diff --git a/vMinecraft.java b/vMinecraft.java index e55d4931c..69cc66381 100644 --- a/vMinecraft.java +++ b/vMinecraft.java @@ -30,6 +30,7 @@ public class vMinecraft extends Plugin { etc.getLoader().addListener(PluginLoader.Hook.EXPLODE, listener, this, PluginListener.Priority.HIGH); etc.getLoader().addListener(PluginLoader.Hook.LIQUID_DESTROY, listener, this, PluginListener.Priority.MEDIUM); etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM); + etc.getLoader().addListener(PluginLoader.Hook.PLAYER_MOVE, listener, this, PluginListener.Priority.MEDIUM); } } diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index cbb44cc08..957502a73 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -176,7 +176,39 @@ public class vMinecraftCommands{ .globalmessages()); return EXIT_SUCCESS; } - + //===================================================================== + //Function: prefix (/prefix) + //Input: Player player: The player using the command + // String[] args: The name of the player + //Output: int: Exit Code + //Use: Freezes a player in place + //===================================================================== + public static int freeze(Player player, String[] args){ + if(player.canUseCommand("/freeze")){ + if (args.length < 2){ + vMinecraftChat.gmsg(Colors.Rose + "Usage is /freeze [Player]"); + return EXIT_SUCCESS; + } + Player other = etc.getServer().matchPlayer(args[0]); + if (other == null) + { + vMinecraftChat.gmsg(Colors.Rose + "The player you specified could not be found"); + return EXIT_SUCCESS; + } + if(player != other && other.hasControlOver(player)){ + vMinecraftChat.gmsg(Colors.Rose + "The player you specified has a higher rank than you"); + return EXIT_SUCCESS; + } + if(vMinecraftSettings.frozenplayers.contains(other)){ + vMinecraftSettings.getInstance().removeFrozen(other.getName()); + return EXIT_SUCCESS; + } + vMinecraftSettings.getInstance().addFrozen(other.getName()); + vMinecraftChat.gmsg(player.getName() + Colors.Blue + " has frozen " + other.getName()); + return EXIT_SUCCESS; + } + return EXIT_SUCCESS; + } //===================================================================== //Function: prefix (/prefix) //Input: Player player: The player using the command diff --git a/vMinecraftListener.java b/vMinecraftListener.java index ac2f7e1d3..99e38fc6b 100644 --- a/vMinecraftListener.java +++ b/vMinecraftListener.java @@ -17,6 +17,11 @@ public class vMinecraftListener extends PluginListener { public void disable() { log.log(Level.INFO, "vMinecraft disabled"); } + public void onPlayerMove(Player player, Location from, Location to) { + if(vMinecraftSettings.frozenplayers.contains(player)){ + player.teleportTo(from); + } + } //===================================================================== //Function: onChat @@ -26,6 +31,7 @@ public class vMinecraftListener extends PluginListener { // and it is enabled //Use: Checks for quote, rage, and colors //===================================================================== + public boolean onChat(Player player, String message){ //Quote (Greentext) diff --git a/vMinecraftSettings.java b/vMinecraftSettings.java index 91508bb93..214bc694a 100644 --- a/vMinecraftSettings.java +++ b/vMinecraftSettings.java @@ -24,6 +24,7 @@ public class vMinecraftSettings { ignore = false, colors = false, nick = false, + freeze = false, cmdFabulous = false, cmdPromote = false, cmdDemote = false, @@ -43,6 +44,8 @@ public class vMinecraftSettings { cmdEzModo = false; //An array of players currently in ezmodo static ArrayList ezModo = new ArrayList(); + //An array of players currently frozen + static ArrayList frozenplayers = new ArrayList(); //An array of players currently toggled for admin chat static ArrayList adminChatList = new ArrayList(); //An array of blocks that won't catch on fire @@ -96,6 +99,7 @@ public class vMinecraftSettings { writer.write("#Enables or Disables the following commands, give groups/users permissions to use these commands for them to work\r\n"); writer.write("/fabulous=true\r\n"); writer.write("/prefix=true\r\n"); + writer.write("/freeze=true\r\n"); writer.write("/suffix=true\r\n"); writer.write("/ignore=true\r\n"); writer.write("/colors=true\r\n"); @@ -234,6 +238,8 @@ public class vMinecraftSettings { public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));} public void addEzModo(String playerName) {ezModo.add(playerName);} public void addAdminToggled(String playerName) {adminChatList.add(playerName);} + public void addFrozen(String playerName) {frozenplayers.add(playerName);} + public void removeFrozen (String playerName) {frozenplayers.remove(frozenplayers.indexOf(playerName));} public String ezModoList() {return ezModo.toString();} //Random death message method