initial commit

This commit is contained in:
Bea 2020-04-09 18:20:14 +02:00
commit bcc950f25f
21 changed files with 773 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="Spigot Plugin:jar">
<output-path>$PROJECT_DIR$/../../# Server per Test Plugins #/plugins</output-path>
<root id="archive" name="FunPlugin.jar">
<element id="module-output" name="Kisses" />
</root>
</artifact>
</component>

0
.idea/description.html Normal file
View File

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="spigot-1.15.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../../spigot-1.15.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../../spigot-1.15.2.jar!/" />
</SOURCES>
</library>
</component>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Kisses.iml" filepath="$PROJECT_DIR$/Kisses.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="net.mindoverflow.spigotplugin">IJ_BASE_PACKAGE</input-field>
</template>

5
.idea/template-meta.xml Normal file
View File

@ -0,0 +1,5 @@
<template unencoded="false">
<roots>
<root index="0" path="" />
</roots>
</template>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

70
.idea/workspace.xml Normal file
View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ArtifactsWorkspaceSettings">
<artifacts-to-build>
<artifact name="Spigot Plugin:jar" />
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="07a2bd62-176f-41f3-8d41-79f3572514cb" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1YuSKheBn0YttuWLQPS3O9ogJjW" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="GenerateAntBuildDialog.backupFiles" value="true" />
<property name="GenerateAntBuildDialog.enableUiFormCompile" value="true" />
<property name="GenerateAntBuildDialog.forceTargetJdk" value="true" />
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="kisses" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="07a2bd62-176f-41f3-8d41-79f3572514cb" name="Default Changelist" comment="" />
<created>1583790923733</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1583790923733</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="873" y="359" key="#Project_Structure" timestamp="1583805186710">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="873" y="359" key="#Project_Structure/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1583805186710" />
<state x="1086" y="404" key="#com.intellij.ide.util.MemberChooser" timestamp="1583804513083">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="1086" y="404" key="#com.intellij.ide.util.MemberChooser/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1583804513083" />
<state x="967" y="441" key="FileChooserDialogImpl" timestamp="1583790955612">
<screen x="0" y="0" width="2560" height="1400" />
</state>
<state x="967" y="441" key="FileChooserDialogImpl/0.0.2560.1400/3840.1065.1600.860/-1360.1191.1360.728@0.0.2560.1400" timestamp="1583790955612" />
</component>
</project>

23
Kisses.iml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../# Server per Test Plugins #/spigot-1.14.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../# Server per Test Plugins #/spigot-1.14.2.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="spigot-1.15.2" level="project" />
</component>
</module>

View File

@ -0,0 +1,40 @@
package net.mindoverflow.kissplugin;
import net.mindoverflow.kissplugin.commands.*;
import net.mindoverflow.kissplugin.listeners.CollisionListener;
import net.mindoverflow.kissplugin.utils.RunningTask;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main extends JavaPlugin
{
// Initializing needed variables.
private Logger logger;
public RunningTask runningTask = new RunningTask(this);
// Method called when the plugin is being loaded.
@Override
public void onEnable() {
logger = getLogger();
logger.log(Level.INFO, "Plugin Successfully Loaded!");
getCommand("fun").setExecutor(new FunCommand());
getCommand("clearchat").setExecutor(new ClearChatCommand());
getCommand("kiss").setExecutor(new KissCommand(this));
getCommand("spook").setExecutor(new SpookCommand(this));
getCommand("angry").setExecutor(new AngryCommand(this));
getServer().getPluginManager().registerEvents(new CollisionListener(this), this);
runningTask.task = getServer().getScheduler().runTaskTimer(this, runningTask, 10, 10);
}
// Method called when the plugin is being unloaded.
@Override
public void onDisable() {
getServer().getScheduler().cancelTasks(this);
logger.log(Level.INFO, "Plugin Successfully Unloaded!");
}
}

View File

@ -0,0 +1,81 @@
package net.mindoverflow.kissplugin.commands;
import net.mindoverflow.kissplugin.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class AngryCommand implements CommandExecutor
{
private Main plugin;
public AngryCommand(Main plugin)
{
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if(commandSender instanceof Player)
{
Player sender = (Player)commandSender;
if(plugin.runningTask.angryPlayers.containsKey(sender.getName()))
{
noLongerAngry(sender.getName(), plugin);
return true;
}
int howLong = 60;
if(args.length == 0)
{
plugin.runningTask.angryPlayers.put(sender.getName(), howLong * plugin.runningTask.multiplier);
LocalTime timeOfDay = LocalTime.ofSecondOfDay(howLong);
String time = timeOfDay.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
time = time.replaceFirst(":", " hours, ");
time = time.replaceFirst(":", " minutes, and ");
time = time + " seconds";
sender.sendMessage("§7You will be angry for §c" + time + "§7!");
sender.sendMessage("§7You did not specify for how long! Use §c/angry <seconds>§7 to set a specific time.");
}
else
{
howLong = Integer.parseInt(args[0]);
if(howLong > 86399) howLong = 86399;
plugin.runningTask.angryPlayers.put(sender.getName(), howLong * plugin.runningTask.multiplier);
LocalTime timeOfDay = LocalTime.ofSecondOfDay(howLong);
String time = timeOfDay.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
time = time.replaceFirst(":", " hours, ");
time = time.replaceFirst(":", " minutes, and ");
time = time + " seconds";
sender.sendMessage("§7You will be angry for §c" + time + "§7!");
}
plugin.getServer().broadcastMessage("§c" + sender.getName() + "§e is now angry!");
}
return true;
}
public static void noLongerAngry(String playerName, Main plugin)
{
plugin.runningTask.angryPlayers.remove(playerName);
plugin.getServer().broadcastMessage("§a" + playerName + "§e is no longer angry!");
Player player = plugin.getServer().getPlayer(playerName);
if(player == null) return;
player.sendMessage("§aYou are no longer angry!");
}
}

View File

@ -0,0 +1,40 @@
package net.mindoverflow.kissplugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ClearChatCommand implements CommandExecutor
{
public static String permission = "funplugin.clearchat";
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(commandSender.hasPermission(permission))
{
String message = "§7Chat cleared by §c" + commandSender.getName();
for(Player p : Bukkit.getServer().getOnlinePlayers())
{
for(int i = 0; i < 200; i++)
{
p.sendMessage("");
}
p.sendMessage(message);
}
Bukkit.getConsoleSender().sendMessage(message);
}
else
{
commandSender.sendMessage("§cMissing permission: §4" + permission);
}
return true;
}
}

View File

@ -0,0 +1,37 @@
package net.mindoverflow.kissplugin.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class FunCommand implements CommandExecutor
{
private CommandSender sender;
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
sender = commandSender;
sendMessage("§6------------[ FunPlugin ]------------");
sendMessage("§c/kiss§7: give a kiss to the nearest player!");
sendMessage("§7You can also walk towards the player to give a kiss.");
sendMessage("");
sendMessage("§d/spook§7: spook the nearest player!");
sendMessage("§7Be careful not to give too many spooks!");
sendMessage("");
sendMessage("§4/angry <seconds>§7: become angry for a specified time!");
sendMessage("§7You will keep spawning angry particles for that long.");
sendMessage("");
sendMessage("§e/clearchat§7: clear everybody's chat.");
sendMessage("§7Only admins can run this command! (§8" + ClearChatCommand.permission + "§7)");
return true;
}
private void sendMessage(String message)
{
sender.sendMessage(message);
}
}

View File

@ -0,0 +1,87 @@
package net.mindoverflow.kissplugin.commands;
import net.mindoverflow.kissplugin.Main;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class KissCommand implements CommandExecutor
{
private Main plugin;
public KissCommand(Main plugin)
{
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
if(commandSender instanceof Player)
{
Player sender = (Player)commandSender;
for(Entity e : sender.getNearbyEntities(3, 3, 3))
{
if(e instanceof Player)
{
Player nearPlayer = (Player)e;
sendKiss(sender, nearPlayer, true, true, true, true, 5, 5, 10);
return true;
}
}
commandSender.sendMessage("§7There is no one to kiss around you! =(");
return true;
}
else
{
commandSender.sendMessage("§cOnly players can kiss other people!");
}
return true;
}
public static void sendKiss(Player sender, Player nearPlayer, boolean sendMessage, boolean playSound, boolean sendTitle, boolean spawnParticle, int titleFadeIn, int titleFadeOut, int particleCount)
{
if(sendMessage)
{
sender.sendMessage("§7You kissed §c" + nearPlayer.getName() + "§7!");
nearPlayer.sendMessage("§c" + sender.getName() + " §7kissed you!");
}
if(sendTitle)
{
sender.sendTitle("", "§c❤ §7You kissed §c" + nearPlayer.getName() + "§7! §c❤", titleFadeIn, 20, titleFadeOut);
nearPlayer.sendTitle("", "§c❤ §c" + sender.getName() + " §7kissed you! §c❤", titleFadeIn, 20, titleFadeOut);
}
if(spawnParticle)
{
sender.spawnParticle(Particle.HEART, nearPlayer.getEyeLocation(), particleCount, 0.3, 0.2, 0.3);
nearPlayer.spawnParticle(Particle.HEART, sender.getEyeLocation(), particleCount, 0.3, 0.2, 0.3);
}
if(playSound)
{
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.6f);
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.8f);
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 1f);
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.6f);
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.8f);
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 1f);
}
}
}

View File

@ -0,0 +1,82 @@
package net.mindoverflow.kissplugin.commands;
import net.mindoverflow.kissplugin.Main;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.Random;
public class SpookCommand implements CommandExecutor
{
private Main plugin;
public SpookCommand(Main plugin)
{
this.plugin = plugin;
}
ArrayList<Sound>spookSounds = new ArrayList<Sound>(){{
add(Sound.AMBIENT_CAVE);
add(Sound.ENTITY_GENERIC_EXPLODE);
add(Sound.ENTITY_DRAGON_FIREBALL_EXPLODE);
}};
ArrayList<String>spookedPlayers = new ArrayList<>();
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if(commandSender instanceof Player)
{
Player sender = (Player)commandSender;
for(Entity e : sender.getNearbyEntities(6, 6, 6))
{
if(e instanceof Player)
{
Player nearPlayer = (Player)e;
String name = nearPlayer.getName();
if(spookedPlayers.contains(name))
{
sender.sendMessage("§7You already spooked §c" + name + "§7 recently!");
return true;
}
spookedPlayers.add(name);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, ()->
{
spookedPlayers.remove(name);
}, 1200);
nearPlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 1, false, false, false));
nearPlayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 1, false, false, false));
nearPlayer.playSound(nearPlayer.getLocation(), getRandomSound(spookSounds), 1, 1);
nearPlayer.sendTitle("§4Boo!", "§cYou got spooked by " + sender.getName() + "!", 0, 60, 10);
nearPlayer.getWorld().strikeLightningEffect(nearPlayer.getLocation());
return true;
}
}
commandSender.sendMessage("§7there is no one to spook around you! =(");
}
return true;
}
private Sound getRandomSound(ArrayList<Sound> list)
{
Random random = new Random();
return list.get(random.nextInt(list.size()));
}
}

View File

@ -0,0 +1,65 @@
package net.mindoverflow.kissplugin.listeners;
import net.mindoverflow.kissplugin.Main;
import net.mindoverflow.kissplugin.commands.KissCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class CollisionListener implements Listener
{
private Main plugin;
public CollisionListener(Main plugin)
{
this.plugin = plugin;
}
/*@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
for(Entity e : event.getPlayer().getNearbyEntities(0.1, 0.1, 0.1))
{
if(e instanceof Player)
{
/*plugin.getServer().getScheduler().runTaskLater(plugin, ()->
{
for(Entity newE : event.getPlayer().getNearbyEntities(0.2, 0.2, 0.2))
{
if(newE instanceof Player && newE.getName().equals(e.getName()))
{*/
//KissCommand.sendKiss(event.getPlayer(), (Player)e, false, false, true, true, 0, 5, 3);
/* }
}
}, 10);*/
/*}
}
}*/
/*@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
for(Entity e : event.getPlayer().getNearbyEntities(0.1, 0.1, 0.1))
{
if (e instanceof Player)
{
KissCommand.sendKiss(event.getPlayer(), (Player) e, false, false, true, true, 0, 5, 3);
}
}
}*/
@EventHandler
public void onPlayerRightClick(PlayerInteractEntityEvent event)
{
if(event.getRightClicked() instanceof Player)
{
KissCommand.sendKiss(event.getPlayer(), (Player)event.getRightClicked(), false, false, true, true, 0, 5, 3);
}
}
}

View File

@ -0,0 +1,47 @@
package net.mindoverflow.kissplugin.utils;
import net.mindoverflow.kissplugin.Main;
import net.mindoverflow.kissplugin.commands.AngryCommand;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
public class RunningTask implements Runnable
{
public int multiplier = 2;
private Main plugin;
public RunningTask(Main plugin)
{
this.plugin = plugin;
}
// <PlayerName, RemainingTime>
public HashMap<String, Integer>angryPlayers = new HashMap<>();
public BukkitTask task;
@Override
public void run() {
for(String s : angryPlayers.keySet())
{
Player p = plugin.getServer().getPlayer(s);
if(angryPlayers.get(s) > 0)
{
p.getWorld().spawnParticle(Particle.VILLAGER_ANGRY, p.getEyeLocation(), 2,0.3, 0.2, 0.3);
angryPlayers.put(s, angryPlayers.get(s) - 1);
}
else
{
AngryCommand.noLongerAngry(s, plugin);
}
}
}
}

24
src/plugin.yml Normal file
View File

@ -0,0 +1,24 @@
name: FunPlugin
version: 0.5.0
author: mind_overflow
main: net.mindoverflow.kissplugin.Main
api-version: 1.15
commands:
fun:
usage: /<command>
description: Main command for this plugin. Show all the info and usage.
aliases: [info]
kiss:
usage: /<command>
description: Give kisses
aliases: [k]
spook:
usage: /<command>
description: Spook someone!
angry:
usage: /<command> <time>
description: Become angry for <time> seconds!
clearchat:
usage: /<command>
description: Clear the chat!
aliases: [cc]