added vanish feature
This commit is contained in:
parent
61337d8f74
commit
83bb7f316d
@ -1,7 +1,7 @@
|
||||
<component name="libraryTable">
|
||||
<library name="spigot-1.15.2">
|
||||
<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>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
@ -25,22 +25,13 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<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$/out/production/Kisses/net/mindoverflow/kissplugin/commands/AngryCommand.class" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/out/production/Kisses/net/mindoverflow/kissplugin/commands/ClearChatCommand.class" 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 afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/commands/VanishCommand.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/listeners/PlayerJoinListener.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/net/mindoverflow/kissplugin/utils/MindCache.java" 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$/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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -71,7 +62,7 @@
|
||||
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="kisses" />
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" 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.proportion" value="0.15" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
@ -104,17 +95,20 @@
|
||||
<option name="oldMeFiltersMigrated" value="true" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="249" y="0" key="#Project_Structure" timestamp="1596835802288">
|
||||
<screen x="0" y="0" width="1536" height="834" />
|
||||
<state x="311" y="30" width="1024" height="841" key="#Project_Structure" timestamp="1597095648391">
|
||||
<screen x="0" y="30" width="1920" height="1050" />
|
||||
</state>
|
||||
<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">
|
||||
<screen x="0" y="0" width="1536" height="834" />
|
||||
<state x="311" y="30" width="1024" height="841" key="#Project_Structure/0.30.1920.1050@0.30.1920.1050" timestamp="1597095648391" />
|
||||
<state x="626" y="229" width="750" height="510" key="FileChooserDialogImpl" timestamp="1597094957721">
|
||||
<screen x="0" y="30" width="1920" height="1050" />
|
||||
</state>
|
||||
<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">
|
||||
<screen x="0" y="0" width="1536" height="834" />
|
||||
<state x="626" y="229" width="750" height="510" key="FileChooserDialogImpl/0.30.1920.1050@0.30.1920.1050" timestamp="1597094957721" />
|
||||
<state x="346" y="30" width="1024" height="841" key="SettingsEditor" timestamp="1597094959997">
|
||||
<screen x="0" y="30" width="1920" height="1050" />
|
||||
</state>
|
||||
<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>
|
||||
</project>
|
@ -3,6 +3,7 @@ package net.mindoverflow.kissplugin;
|
||||
import net.mindoverflow.kissplugin.commands.*;
|
||||
import net.mindoverflow.kissplugin.listeners.CollisionListener;
|
||||
import net.mindoverflow.kissplugin.listeners.PlayerDeathListener;
|
||||
import net.mindoverflow.kissplugin.listeners.PlayerJoinListener;
|
||||
import net.mindoverflow.kissplugin.utils.RunningTask;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -26,9 +27,11 @@ public class Main extends JavaPlugin
|
||||
getCommand("kiss").setExecutor(new KissCommand(this));
|
||||
getCommand("spook").setExecutor(new SpookCommand(this));
|
||||
getCommand("angry").setExecutor(new AngryCommand(this));
|
||||
getCommand("vanish").setExecutor(new VanishCommand());
|
||||
|
||||
getServer().getPluginManager().registerEvents(new CollisionListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerDeathListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
|
||||
|
||||
runningTask.task = getServer().getScheduler().runTaskTimer(this, runningTask, 10, 10);
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ public class SpookCommand implements CommandExecutor
|
||||
ArrayList<String>spookedPlayers = new ArrayList<>();
|
||||
|
||||
@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)
|
||||
{
|
||||
|
53
src/net/mindoverflow/kissplugin/commands/VanishCommand.java
Normal file
53
src/net/mindoverflow/kissplugin/commands/VanishCommand.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
10
src/net/mindoverflow/kissplugin/utils/MindCache.java
Normal file
10
src/net/mindoverflow/kissplugin/utils/MindCache.java
Normal 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<>();
|
||||
|
||||
}
|
@ -21,4 +21,8 @@ commands:
|
||||
clearchat:
|
||||
usage: /<command>
|
||||
description: Clear the chat!
|
||||
aliases: [cc]
|
||||
aliases: [cc]
|
||||
vanish:
|
||||
usage: /<command>
|
||||
description: Vanish!
|
||||
aliases: [v, va]
|
Loading…
Reference in New Issue
Block a user