From 38a6caae711050a026668d31bbdf622f638a4309 Mon Sep 17 00:00:00 2001 From: cerevisiae Date: Mon, 29 Nov 2010 21:00:03 -0600 Subject: [PATCH] Fixed the functions that call wordWrap so they should no longer output the username multiple times. --- vminecraftChat.java | 41 +++++++++++++++-------------------------- vminecraftCommands.java | 31 +++++++++++++++++++------------ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/vminecraftChat.java b/vminecraftChat.java index ab429e889..dddbbd7e9 100644 --- a/vminecraftChat.java +++ b/vminecraftChat.java @@ -272,21 +272,17 @@ public class vminecraftChat { public static boolean quote(Player player, String message) { //Format the name - String playerName = "<" + nameColor(player) + Colors.White +"> "; + String playerName = Colors.White + "<" + nameColor(player) + + Colors.White + "> "; if(vminecraftSettings.getInstance().greentext()) { //Log the chat - log.log(Level.INFO, "<"+player.getName()+"> "+message); + log.log(Level.INFO, "<"+player.getName()+"> " +message); //Get the multi line array - String[] msg = wordWrap(playerName + message); + String[] msg = wordWrap(playerName + Colors.LightGreen + message); - //Output the first line - gmsg( playerName + Colors.LightGreen + msg[0]); - - //Get the rest of the lines and display them. - String[] tempOut = new String[msg.length - 1]; - System.arraycopy(msg, 1, tempOut, 0, tempOut.length); - for(String str: tempOut) + //Output the lines + for(String str: msg) gmsg(Colors.LightGreen + str); return true; } @@ -303,20 +299,16 @@ public class vminecraftChat { public static boolean rage(Player player, String message) { //Format the name - String playerName = "<" + nameColor(player) + Colors.White +"> "; + String playerName = Colors.White + "<" + + nameColor(player) + Colors.White +"> "; if (vminecraftSettings.getInstance().FFF()) { log.log(Level.INFO, "<"+player.getName()+"> "+message); //Get the multi line array - String[] msg = wordWrap(playerName + message); + String[] msg = wordWrap(playerName + Colors.Red + message); - //Output the first line - gmsg( playerName + Colors.Red + msg[0]); - - //Get the rest of the lines and display them. - String[] tempOut = new String[msg.length - 1]; - System.arraycopy(msg, 1, tempOut, 0, tempOut.length); - for(String str: tempOut) + //Output the message + for(String str: msg) gmsg(Colors.Red + str); return true; } @@ -333,7 +325,8 @@ public class vminecraftChat { public static boolean quakeColors(Player player, String message) { //Format the name - String playerName = "<" + nameColor(player) + Colors.White +"> "; + String playerName = Colors.White + "<" + + nameColor(player) + Colors.White +"> "; if(vminecraftSettings.getInstance().quakeColors() && message.length()>2) { //Log the chat @@ -344,12 +337,8 @@ public class vminecraftChat { //Apply colors to the lines applyColors(msg); - //Output the first line - gmsg( playerName + msg[0]); - //Get the rest of the lines and display them. - String[] tempOut = new String[msg.length - 1]; - System.arraycopy(msg, 1, tempOut, 0, tempOut.length); - for(String str: tempOut) + //Output the message + for(String str: msg) gmsg(str); //Loop through the string finding the color codes and inserting them diff --git a/vminecraftCommands.java b/vminecraftCommands.java index 8d9ef4792..617cf5836 100644 --- a/vminecraftCommands.java +++ b/vminecraftCommands.java @@ -203,26 +203,33 @@ public class vminecraftCommands{ { //If the command is enabled if(vminecraftSettings.getInstance().cmdFabulous()) { - String playerName = "<" + vminecraftChat.nameColor(player) - + Colors.White + "> "; + + //Format the name + String playerName = Colors.White + "<" + + nameColor(player) + Colors.White +"> "; //Make sure a message has been specified if (args.length < 1) {return false;} String str = " "; + //Merge the message again - str = etc.combineSplit(0, args, " "); + str = etc.combineSplit(0, args, " "); + //Output for server log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\""); - //Prepend the player name + + //Prepend the player name and cut into lines. String[] message = vminecraftChat.wordWrap(playerName + str); - //Output the first line - vminecraftChat.gmsg( playerName + vminecraftChat.rainbow(message[0])); - - //Get the rest of the lines and display them. - String[] tempOut = new String[message.length - 1]; - System.arraycopy(message, 1, tempOut, 0, tempOut.length); - for(String msg: tempOut) - vminecraftChat.gmsg(vminecraftChat.rainbow(msg)); + //Output the message + for(String msg: message) + { + if (msg.contains(playerName)) + vminecraftChat.gmsg( + vminecraftChat.rainbow( + msg.substring(playerName.length() - 1))); + else + vminecraftChat.gmsg(msg); + } return true; }