Browse Source

Changes to TODO

cerevisiae 14 years ago
parent
commit
0cf2c13a4e
6 changed files with 146 additions and 7 deletions
  1. 7 1
      TODO
  2. 11 1
      vMinecraft.java
  3. 80 1
      vMinecraftCommands.java
  4. 6 0
      vMinecraftListener.java
  5. 9 0
      vMinecraftSettings.java
  6. 33 4
      vMinecraftUsers.java

+ 7 - 1
TODO

@@ -1,5 +1,4 @@
 vMinecraft v1 Todo:
-	! Promote and Demote (ASAP) <Cere> DIBS
 	+ matchPlayer taking into account nicknames and prefixes and suffixes
 	+ Add [] around player tags
 	+ Modify setNick to not allow players to copy other's
@@ -27,9 +26,16 @@ vMinecraft v2 Updates!
 			how much longer they are probated for.
 
 DONE
+        +Added /freeze command to stop players from moving
 	+ Quick recode of /me to use the new getName function
+<<<<<<< HEAD
     + Simple Fire Antigrief
     + /prefix
+=======
+        + Promote and Demote (ASAP) <Cere> DIBS
+        + Simple Fire Antigrief
+        + /prefix
+>>>>>>> 30d6b1ac5186143118978d1d49d9be4295585464
 	+ /a to toggle admin chat
 	+ Code was organized
 	+ Aliasing was added

+ 11 - 1
vMinecraft.java

@@ -13,7 +13,16 @@ public class vMinecraft extends Plugin {
 		vMinecraftSettings.getInstance().loadSettings();
         vMinecraftUsers.getInstance().loadUsers();
 		vMinecraftCommands.loadCommands();
-
+                /*while(true){
+                    if (etc.getServer().getTime() == 0){
+                    vMinecraftChat.gmsg(Colors.Rose + "The sun has risen, it is now safe to punch trees");
+                }
+                if (etc.getServer().getTime() == 13000){
+                    vMinecraftChat.gmsg(Colors.Rose + "What a terrible night to have a curse");
+                }
+                }
+                 * 
+                 */
     }
 
     public void disable() {
@@ -30,6 +39,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);
         }
     }
 

+ 80 - 1
vMinecraftCommands.java

@@ -55,8 +55,10 @@ public class vMinecraftCommands{
         cl.register("/demote", "demote", "Demote a player one rank");
 
         //Movement
+        cl.register("/freeze", "freeze");
         cl.register("/tp", "teleport");
         cl.register("/tphere", "tphere");
+        cl.register("/tpback", "tpback");
         cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
 
         //Health
@@ -176,7 +178,60 @@ public class vMinecraftCommands{
         		.globalmessages());
         return EXIT_SUCCESS;
     }
-    
+    public static int tpback(Player player, String[] args){
+        if(player.canUseCommand("/tpback")){
+            String tpxyz = vMinecraftUsers.getProfile(player).getTpxyz();
+            String tpxyz2[] = tpxyz.split(",");
+            double x = Double.parseDouble(tpxyz2[0]);
+            double y = Double.parseDouble(tpxyz2[1]);
+            double z = Double.parseDouble(tpxyz2[2]);
+            player.teleportTo(x, y, z, 0, 0);
+            String cx = Double.toString(etc.getServer().getSpawnLocation().x);
+            String cy = Double.toString(etc.getServer().getSpawnLocation().y);
+            String cz = Double.toString(etc.getServer().getSpawnLocation().z);
+            String cxyz = cx + "," + cy + "," + cz;
+            vMinecraftUsers.getProfile(player).setTpback(cxyz);
+            player.sendMessage(Colors.Rose + "/tpback data reset to spawn");
+            return EXIT_SUCCESS;
+            
+        }
+        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") && vMinecraftSettings.getInstance().freeze()){
+            if (args.length < 1){
+                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.getInstance().isFrozen(other.getName())){
+                vMinecraftSettings.getInstance().removeFrozen(other.getName());
+                vMinecraftChat.gmsg(player.getName() + Colors.Blue + " has unfrozen " + other.getName());
+                return EXIT_SUCCESS;
+            } else {
+            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
@@ -978,6 +1033,18 @@ public class vMinecraftCommands{
 		
 		//If the player exists transport the user to the player
 		else {
+                    //Storing their previous location for tpback
+                    double x = player.getLocation().x;
+                    double y = player.getLocation().y;
+                    double z = player.getLocation().z;
+                    String x2 = Double.toString(x);
+                    String y2 = Double.toString(y);
+                    String z2 = Double.toString(z);
+                    String xyz = x2+","+y2+","+z2;
+                    vMinecraftUsers.getProfile(player).setTpback(xyz);
+                    if(player.canUseCommand("/tpback")){
+                     player.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return.");
+                    }
 			vMinecraftChat.gmsg( player, vMinecraftChat.getName(player)
 					+ Colors.LightBlue + " has teleported to "
 					+ vMinecraftChat.getName(playerTarget));
@@ -1059,6 +1126,18 @@ public class vMinecraftCommands{
 			log.log(Level.INFO, player.getName() + " teleported "
 					+ player.getName() + " to their self.");
 			playerTarget.teleportTo(player);
+                        double x = player.getLocation().x;
+                        double y = player.getLocation().y;
+                        double z = player.getLocation().z;
+                        String x2 = Double.toString(x);
+                        String y2 = Double.toString(y);
+                        String z2 = Double.toString(z);
+                        String xyz = x2+","+y2+","+z2;
+                        vMinecraftUsers.getProfile(playerTarget).setTpback(xyz);
+                        if(playerTarget.canUseCommand("/tpback"))
+                        {
+                        playerTarget.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return.");
+                        }
 		}
 		return EXIT_SUCCESS;
 	}

+ 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.getInstance().isFrozen(player.getName())){
+                 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)

+ 9 - 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");
@@ -154,6 +158,7 @@ public class vMinecraftSettings {
             ignore = properties.getBoolean("ignore",true);
             colors = properties.getBoolean("colors",true);
             nick = properties.getBoolean("nick",true);
+            freeze = properties.getBoolean("/freeze",true);
 			cmdFabulous = properties.getBoolean("/fabulous",true);
 			cmdPromote = properties.getBoolean("/promote",true);
 			cmdDemote = properties.getBoolean("/demote",true);
@@ -208,6 +213,7 @@ public class vMinecraftSettings {
         public boolean ignore() {return ignore;}
         public boolean colors() {return colors;}
         public boolean nick() {return nick;}
+        public boolean freeze() {return freeze;}
 	public boolean cmdFabulous() {return cmdFabulous;}
 	public boolean cmdPromote() {return cmdPromote;}
 	public boolean cmdDemote() {return cmdDemote;}
@@ -229,11 +235,14 @@ public class vMinecraftSettings {
 	//EzModo methods
     public boolean cmdEzModo() {return cmdEzModo;}
 	public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
+        public boolean isFrozen(String playerName) {return frozenplayers.contains(playerName);}
         public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
 	public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
         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

+ 33 - 4
vMinecraftUsers.java

@@ -152,7 +152,8 @@ class PlayerList
 					   lastMessage,
 					   nickName,
 					   tag,
-					   suffix;
+					   suffix,
+                        tpxyz;
 		
 		private boolean dead;
 		
@@ -181,6 +182,7 @@ class PlayerList
             tag = new String();
             nickName = new String();
             suffix = new String();
+            tpxyz = new String();
             defaultColor = 'f';
 			ignoreList = new ArrayList<String>();
             aliasList = new commandList();
@@ -242,6 +244,12 @@ class PlayerList
         					}
         				}
         			}
+                                //XYZ TP Back value
+                                //Not sure if declaring a double this way will work or not
+                                if(character.length > 7)
+                                {
+                                    tpxyz = character[7];
+                                }
                 	in.close();
         			return true;
             	}
@@ -285,7 +293,7 @@ class PlayerList
             			writer.append(nickName + ":");
             			writer.append(suffix + ":");
             			writer.append(defaultColor + ":");
-            			
+                                           			
             			int i = 0;
             			for(String ignore : ignoreList)
             			{
@@ -294,8 +302,8 @@ class PlayerList
             					writer.append(",");
             			}
             			writer.append(":");
-            			
             			writer.append(aliasList.toString());
+                                writer.append(tpxyz.toString());
             			writer.append("\r\n");
             		}
             	}
@@ -325,6 +333,7 @@ class PlayerList
                 out.append(nickName + ":");
                 out.append(suffix + ":");
                 out.append(defaultColor + ":");
+                
     			
     			int i = 0;
     			for(String ignore : ignoreList)
@@ -334,6 +343,7 @@ class PlayerList
     					out.append(",");
     			}
     			out.append(":");
+                        out.append(tpxyz + ":");
     			
     			out.append(aliasList.toString());
     			out.newLine();
@@ -456,8 +466,27 @@ class PlayerList
 			tag = newTag;
 			save();
 		}
-
+                //=====================================================================
+		//Function:	setTpback
+		//Input:	None
+		//Output:	None
+		//Use:		Sets a player's tpback xyz coordinates
+		//=====================================================================
+                public void setTpback(String newtpback)
+                {
+                    tpxyz = newtpback;
+                    save();
+                }
+                //=====================================================================
+		//Function:	getTpxyz
+		//Input:	None
+		//Output:	Double: The player's tpback x coords
+		//Use:		Gets the x value of tpback
 		//=====================================================================
+                public String getTpxyz() 
+                { 
+                    return tpxyz; 
+                }
 		//Function:	getTag
 		//Input:	None
 		//Output:	String: The player tag