2010-12-01 05:47:24 +01:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Class: vMinecraftChat
|
|
|
|
|
//Use: Encapsulates all chat commands added by this mod
|
|
|
|
|
//Author: nossr50, TrapAlice, cerevisiae
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public class vMinecraftChat {
|
|
|
|
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
2010-12-07 22:05:54 +01:00
|
|
|
|
protected static final int lineLength = 312;
|
2010-12-10 09:25:59 +01:00
|
|
|
|
//The array of colors to use
|
|
|
|
|
protected static final String[] rainbow = new String[] {
|
|
|
|
|
Colors.Red,
|
|
|
|
|
Colors.Rose,
|
|
|
|
|
Colors.Gold,
|
|
|
|
|
Colors.Yellow,
|
|
|
|
|
Colors.LightGreen,
|
|
|
|
|
Colors.Green,
|
|
|
|
|
Colors.LightBlue,
|
|
|
|
|
Colors.Blue,
|
|
|
|
|
Colors.Navy,
|
|
|
|
|
Colors.DarkPurple,
|
|
|
|
|
Colors.Purple,
|
|
|
|
|
Colors.LightPurple};
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: gmsg
|
2010-12-13 23:25:57 +01:00
|
|
|
|
//Input: Player sender: The player sending the message
|
|
|
|
|
// String msg: The message to be broadcast to all players
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Output: None
|
|
|
|
|
//Use: Outputs a message to everybody
|
|
|
|
|
//=====================================================================
|
2010-12-02 04:25:45 +01:00
|
|
|
|
public static void gmsg(Player sender, String msg){
|
2010-12-13 23:25:57 +01:00
|
|
|
|
if(sender != null && sender.isMuted())
|
2010-12-10 09:25:59 +01:00
|
|
|
|
sender.sendMessage(Colors.Red + "You have been muted.");
|
|
|
|
|
|
2010-12-02 04:25:45 +01:00
|
|
|
|
for (Player receiver : etc.getServer().getPlayerList()) {
|
2010-12-10 02:18:35 +01:00
|
|
|
|
|
|
|
|
|
if (receiver == null) {return;}
|
|
|
|
|
|
|
|
|
|
if(vMinecraftUsers.getProfile(receiver) == null)
|
|
|
|
|
return;
|
|
|
|
|
//Check if the person has the sender ignored
|
|
|
|
|
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
|
|
|
|
|
{
|
|
|
|
|
String[] message = applyColors(wordWrap(msg));
|
|
|
|
|
for(String out : message)
|
|
|
|
|
receiver.sendMessage(out);
|
|
|
|
|
}
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 19:36:42 +01:00
|
|
|
|
//=====================================================================
|
2010-12-13 23:25:57 +01:00
|
|
|
|
//Function: gmsg
|
2010-12-01 19:36:42 +01:00
|
|
|
|
//Input: String msg: The message to be broadcast to all players
|
|
|
|
|
//Output: None
|
|
|
|
|
//Use: Outputs a message to everybody
|
|
|
|
|
//=====================================================================
|
2010-12-13 23:25:57 +01:00
|
|
|
|
public static void gmsg(String msg){gmsg(null, msg);}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: sendMessage
|
|
|
|
|
//Input: Player sender: The player sending the message
|
|
|
|
|
// Player receiver: The player receiving the message
|
|
|
|
|
// String msg: The message to be broadcast to all players
|
|
|
|
|
//Output: None
|
|
|
|
|
//Use: Outputs a message to everybody
|
|
|
|
|
//=====================================================================
|
2010-12-02 04:25:45 +01:00
|
|
|
|
public static void sendMessage(Player sender, Player receiver, String msg){
|
2010-12-13 23:25:57 +01:00
|
|
|
|
if(sender != null && sender.isMuted())
|
2010-12-10 09:25:59 +01:00
|
|
|
|
sender.sendMessage(Colors.Red + "You have been muted.");
|
|
|
|
|
|
2010-12-08 20:29:13 +01:00
|
|
|
|
//Check if the receiver has the sender ignored
|
2010-12-10 02:18:35 +01:00
|
|
|
|
if(vMinecraftUsers.getProfile(receiver) == null)
|
2010-12-08 20:29:13 +01:00
|
|
|
|
return;
|
2010-12-10 02:18:35 +01:00
|
|
|
|
if(!vMinecraftUsers.getProfile(receiver).isIgnored(sender))
|
2010-12-08 20:29:13 +01:00
|
|
|
|
{
|
|
|
|
|
String[] message = applyColors(wordWrap(msg));
|
|
|
|
|
for(String out : message)
|
|
|
|
|
receiver.sendMessage(out);
|
|
|
|
|
//Tell them if they are
|
|
|
|
|
} else
|
2010-12-10 02:18:35 +01:00
|
|
|
|
sendMessage(sender, sender, Colors.Rose + receiver.getName()
|
|
|
|
|
+ " has you on their ignore list.");
|
2010-12-01 19:36:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-13 23:25:57 +01:00
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: sendMessage
|
|
|
|
|
//Input: Player receiver: The player receiving the message
|
|
|
|
|
// String msg: The message to be broadcast to all players
|
|
|
|
|
//Output: None
|
|
|
|
|
//Use: Outputs a message to everybody
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static void sendMessage(Player receiver, String msg)
|
|
|
|
|
{
|
|
|
|
|
sendMessage(null, receiver, msg);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: wordWrap
|
|
|
|
|
//Input: String msg: The message to be wrapped
|
|
|
|
|
//Output: String[]: The array of substrings
|
|
|
|
|
//Use: Cuts the message apart into whole words short enough to fit
|
|
|
|
|
// on one line
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static String[] wordWrap(String msg){
|
|
|
|
|
//Split each word apart
|
2010-12-02 04:25:45 +01:00
|
|
|
|
ArrayList<String> split = new ArrayList<String>();
|
|
|
|
|
for(String in : msg.split(" "))
|
2010-12-09 01:30:26 +01:00
|
|
|
|
split.add(in);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Create an arraylist for the output
|
|
|
|
|
ArrayList<String> out = new ArrayList<String>();
|
|
|
|
|
//While i is less than the length of the array of words
|
2010-12-02 04:25:45 +01:00
|
|
|
|
while(!split.isEmpty()){
|
2010-12-01 05:47:24 +01:00
|
|
|
|
int len = 0;
|
2010-12-02 04:25:45 +01:00
|
|
|
|
|
|
|
|
|
//Create an arraylist to hold individual words
|
|
|
|
|
ArrayList<String> words = new ArrayList<String>();
|
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Loop through the words finding their length and increasing
|
|
|
|
|
//j, the end point for the sub string
|
2010-12-08 05:18:54 +01:00
|
|
|
|
while(!split.isEmpty() && split.get(0) != null && len <= lineLength)
|
2010-12-01 05:47:24 +01:00
|
|
|
|
{
|
2010-12-02 04:25:45 +01:00
|
|
|
|
int wordLength = msgLength(split.get(0)) + 4;
|
|
|
|
|
|
|
|
|
|
//If a word is too long for a line
|
2010-12-07 22:05:54 +01:00
|
|
|
|
if(wordLength > lineLength)
|
2010-12-02 04:25:45 +01:00
|
|
|
|
{
|
|
|
|
|
String[] tempArray = wordCut(len, split.remove(0));
|
2010-12-09 01:30:26 +01:00
|
|
|
|
words.add(tempArray[0]);
|
2010-12-02 04:25:45 +01:00
|
|
|
|
split.add(tempArray[1]);
|
|
|
|
|
}
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
2010-12-02 04:25:45 +01:00
|
|
|
|
//If the word is not too long to fit
|
|
|
|
|
len += wordLength;
|
2010-12-07 22:05:54 +01:00
|
|
|
|
if( len < lineLength)
|
2010-12-02 04:25:45 +01:00
|
|
|
|
words.add(split.remove(0));
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
2010-12-01 18:44:32 +01:00
|
|
|
|
//Merge them and add them to the output array.
|
2010-12-02 04:25:45 +01:00
|
|
|
|
out.add( etc.combineSplit(0,
|
2010-12-09 01:30:26 +01:00
|
|
|
|
words.toArray(new String[words.size()]), " ") + " " );
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
//Convert to an array and return
|
2010-12-02 04:25:45 +01:00
|
|
|
|
return out.toArray(new String[out.size()]);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: msgLength
|
|
|
|
|
//Input: String str: The string to find the length of
|
|
|
|
|
//Output: int: The length on the screen of a string
|
|
|
|
|
//Use: Finds the length on the screen of a string. Ignores colors.
|
|
|
|
|
//=====================================================================
|
2010-12-10 06:02:53 +01:00
|
|
|
|
public static int msgLength(String str){
|
2010-12-01 05:47:24 +01:00
|
|
|
|
int length = 0;
|
|
|
|
|
//Loop through all the characters, skipping any color characters
|
|
|
|
|
//and their following color codes
|
|
|
|
|
for(int x = 0; x<str.length(); x++)
|
|
|
|
|
{
|
2010-12-10 09:25:59 +01:00
|
|
|
|
if(str.charAt(x) == '^' || str.charAt(x) == Colors.White.charAt(0))
|
|
|
|
|
{
|
|
|
|
|
if(colorChange(str.charAt(x + 1)) != null)
|
|
|
|
|
{
|
|
|
|
|
x++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 04:25:45 +01:00
|
|
|
|
int len = charLength(str.charAt(x));
|
2010-12-10 09:25:59 +01:00
|
|
|
|
length += len;
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
return length;
|
|
|
|
|
}
|
2010-12-02 04:25:45 +01:00
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: wordCut
|
|
|
|
|
//Input: String str: The string to find the length of
|
|
|
|
|
//Output: String[]: The cut up word
|
|
|
|
|
//Use: Cuts apart a word that is too long to fit on one line
|
|
|
|
|
//=====================================================================
|
|
|
|
|
private static String[] wordCut(int lengthBefore, String str){
|
|
|
|
|
int length = lengthBefore;
|
|
|
|
|
//Loop through all the characters, skipping any color characters
|
|
|
|
|
//and their following color codes
|
|
|
|
|
String[] output = new String[2];
|
|
|
|
|
int x = 0;
|
2010-12-07 22:05:54 +01:00
|
|
|
|
while(length < lineLength && x < str.length())
|
2010-12-02 04:25:45 +01:00
|
|
|
|
{
|
|
|
|
|
int len = charLength(str.charAt(x));
|
|
|
|
|
if( len > 0)
|
|
|
|
|
length += len;
|
2010-12-09 01:30:26 +01:00
|
|
|
|
else
|
|
|
|
|
x++;
|
2010-12-02 04:25:45 +01:00
|
|
|
|
x++;
|
|
|
|
|
}
|
2010-12-09 01:30:26 +01:00
|
|
|
|
if(x > str.length())
|
|
|
|
|
x = str.length();
|
2010-12-02 04:25:45 +01:00
|
|
|
|
//Add the substring to the output after cutting it
|
|
|
|
|
output[0] = str.substring(0, x);
|
|
|
|
|
//Add the last of the string to the output.
|
|
|
|
|
output[1] = str.substring(x);
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-02 04:29:50 +01:00
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: charLength
|
|
|
|
|
//Input: char x: The character to find the length of.
|
|
|
|
|
//Output: int: The length of the character
|
|
|
|
|
//Use: Finds the visual length of the character on the screen.
|
|
|
|
|
//=====================================================================
|
2010-12-02 04:25:45 +01:00
|
|
|
|
private static int charLength(char x)
|
|
|
|
|
{
|
2010-12-07 22:05:54 +01:00
|
|
|
|
if("i.:,;|!".indexOf(x) != -1)
|
2010-12-02 04:25:45 +01:00
|
|
|
|
return 2;
|
|
|
|
|
else if("l'".indexOf(x) != -1)
|
|
|
|
|
return 3;
|
|
|
|
|
else if("tI[]".indexOf(x) != -1)
|
|
|
|
|
return 4;
|
2010-12-07 22:05:54 +01:00
|
|
|
|
else if("fk{}<>\"*()".indexOf(x) != -1)
|
2010-12-02 04:25:45 +01:00
|
|
|
|
return 5;
|
2010-12-09 01:30:26 +01:00
|
|
|
|
else if("abcdeghjmnopqrsuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890\\/#?$%-=_+&^".indexOf(x) != -1)
|
2010-12-02 04:25:45 +01:00
|
|
|
|
return 6;
|
|
|
|
|
else if("@~".indexOf(x) != -1)
|
|
|
|
|
return 7;
|
|
|
|
|
else if(x==' ')
|
|
|
|
|
return 4;
|
|
|
|
|
else
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: rainbow
|
|
|
|
|
//Input: String msg: The string to colorify
|
|
|
|
|
//Output: String: The rainbowed result
|
|
|
|
|
//Use: Rainbowifies a string;
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static String rainbow(String msg){
|
|
|
|
|
String temp = "";
|
|
|
|
|
int counter=0;
|
|
|
|
|
//Loop through the message applying the colors
|
|
|
|
|
for(int x=0; x<msg.length(); x++)
|
|
|
|
|
{
|
2010-12-10 09:25:59 +01:00
|
|
|
|
temp += rainbow[counter]+msg.charAt(x);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
if(msg.charAt(x)!=' ') counter++;
|
|
|
|
|
if(counter==rainbow.length) counter = 0;
|
|
|
|
|
}
|
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: getName
|
|
|
|
|
//Input: Player player: The player to get name as color
|
|
|
|
|
//Output: String: The name colored
|
|
|
|
|
//Use: Returns the colored name;
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static String getName(Player player){
|
|
|
|
|
|
2010-12-10 03:09:42 +01:00
|
|
|
|
//Add the nickname or the name if there is none
|
|
|
|
|
String output = vMinecraftUsers.getProfile(player).getNick();
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
2010-12-10 03:09:42 +01:00
|
|
|
|
if(output.isEmpty())
|
|
|
|
|
output = player.getName();
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Add the color if there is one
|
|
|
|
|
if(player.getColor() != null && player.getColor() != "")
|
|
|
|
|
output = player.getColor().substring(0,2) + output;
|
2010-12-10 03:09:42 +01:00
|
|
|
|
|
2010-12-10 02:18:35 +01:00
|
|
|
|
//Add the tag if there is one
|
2010-12-10 03:09:42 +01:00
|
|
|
|
output = vMinecraftUsers.getProfile(player).getTag() + output;
|
|
|
|
|
|
|
|
|
|
//Add the suffix if there is one
|
|
|
|
|
output += vMinecraftUsers.getProfile(player).getSuffix();
|
|
|
|
|
|
2010-12-10 19:36:01 +01:00
|
|
|
|
output = Colors.White + output;
|
|
|
|
|
|
2010-12-10 03:09:42 +01:00
|
|
|
|
/*if(playerPrefix != null && !playerPrefix.isEmpty())
|
|
|
|
|
output = applyColors(playerPrefix.substring(1)) + output;*/
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Return the name
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: colorChange
|
|
|
|
|
//Input: char colour: The color code to find the color for
|
|
|
|
|
//Output: String: The color that the code identified
|
|
|
|
|
//Use: Finds a color giving a color code
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static String colorChange(char colour)
|
|
|
|
|
{
|
|
|
|
|
String color = "";
|
|
|
|
|
switch(colour)
|
|
|
|
|
{
|
|
|
|
|
case '0':
|
|
|
|
|
color = Colors.Black;
|
|
|
|
|
break;
|
|
|
|
|
case '1':
|
|
|
|
|
color = Colors.Navy;
|
|
|
|
|
break;
|
|
|
|
|
case '2':
|
|
|
|
|
color = Colors.Green;
|
|
|
|
|
break;
|
|
|
|
|
case '3':
|
|
|
|
|
color = Colors.Blue;
|
|
|
|
|
break;
|
|
|
|
|
case '4':
|
|
|
|
|
color = Colors.Red;
|
|
|
|
|
break;
|
|
|
|
|
case '5':
|
|
|
|
|
color = Colors.Purple;
|
|
|
|
|
break;
|
|
|
|
|
case '6':
|
|
|
|
|
color = Colors.Gold;
|
|
|
|
|
break;
|
|
|
|
|
case '7':
|
|
|
|
|
color = Colors.LightGray;
|
|
|
|
|
break;
|
|
|
|
|
case '8':
|
|
|
|
|
color = Colors.Gray;
|
|
|
|
|
break;
|
|
|
|
|
case '9':
|
|
|
|
|
color = Colors.DarkPurple;
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
color = Colors.LightGreen;
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
color = Colors.LightBlue;
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
color = Colors.Rose;
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
color = Colors.LightPurple;
|
|
|
|
|
break;
|
|
|
|
|
case 'e':
|
|
|
|
|
color = Colors.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 'f':
|
|
|
|
|
color = Colors.White;
|
|
|
|
|
break;
|
|
|
|
|
case 'A':
|
|
|
|
|
color = Colors.LightGreen;
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
color = Colors.LightBlue;
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
color = Colors.Rose;
|
|
|
|
|
break;
|
|
|
|
|
case 'D':
|
|
|
|
|
color = Colors.LightPurple;
|
|
|
|
|
break;
|
|
|
|
|
case 'E':
|
|
|
|
|
color = Colors.Yellow;
|
|
|
|
|
break;
|
|
|
|
|
case 'F':
|
|
|
|
|
color = Colors.White;
|
|
|
|
|
break;
|
2010-12-02 21:45:24 +01:00
|
|
|
|
case 'R':
|
2010-12-12 22:01:17 +01:00
|
|
|
|
color = "^r";
|
2010-12-02 21:45:24 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'r':
|
2010-12-12 22:01:17 +01:00
|
|
|
|
color = "^r";
|
2010-12-02 21:45:24 +01:00
|
|
|
|
break;
|
2010-12-01 05:47:24 +01:00
|
|
|
|
default:
|
|
|
|
|
color = null;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: adminChat
|
|
|
|
|
//Input: Player player: The player talking
|
|
|
|
|
// String message: The message to apply the effect to
|
|
|
|
|
//Output: boolean: If this feature is enabled
|
|
|
|
|
//Use: Sends messages only to admins
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static boolean adminChat(Player player, String message){
|
|
|
|
|
|
|
|
|
|
//Check if the player can use this feature
|
|
|
|
|
if(player.isAdmin() || player.canUseCommand("/adminchat"))
|
|
|
|
|
{
|
|
|
|
|
//Special formatting for adminchat {Username}
|
|
|
|
|
String adminchat = Colors.DarkPurple + "{" + getName(player)
|
2010-12-08 10:47:42 +01:00
|
|
|
|
+ Colors.DarkPurple +"} ";
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
2010-12-01 07:56:52 +01:00
|
|
|
|
//Cut off the @ prefix
|
|
|
|
|
if(message.startsWith("@"))
|
|
|
|
|
message = message.substring(1, message.length());
|
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Get the player from the playerlist to send the message to.
|
|
|
|
|
for (Player p: etc.getServer().getPlayerList()) {
|
|
|
|
|
|
|
|
|
|
//If p is not null
|
|
|
|
|
if (p != null) {
|
|
|
|
|
|
2010-12-01 19:36:42 +01:00
|
|
|
|
//And if p is an admin or has access to adminchat send message
|
2010-12-01 05:47:24 +01:00
|
|
|
|
if (p.isAdmin() || (p.canUseCommand("/adminchat"))) {
|
2010-12-02 04:25:45 +01:00
|
|
|
|
sendMessage(player, p, adminchat + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//So you can read adminchat from the server console
|
2010-12-12 22:01:17 +01:00
|
|
|
|
log.log(Level.INFO, "@" + "<" + player.getName() + "> " + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: quote
|
|
|
|
|
//Input: Player player: The player talking
|
|
|
|
|
// String message: The message to apply the effect to
|
|
|
|
|
//Output: boolean: If this feature is enabled
|
|
|
|
|
//Use: Displays a message as a quote
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static boolean quote(Player player, String message)
|
|
|
|
|
{
|
|
|
|
|
//Format the name
|
|
|
|
|
String playerName = Colors.White + "<" + getName(player)
|
|
|
|
|
+ Colors.White + "> ";
|
|
|
|
|
if(vMinecraftSettings.getInstance().greentext()) {
|
|
|
|
|
//Log the chat
|
2010-12-08 10:47:42 +01:00
|
|
|
|
log.log(Level.INFO, "<"+player.getName()+"> " + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
2010-12-01 19:36:42 +01:00
|
|
|
|
//Output the message
|
2010-12-02 04:25:45 +01:00
|
|
|
|
gmsg(player, playerName + Colors.LightGreen + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: rage
|
|
|
|
|
//Input: Player player: The player talking
|
|
|
|
|
// String message: The message to apply the effect to
|
|
|
|
|
//Output: boolean: If this feature is enabled
|
|
|
|
|
//Use: Displays a message in red
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static boolean rage(Player player, String message)
|
|
|
|
|
{
|
|
|
|
|
//Format the name
|
|
|
|
|
String playerName = Colors.White + "<"
|
|
|
|
|
+ getName(player) + Colors.White +"> ";
|
|
|
|
|
if (vMinecraftSettings.getInstance().FFF()) {
|
|
|
|
|
log.log(Level.INFO, "<"+player.getName()+"> "+message);
|
2010-12-01 19:36:42 +01:00
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Output the message
|
2010-12-02 04:25:45 +01:00
|
|
|
|
gmsg(player, playerName + Colors.Red + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: quakeColors
|
|
|
|
|
//Input: Player player: The player talking
|
|
|
|
|
// String message: The message to apply the effect to
|
|
|
|
|
//Output: boolean: If this feature is enabled
|
|
|
|
|
//Use: Displays a message in red
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static boolean quakeColors(Player player, String message)
|
|
|
|
|
{
|
|
|
|
|
//Format the name
|
|
|
|
|
String playerName = Colors.White + "<"
|
2010-12-01 19:36:42 +01:00
|
|
|
|
+ getName(player) + Colors.White +"> ";
|
2010-12-01 05:47:24 +01:00
|
|
|
|
if(vMinecraftSettings.getInstance().quakeColors()) {
|
|
|
|
|
|
2010-12-12 22:01:17 +01:00
|
|
|
|
String color = vMinecraftUsers.getProfile(player).getColor();
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Log the chat
|
2010-12-12 22:01:17 +01:00
|
|
|
|
log.log(Level.INFO, "<"+player.getName()+"> " + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Output the message
|
2010-12-12 22:01:17 +01:00
|
|
|
|
gmsg(player, playerName + color + message);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Loop through the string finding the color codes and inserting them
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-12-02 21:45:24 +01:00
|
|
|
|
|
|
|
|
|
//=====================================================================
|
2010-12-01 16:17:59 +01:00
|
|
|
|
//Function: emote
|
|
|
|
|
//Input: Player player: The player talking
|
2010-12-02 21:45:24 +01:00
|
|
|
|
// String message: The message to apply the effect to
|
2010-12-01 16:17:59 +01:00
|
|
|
|
//Output: boolean: If this feature is enabled
|
|
|
|
|
//Use: /me but with our custom colors applied
|
|
|
|
|
//=====================================================================
|
2010-12-10 10:15:39 +01:00
|
|
|
|
public static boolean emote(Player player, String message)
|
|
|
|
|
{
|
|
|
|
|
gmsg(player, "* " + getName(player) + " " + Colors.White + message);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
|
//Function: applyColors
|
|
|
|
|
//Input: String[] message: The lines to be colored
|
|
|
|
|
//Output: String[]: The lines, but colorful
|
|
|
|
|
//Use: Colors each line
|
|
|
|
|
//=====================================================================
|
|
|
|
|
public static String[] applyColors(String[] message)
|
|
|
|
|
{
|
2010-12-01 07:47:58 +01:00
|
|
|
|
if(message != null && message[0] != null && !message[0].isEmpty()){
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//The color to start the line with
|
|
|
|
|
String recentColor = Colors.White;
|
|
|
|
|
|
|
|
|
|
//Go through each line
|
|
|
|
|
int counter = 0;
|
2010-12-10 09:25:59 +01:00
|
|
|
|
int i = 0;
|
|
|
|
|
boolean taste = false;
|
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
for(String msg: message)
|
|
|
|
|
{
|
|
|
|
|
//Start the line with the most recent color
|
2010-12-10 09:44:37 +01:00
|
|
|
|
String temp = "";
|
2010-12-12 22:01:17 +01:00
|
|
|
|
if(!recentColor.equals("^r") && recentColor != null)
|
2010-12-10 09:44:37 +01:00
|
|
|
|
temp += recentColor;
|
2010-12-01 05:47:24 +01:00
|
|
|
|
|
|
|
|
|
//Loop through looking for a color code
|
|
|
|
|
for(int x = 0; x< msg.length(); x++)
|
|
|
|
|
{
|
2010-12-01 16:17:59 +01:00
|
|
|
|
//If the char is a ^ or <20>
|
2010-12-10 09:44:37 +01:00
|
|
|
|
if(taste || msg.charAt(x) == '^'
|
2010-12-10 10:15:39 +01:00
|
|
|
|
|| msg.charAt(x) == Colors.Red.charAt(0))
|
2010-12-01 05:47:24 +01:00
|
|
|
|
{
|
|
|
|
|
if(x != msg.length() - 1)
|
|
|
|
|
{
|
|
|
|
|
//If the following character is a color code
|
|
|
|
|
if(vMinecraftChat.colorChange(msg.charAt(x+1)) != null)
|
|
|
|
|
{
|
|
|
|
|
//Set the most recent color to the new color
|
|
|
|
|
recentColor = vMinecraftChat.colorChange(msg.charAt(x+1));
|
2010-12-10 09:25:59 +01:00
|
|
|
|
|
|
|
|
|
//If the color specified is rainbow
|
2010-12-12 22:01:17 +01:00
|
|
|
|
if(taste || recentColor.equals("^r"))
|
2010-12-10 09:25:59 +01:00
|
|
|
|
{
|
|
|
|
|
//Skip the quake code for rainbow
|
2010-12-12 22:01:17 +01:00
|
|
|
|
if(recentColor.equals("^r"))
|
2010-12-10 09:25:59 +01:00
|
|
|
|
{
|
|
|
|
|
x += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Taste keeps it going with rainbow if there
|
|
|
|
|
//are more lines
|
|
|
|
|
taste = true;
|
|
|
|
|
//Loop through the message applying the colors
|
|
|
|
|
while(x < msg.length() && msg.charAt(x) != '^'
|
|
|
|
|
&& msg.charAt(x) != Colors.Red.charAt(0))
|
|
|
|
|
{
|
|
|
|
|
temp += rainbow[i] + msg.charAt(x);
|
|
|
|
|
|
|
|
|
|
if(msg.charAt(x) != ' ') i++;
|
|
|
|
|
if(i == rainbow.length) i = 0;
|
|
|
|
|
x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If it reached another color instead of the end
|
|
|
|
|
if(x < msg.length() && msg.charAt(x) == '^'
|
2010-12-10 09:44:37 +01:00
|
|
|
|
|| x < msg.length()
|
|
|
|
|
&& msg.charAt(x) == Colors.Red.charAt(0) )
|
2010-12-10 09:25:59 +01:00
|
|
|
|
{
|
|
|
|
|
taste = false;
|
|
|
|
|
i = 0;
|
|
|
|
|
x--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Add the color
|
|
|
|
|
temp += recentColor;
|
|
|
|
|
//Skip these chars
|
|
|
|
|
x++;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 05:47:24 +01:00
|
|
|
|
//Otherwise ignore it.
|
|
|
|
|
} else {
|
|
|
|
|
temp += msg.charAt(x);
|
|
|
|
|
}
|
|
|
|
|
//Insert the character
|
2010-12-01 07:47:58 +01:00
|
|
|
|
} else {
|
|
|
|
|
temp += msg.charAt(x);
|
2010-12-01 05:47:24 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
temp += msg.charAt(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Replace the message with the colorful message
|
|
|
|
|
message[counter] = temp;
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return message;
|
|
|
|
|
}
|
2010-12-10 03:09:42 +01:00
|
|
|
|
}
|