Browse Source

Added half-functional /me recode

nossr50 14 years ago
parent
commit
91a9e1350b
3 changed files with 31 additions and 7 deletions
  1. 2 3
      vMinecraft.java
  2. 16 2
      vMinecraftChat.java
  3. 13 2
      vMinecraftCommands.java

+ 2 - 3
vMinecraft.java

@@ -25,8 +25,7 @@ public class vMinecraft extends Plugin {
         etc.getLoader().addListener(PluginLoader.Hook.IGNITE, listener, this, PluginListener.Priority.HIGH);
         etc.getLoader().addListener(PluginLoader.Hook.IGNITE, listener, this, PluginListener.Priority.HIGH);
         etc.getLoader().addListener(PluginLoader.Hook.DAMAGE, listener, this, PluginListener.Priority.MEDIUM);
         etc.getLoader().addListener(PluginLoader.Hook.DAMAGE, listener, this, PluginListener.Priority.MEDIUM);
         etc.getLoader().addListener(PluginLoader.Hook.EXPLODE, listener, this, PluginListener.Priority.HIGH);
         etc.getLoader().addListener(PluginLoader.Hook.EXPLODE, listener, this, PluginListener.Priority.HIGH);
-        if(etc.getInstance().isHealthEnabled()){
-        	etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM);
+        etc.getLoader().addListener(PluginLoader.Hook.HEALTH_CHANGE, listener, this, PluginListener.Priority.MEDIUM);
         }
         }
     }
     }
-}
+

+ 16 - 2
vMinecraftChat.java

@@ -361,6 +361,20 @@ public class vMinecraftChat {
 		}
 		}
 		return false;
 		return false;
 	}
 	}
+        //=====================================================================
+	//Function:	emote
+	//Input:	Player player: The player talking
+        //          	String message: The message to apply the effect to
+	//Output:	boolean: If this feature is enabled
+	//Use:		/me but with our custom colors applied
+	//=====================================================================
+        public static boolean emote(Player player, String[] message)
+        {
+            String[] msg = wordWrap("* " + getName(player) + Colors.White + message);
+            for(String str: msg)
+				gmsg(str);
+            return true;
+        }
 
 
     
     
     //=====================================================================
     //=====================================================================
@@ -385,7 +399,7 @@ public class vMinecraftChat {
 				//Loop through looking for a color code
 				//Loop through looking for a color code
 				for(int x = 0; x< msg.length(); x++)
 				for(int x = 0; x< msg.length(); x++)
 				{
 				{
-					//If the char is a ^ or §
+					//If the char is a ^ or �
 					if(msg.charAt(x) == '^' || msg.charAt(x) == Colors.White.charAt(0))
 					if(msg.charAt(x) == '^' || msg.charAt(x) == Colors.White.charAt(0))
 					{
 					{
 						if(x != msg.length() - 1)
 						if(x != msg.length() - 1)
@@ -451,7 +465,7 @@ public class vMinecraftChat {
 			//Loop through looking for a color code
 			//Loop through looking for a color code
 			for(int x = 0; x< message.length(); x++)
 			for(int x = 0; x< message.length(); x++)
 			{
 			{
-				//If the char is a ^ or '§'
+				//If the char is a ^ or '�'
 				if(message.charAt(x) == '^' || message.charAt(x) == Colors.White.charAt(0))
 				if(message.charAt(x) == '^' || message.charAt(x) == Colors.White.charAt(0))
 				{
 				{
 					if(x != message.length() - 1)
 					if(x != message.length() - 1)

+ 13 - 2
vMinecraftCommands.java

@@ -42,9 +42,21 @@ public class vMinecraftCommands{
         cl.register("/suicide", "suicide", "kill yourself... you loser");
         cl.register("/suicide", "suicide", "kill yourself... you loser");
         cl.register("/a", "adminChatToggle", "toggle admin chat for every message");
         cl.register("/a", "adminChatToggle", "toggle admin chat for every message");
         cl.register("/modify", "modifySplit");
         cl.register("/modify", "modifySplit");
+        cl.register("/me", "me");
         cl.registerAlias("/playerlist", "/who");
         cl.registerAlias("/playerlist", "/who");
         cl.registerAlias("/suicide", "/wrists");
         cl.registerAlias("/suicide", "/wrists");
         cl.registerAlias("/clearinventory", "/ci");
         cl.registerAlias("/clearinventory", "/ci");
+    }
+    	//=====================================================================
+	//Function:	me (/me)
+	//Input:	Player player: The player using the command
+	//Output:	int: Exit Code
+	//Use:		The player uses this to emote, but now its colorful.
+	//=====================================================================
+    public static int me(Player player, String[] args)
+    {
+        vMinecraftChat.emote(player, args);
+        return EXIT_SUCCESS;
     }
     }
 	//=====================================================================
 	//=====================================================================
 	//Function:	adminChatToggle (/a)
 	//Function:	adminChatToggle (/a)
@@ -53,8 +65,7 @@ public class vMinecraftCommands{
 	//Use:		Toggles the player into admin chat. Every message they
 	//Use:		Toggles the player into admin chat. Every message they
         //              send will be piped to admin chat.
         //              send will be piped to admin chat.
 	//=====================================================================
 	//=====================================================================
-
-    public static int adminChatToggle(Player player)
+    public static int adminChatToggle(Player player, String[] args)
 {
 {
     if(vMinecraftSettings.getInstance().adminChatToggle())
     if(vMinecraftSettings.getInstance().adminChatToggle())
     {
     {