Fixed the functions that call wordWrap so they should no longer output the username multiple times.

This commit is contained in:
cerevisiae 2010-11-29 21:00:03 -06:00
parent 11dc691220
commit 38a6caae71
2 changed files with 34 additions and 38 deletions

View File

@ -272,21 +272,17 @@ public class vminecraftChat {
public static boolean quote(Player player, String message) public static boolean quote(Player player, String message)
{ {
//Format the name //Format the name
String playerName = "<" + nameColor(player) + Colors.White +"> "; String playerName = Colors.White + "<" + nameColor(player)
+ Colors.White + "> ";
if(vminecraftSettings.getInstance().greentext()) { if(vminecraftSettings.getInstance().greentext()) {
//Log the chat //Log the chat
log.log(Level.INFO, "<"+player.getName()+"> "+message); log.log(Level.INFO, "<"+player.getName()+"> " +message);
//Get the multi line array //Get the multi line array
String[] msg = wordWrap(playerName + message); String[] msg = wordWrap(playerName + Colors.LightGreen + message);
//Output the first line //Output the lines
gmsg( playerName + Colors.LightGreen + msg[0]); for(String str: msg)
//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)
gmsg(Colors.LightGreen + str); gmsg(Colors.LightGreen + str);
return true; return true;
} }
@ -303,20 +299,16 @@ public class vminecraftChat {
public static boolean rage(Player player, String message) public static boolean rage(Player player, String message)
{ {
//Format the name //Format the name
String playerName = "<" + nameColor(player) + Colors.White +"> "; String playerName = Colors.White + "<"
+ nameColor(player) + Colors.White +"> ";
if (vminecraftSettings.getInstance().FFF()) { if (vminecraftSettings.getInstance().FFF()) {
log.log(Level.INFO, "<"+player.getName()+"> "+message); log.log(Level.INFO, "<"+player.getName()+"> "+message);
//Get the multi line array //Get the multi line array
String[] msg = wordWrap(playerName + message); String[] msg = wordWrap(playerName + Colors.Red + message);
//Output the first line //Output the message
gmsg( playerName + Colors.Red + msg[0]); for(String str: msg)
//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)
gmsg(Colors.Red + str); gmsg(Colors.Red + str);
return true; return true;
} }
@ -333,7 +325,8 @@ public class vminecraftChat {
public static boolean quakeColors(Player player, String message) public static boolean quakeColors(Player player, String message)
{ {
//Format the name //Format the name
String playerName = "<" + nameColor(player) + Colors.White +"> "; String playerName = Colors.White + "<"
+ nameColor(player) + Colors.White +"> ";
if(vminecraftSettings.getInstance().quakeColors() && message.length()>2) { if(vminecraftSettings.getInstance().quakeColors() && message.length()>2) {
//Log the chat //Log the chat
@ -344,12 +337,8 @@ public class vminecraftChat {
//Apply colors to the lines //Apply colors to the lines
applyColors(msg); applyColors(msg);
//Output the first line //Output the message
gmsg( playerName + msg[0]); for(String str: msg)
//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)
gmsg(str); gmsg(str);
//Loop through the string finding the color codes and inserting them //Loop through the string finding the color codes and inserting them

View File

@ -203,26 +203,33 @@ public class vminecraftCommands{
{ {
//If the command is enabled //If the command is enabled
if(vminecraftSettings.getInstance().cmdFabulous()) { 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 //Make sure a message has been specified
if (args.length < 1) {return false;} if (args.length < 1) {return false;}
String str = " "; String str = " ";
//Merge the message again //Merge the message again
str = etc.combineSplit(0, args, " "); str = etc.combineSplit(0, args, " ");
//Output for server //Output for server
log.log(Level.INFO, player.getName()+" fabulously said \""+ str+"\""); 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); String[] message = vminecraftChat.wordWrap(playerName + str);
//Output the first line //Output the message
vminecraftChat.gmsg( playerName + vminecraftChat.rainbow(message[0])); for(String msg: message)
{
//Get the rest of the lines and display them. if (msg.contains(playerName))
String[] tempOut = new String[message.length - 1]; vminecraftChat.gmsg(
System.arraycopy(message, 1, tempOut, 0, tempOut.length); vminecraftChat.rainbow(
for(String msg: tempOut) msg.substring(playerName.length() - 1)));
vminecraftChat.gmsg(vminecraftChat.rainbow(msg)); else
vminecraftChat.gmsg(msg);
}
return true; return true;
} }