From 91a9e1350b52b08cd6ee82138081ea4225848b25 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 1 Dec 2010 07:17:59 -0800 Subject: [PATCH] Added half-functional /me recode --- vMinecraft.java | 5 ++--- vMinecraftChat.java | 18 ++++++++++++++++-- vMinecraftCommands.java | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/vMinecraft.java b/vMinecraft.java index 654be29fd..fd7336dd7 100644 --- a/vMinecraft.java +++ b/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.DAMAGE, listener, this, PluginListener.Priority.MEDIUM); 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); } } -} + diff --git a/vMinecraftChat.java b/vMinecraftChat.java index 3f55bb844..6aa09c260 100644 --- a/vMinecraftChat.java +++ b/vMinecraftChat.java @@ -361,6 +361,20 @@ public class vMinecraftChat { } 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 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(x != msg.length() - 1) @@ -451,7 +465,7 @@ public class vMinecraftChat { //Loop through looking for a color code 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(x != message.length() - 1) diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index c4106df93..9f7ca15d0 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -42,9 +42,21 @@ public class vMinecraftCommands{ cl.register("/suicide", "suicide", "kill yourself... you loser"); cl.register("/a", "adminChatToggle", "toggle admin chat for every message"); cl.register("/modify", "modifySplit"); + cl.register("/me", "me"); cl.registerAlias("/playerlist", "/who"); cl.registerAlias("/suicide", "/wrists"); 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) @@ -53,8 +65,7 @@ public class vMinecraftCommands{ //Use: Toggles the player into admin chat. Every message they // 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()) {