Browse Source

Added a nickname and suffix feature.

cerevisiae 14 years ago
parent
commit
f034a9e477
2 changed files with 125 additions and 2 deletions
  1. 3 2
      TODO
  2. 122 0
      vMinecraftCommands.java

+ 3 - 2
TODO

@@ -2,14 +2,13 @@ Vminecraft b8 Todo:
 	+ ^r for rainbow color code
 	+ ^r for rainbow color code
 	+ Finish work on the flat file system
 	+ Finish work on the flat file system
 	+ Antigriefs <Nos> Working on this
 	+ Antigriefs <Nos> Working on this
-	+ Allow players to nickname themselves or others
 	+ Time manipulation <Cere> Working on this
 	+ Time manipulation <Cere> Working on this
 		* Have time changes not be instant but move the sky faster
 		* Have time changes not be instant but move the sky faster
 			to get to the time entered
 			to get to the time entered
 		* Loop through specific times of the day and then rewind
 		* Loop through specific times of the day and then rewind
 			ex: Sunrise to sunset, mid-morning to noon
 			ex: Sunrise to sunset, mid-morning to noon
 	+ Aliasing Commands (Global Aliases and Personal Aliases) <Cere>
 	+ Aliasing Commands (Global Aliases and Personal Aliases) <Cere>
-	+ Different types of /slay
+	? Different types of /slay
 		* /slay fire to burn them to death
 		* /slay fire to burn them to death
 		* /slay drown to drown them
 		* /slay drown to drown them
 		* /slay boil to burn them with lava
 		* /slay boil to burn them with lava
@@ -43,5 +42,7 @@ DONE
 	+ Recode Messaging
 	+ Recode Messaging
 		* Reply Feature
 		* Reply Feature
 		* Personal Muting
 		* Personal Muting
+	+ Allow players to nickname themselves or others
+	+ Allow players to set suffixes
 
 
 Notes: Let's try to to finish as much of this list as possible tomorrow and push for a b8 release soon :P
 Notes: Let's try to to finish as much of this list as possible tomorrow and push for a b8 release soon :P

+ 122 - 0
vMinecraftCommands.java

@@ -174,6 +174,7 @@ public class vMinecraftCommands{
     //=====================================================================
     //=====================================================================
 	//Function:	prefix (/prefix)
 	//Function:	prefix (/prefix)
 	//Input:	Player player: The player using the command
 	//Input:	Player player: The player using the command
+    //			String[] args: The color and the prefix
 	//Output:	int: Exit Code
 	//Output:	int: Exit Code
 	//Use:		Changes your name color and prefix
 	//Use:		Changes your name color and prefix
 	//=====================================================================
 	//=====================================================================
@@ -197,6 +198,127 @@ public class vMinecraftCommands{
         return EXIT_SUCCESS;
         return EXIT_SUCCESS;
     }
     }
     
     
+    //=====================================================================
+	//Function:	nickName (/nick)
+	//Input:	Player player: The player using the command
+    //			String[] args: The color and the prefix
+	//Output:	int: Exit Code
+	//Use:		Changes your name color and prefix
+	//=====================================================================
+    public static int nickName(Player player, String[] args){
+    	
+    	//if the player can nickname others
+        if(player.canUseCommand("/nickother")){
+            if(args.length < 2){
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "Usage is /prefix [Player] [Name]");
+                return EXIT_SUCCESS;
+            }
+            
+            //Check if the nickname is too long
+            if(args[1].length() > 20)
+            {
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "The suffix you entered was too long.");
+                return EXIT_SUCCESS;
+            }
+            
+            //Check if the player exists
+            Player other = etc.getServer().matchPlayer(args[0]);
+            if(other == null)
+            {
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "The player you specified could not be found");
+                return EXIT_SUCCESS;
+            }
+            vMinecraftUsers.getProfile(other).setNick(args[1]);
+            
+            return EXIT_SUCCESS;
+        }
+        
+        //Make sure they can nickname themselves
+        if(!player.canUseCommand("/nick")){
+            return EXIT_FAIL;
+        }
+        
+        //Check if the nickname is too long
+        if(args[0].length() > 20)
+        {
+            vMinecraftChat.sendMessage(player, player, Colors.Rose
+            		+ "The suffix you entered was too long.");
+            return EXIT_SUCCESS;
+        }
+        
+        if(args.length < 1){
+            vMinecraftChat.sendMessage(player, player, Colors.Rose
+            		+ "Usage is /prefix [Name]");
+            return EXIT_SUCCESS;
+        }
+        vMinecraftUsers.getProfile(player).setNick(args[0]);
+        
+        return EXIT_SUCCESS;
+    }
+    
+    //=====================================================================
+	//Function:	suffix (/suffix)
+	//Input:	Player player: The player using the command
+    //			String[] args: The color and the prefix
+	//Output:	int: Exit Code
+	//Use:		Changes your name color and prefix
+	//=====================================================================
+    public static int suffix(Player player, String[] args){
+    	
+    	//if the player can suffix others
+        if(player.canUseCommand("/suffixother")){
+            if(args.length < 2){
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "Usage is /suffix [Player] [Name]");
+                return EXIT_SUCCESS;
+            }
+            
+            //Check if the suffix is too long
+            if(args[1].length() > 10)
+            {
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "The suffix you entered was too long.");
+                return EXIT_SUCCESS;
+            }
+            
+            //Check if the player exists
+            Player other = etc.getServer().matchPlayer(args[0]);
+            if(other == null)
+            {
+                vMinecraftChat.sendMessage(player, player, Colors.Rose
+                		+ "The player you specified could not be found");
+                return EXIT_SUCCESS;
+            }
+            vMinecraftUsers.getProfile(other).setSuffix(args[1]);
+            
+            return EXIT_SUCCESS;
+        }
+        
+        //Check if the player can set their own suffix.
+        if(!player.canUseCommand("/suffix")){
+            return EXIT_FAIL;
+        }
+        if(args.length < 1){
+            vMinecraftChat.sendMessage(player, player, Colors.Rose
+            		+ "Usage is /suffix [Suffix]");
+            return EXIT_SUCCESS;
+        }
+        
+        //Check if the suffix is too long
+        if(args[0].length() > 10)
+        {
+            vMinecraftChat.sendMessage(player, player, Colors.Rose
+            		+ "The suffix you entered was too long.");
+            return EXIT_SUCCESS;
+        }
+        vMinecraftUsers.getProfile(player).setSuffix(args[0]);
+        
+        return EXIT_SUCCESS;
+    }
+    
     //=====================================================================
     //=====================================================================
 	//Function:	colors (/colors)
 	//Function:	colors (/colors)
 	//Input:	Player player: The player using the command
 	//Input:	Player player: The player using the command