Browse Source

Added a /freeze command for fun

nossr50 14 years ago
parent
commit
ad29bb2bbb
4 changed files with 46 additions and 1 deletions
  1. 1 0
      vMinecraft.java
  2. 33 1
      vMinecraftCommands.java
  3. 6 0
      vMinecraftListener.java
  4. 6 0
      vMinecraftSettings.java

+ 1 - 0
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);
         }
     }
 

+ 33 - 1
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

+ 6 - 0
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)

+ 6 - 0
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<String> ezModo = new ArrayList<String>();
+        //An array of players currently frozen
+        static ArrayList<String> frozenplayers = new ArrayList<String>();
     //An array of players currently toggled for admin chat
     static ArrayList<String> adminChatList = new ArrayList<String>();
     //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