added vanish feature

This commit is contained in:
Bea 2020-08-10 23:43:02 +02:00
parent 61337d8f74
commit 83bb7f316d
8 changed files with 138 additions and 23 deletions

View File

@ -1,7 +1,7 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="spigot-1.15.2"> <library name="spigot-1.15.2">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.15.2-R0.1-SNAPSHOT/bukkit-1.15.2-R0.1-SNAPSHOT.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13-R0.1-SNAPSHOT/bukkit-1.13-R0.1-SNAPSHOT.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@ -25,22 +25,13 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="07a2bd62-176f-41f3-8d41-79f3572514cb" name="Default Changelist" comment=""> <list default="true" id="07a2bd62-176f-41f3-8d41-79f3572514cb" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/Main.class" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/commands/VanishCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/AngryCommand.class" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/listeners/PlayerJoinListener.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/ClearChatCommand.class" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/utils/MindCache.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/FunCommand.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/KissCommand.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/SpookCommand$1.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/SpookCommand.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/listeners/CollisionListener.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/listeners/PlayerDeathListener.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/utils/RunningTask.class" afterDir="false" />
<change afterPath="$PROJECT_DIR$/out/production/Kisses/plugin.yml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/listeners/PlayerDeathListener.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/artifacts/Spigot_Plugin_jar.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/artifacts/Spigot_Plugin_jar.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/spigot_1_15_2.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/spigot_1_15_2.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/libraries/spigot_1_15_2.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/spigot_1_15_2.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/Main.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/commands/SpookCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/commands/SpookCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/plugin.yml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/plugin.yml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -71,7 +62,7 @@
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="kisses" /> <property name="GenerateAntBuildDialog.outputFileNameProperty" value="kisses" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../Server/plugins" /> <property name="last_opened_file_path" value="$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13-R0.1-SNAPSHOT/bukkit-1.13-R0.1-SNAPSHOT.jar" />
<property name="project.structure.last.edited" value="Artifacts" /> <property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" /> <property name="project.structure.side.proportion" value="0.2" />
@ -104,17 +95,20 @@
<option name="oldMeFiltersMigrated" value="true" /> <option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="249" y="0" key="#Project_Structure" timestamp="1596835802288"> <state x="311" y="30" width="1024" height="841" key="#Project_Structure" timestamp="1597095648391">
<screen x="0" y="0" width="1536" height="834" /> <screen x="0" y="30" width="1920" height="1050" />
</state> </state>
<state x="249" y="0" key="#Project_Structure/0.0.1536.834@0.0.1536.834" timestamp="1596835802288" /> <state x="249" y="0" key="#Project_Structure/0.0.1536.834@0.0.1536.834" timestamp="1596835802288" />
<state x="501" y="158" key="FileChooserDialogImpl" timestamp="1596835796216"> <state x="311" y="30" width="1024" height="841" key="#Project_Structure/0.30.1920.1050@0.30.1920.1050" timestamp="1597095648391" />
<screen x="0" y="0" width="1536" height="834" /> <state x="626" y="229" width="750" height="510" key="FileChooserDialogImpl" timestamp="1597094957721">
<screen x="0" y="30" width="1920" height="1050" />
</state> </state>
<state x="501" y="158" key="FileChooserDialogImpl/0.0.1536.834@0.0.1536.834" timestamp="1596835796216" /> <state x="501" y="158" key="FileChooserDialogImpl/0.0.1536.834@0.0.1536.834" timestamp="1596835796216" />
<state x="277" y="0" key="SettingsEditor" timestamp="1596835536928"> <state x="626" y="229" width="750" height="510" key="FileChooserDialogImpl/0.30.1920.1050@0.30.1920.1050" timestamp="1597094957721" />
<screen x="0" y="0" width="1536" height="834" /> <state x="346" y="30" width="1024" height="841" key="SettingsEditor" timestamp="1597094959997">
<screen x="0" y="30" width="1920" height="1050" />
</state> </state>
<state x="277" y="0" key="SettingsEditor/0.0.1536.834@0.0.1536.834" timestamp="1596835536928" /> <state x="277" y="0" key="SettingsEditor/0.0.1536.834@0.0.1536.834" timestamp="1596835536928" />
<state x="346" y="30" width="1024" height="841" key="SettingsEditor/0.30.1920.1050@0.30.1920.1050" timestamp="1597094959997" />
</component> </component>
</project> </project>

View File

@ -3,6 +3,7 @@ package net.mindoverflow.kissplugin;
import net.mindoverflow.kissplugin.commands.*; import net.mindoverflow.kissplugin.commands.*;
import net.mindoverflow.kissplugin.listeners.CollisionListener; import net.mindoverflow.kissplugin.listeners.CollisionListener;
import net.mindoverflow.kissplugin.listeners.PlayerDeathListener; import net.mindoverflow.kissplugin.listeners.PlayerDeathListener;
import net.mindoverflow.kissplugin.listeners.PlayerJoinListener;
import net.mindoverflow.kissplugin.utils.RunningTask; import net.mindoverflow.kissplugin.utils.RunningTask;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -26,9 +27,11 @@ public class Main extends JavaPlugin
getCommand("kiss").setExecutor(new KissCommand(this)); getCommand("kiss").setExecutor(new KissCommand(this));
getCommand("spook").setExecutor(new SpookCommand(this)); getCommand("spook").setExecutor(new SpookCommand(this));
getCommand("angry").setExecutor(new AngryCommand(this)); getCommand("angry").setExecutor(new AngryCommand(this));
getCommand("vanish").setExecutor(new VanishCommand());
getServer().getPluginManager().registerEvents(new CollisionListener(this), this); getServer().getPluginManager().registerEvents(new CollisionListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerDeathListener(), this); getServer().getPluginManager().registerEvents(new PlayerDeathListener(), this);
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
runningTask.task = getServer().getScheduler().runTaskTimer(this, runningTask, 10, 10); runningTask.task = getServer().getScheduler().runTaskTimer(this, runningTask, 10, 10);
} }

View File

@ -30,7 +30,8 @@ public class SpookCommand implements CommandExecutor
ArrayList<String>spookedPlayers = new ArrayList<>(); ArrayList<String>spookedPlayers = new ArrayList<>();
@Override @Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args)
{
if(commandSender instanceof Player) if(commandSender instanceof Player)
{ {

View File

@ -0,0 +1,53 @@
package net.mindoverflow.kissplugin.commands;
import net.mindoverflow.kissplugin.utils.MindCache;
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 VanishCommand implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args)
{
if(!commandSender.hasPermission("funplugin.vanish"))
{
commandSender.sendMessage("§cNo permissions!");
return true;
}
if(!(commandSender instanceof Player))
{
commandSender.sendMessage("Only players!");
return true;
}
Player player = (Player) commandSender;
String username = player.getName();
if(!MindCache.vanishedPlayers.contains(username))
{
for(Player hideTo : Bukkit.getServer().getOnlinePlayers())
{
hideTo.hidePlayer(player);
}
MindCache.vanishedPlayers.add(username);
player.sendMessage("§bHidden to everyone!");
}
else
{
for(Player showTo : Bukkit.getServer().getOnlinePlayers())
{
showTo.showPlayer(player);
}
MindCache.vanishedPlayers.remove(username);
player.sendMessage("§eShown to everyone!");
}
return true;
}
}

View File

@ -0,0 +1,50 @@
package net.mindoverflow.kissplugin.listeners;
import net.mindoverflow.kissplugin.utils.MindCache;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerJoinListener implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
for(String username : MindCache.vanishedPlayers)
{
Player hiddenPlayer = Bukkit.getPlayer(username);
if(hiddenPlayer != null)
{
event.getPlayer().hidePlayer(hiddenPlayer);
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
for(String username : MindCache.vanishedPlayers)
{
Player hiddenPlayer = Bukkit.getPlayer(username);
if(hiddenPlayer != null)
{
event.getPlayer().showPlayer(hiddenPlayer);
}
}
Player player = event.getPlayer();
String username = player.getName();
if(MindCache.vanishedPlayers.contains(username))
{
for(Player onlinePlayer : Bukkit.getServer().getOnlinePlayers())
{
onlinePlayer.showPlayer(player);
}
}
MindCache.vanishedPlayers.remove(username);
}
}

View File

@ -0,0 +1,10 @@
package net.mindoverflow.kissplugin.utils;
import java.util.ArrayList;
import java.util.List;
public class MindCache
{
public static List<String> vanishedPlayers = new ArrayList<>();
}

View File

@ -21,4 +21,8 @@ commands:
clearchat: clearchat:
usage: /<command> usage: /<command>
description: Clear the chat! description: Clear the chat!
aliases: [cc] aliases: [cc]
vanish:
usage: /<command>
description: Vanish!
aliases: [v, va]