cerevisiae пре 14 година
родитељ
комит
db8ac45ad5
3 измењених фајлова са 117 додато и 45 уклоњено
  1. 96 31
      vminecraftChat.java
  2. 10 4
      vminecraftCommands.java
  3. 11 10
      vminecraftSettings.java

+ 96 - 31
vminecraftChat.java

@@ -131,7 +131,7 @@ public class vminecraftChat {
     public static String getName(Player player){
     	
     	//Get the prefix
-    	String[] playerPrefix = new String[]{player.getPrefix()};
+    	String playerPrefix = player.getPrefix();
     	
     	//Add the name
     	String output = player.getName();
@@ -140,8 +140,8 @@ public class vminecraftChat {
     	if(player.getColor() != null && player.getColor() != "")
     		output = player.getColor().substring(0,2) + output;
     	//Add the prefix if there is one
-    	if(playerPrefix[0] != null && playerPrefix[0] != "")
-    		output = applyColors(playerPrefix)[0].substring(3) + output;
+    	if(playerPrefix != null && playerPrefix != "")
+    		output = applyColors(playerPrefix).substring(3) + output;
     	
     	//Return the name
         return output;
@@ -365,46 +365,111 @@ public class vminecraftChat {
 	//Output:	String[]: The lines, but colorful
 	//Use:		Colors each line
 	//=====================================================================
-	private static String[] applyColors(String[] message)
+	public static String[] applyColors(String[] message)
 	{
+		if(message != null && message[0] != null && !message[0].equals("")){
+			//The color to start the line with
+			String recentColor = Colors.White;
+			
+			//Go through each line
+			int counter = 0;
+			for(String msg: message)
+			{	
+				//Start the line with the most recent color
+				String temp = recentColor;
+				
+				//Loop through looking for a color code
+				for(int x = 0; x< msg.length(); x++)
+				{
+					//If the char is a ^ or §
+					if(msg.charAt(x) == '^' || msg.charAt(x) == '§')
+					{
+						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));
+								//Add the color
+								temp += recentColor;
+								//Skip these chars
+								x++;
+							//Otherwise ignore it.
+							} else {
+								temp += msg.charAt(x);
+							}
+						//Insert the character
+						}
+					} else {
+						temp += msg.charAt(x);
+					}
+				}
+				//Replace the message with the colorful message
+				message[counter] = temp;
+				counter++;
+			}
+		}
+		return message;
+	}
 
-		//The color to start the line with
-		String recentColor = Colors.White;
-		
-		//Go through each line
-		int counter = 0;
-		for(String msg: message)
-		{	
+	//=====================================================================
+	//Function:	applyColors
+	//Input:	String message: The line to be colored
+	//Output:	String: The line, but colorful
+	//Use:		Colors a line
+	//=====================================================================
+	public static String applyColors(String message)
+	{
+		return applyColors(message, Colors.White);
+	}
+
+	//=====================================================================
+	//Function:	applyColors
+	//Input:	String message: The line to be colored
+	//			String color: The color to start the line with
+	//Output:	String: The line, but colorful
+	//Use:		Colors a line
+	//=====================================================================
+	public static String applyColors(String message, String color)
+	{
+		if(message != null && !message.equals(""))
+		{
+			//The color to start the line with
+			if(color == null)
+				 color = Colors.White;
+			
 			//Start the line with the most recent color
-			String temp = recentColor;
+			String temp = color;
 			
 			//Loop through looking for a color code
-			for(int x = 0; x< msg.length(); x++)
+			for(int x = 0; x< message.length(); x++)
 			{
-				//If the char is a ^
-				if(msg.charAt(x)=='^' && x != msg.length() - 1)
+				//If the char is a ^ or §
+				if(message.charAt(x) == '^' || message.charAt(x) == '§')
 				{
-					//If the following character is a color code
-					if(vminecraftChat.colorChange(msg.charAt(x+1)) != null)
+					if(x != message.length() - 1)
 					{
-						//Set the most recent color to the new color
-						recentColor = vminecraftChat.colorChange(msg.charAt(x+1));
-						//Add the color
-						temp += recentColor;
-						//Skip these chars
-						x++;
-					//Otherwise ignore it.
+						//If the following character is a color code
+						if(vminecraftChat.colorChange(message.charAt(x+1)) != null)
+						{
+							//Set the most recent color to the new color
+							color = vminecraftChat.colorChange(message.charAt(x+1));
+							//Add the color
+							temp += color;
+							//Skip these chars
+							x++;
+						//Otherwise ignore it.
+						} else {
+							temp += message.charAt(x);
+						}
+					//Insert the character
 					} else {
-						temp += msg.charAt(x);
+						temp += message.charAt(x);
 					}
-				//Insert the character
-				} else {
-					temp += msg.charAt(x);
 				}
+	
 			}
-			//Replace the message with the colorful message
-			message[counter] = temp;
-			counter++;
 		}
 		return message;
 	}

+ 10 - 4
vminecraftCommands.java

@@ -237,11 +237,17 @@ public class vminecraftCommands{
 	{
 		//If the rules exist
 		if(vminecraftSettings.getInstance().cmdRules()
-				&& vminecraftSettings.getInstance().getRules().length != 0) {
+				&& vminecraftSettings.getInstance().getRules().length > 0) {
+			
+			//Apply QuakeCode Colors to the rules
+			String[] rules = vminecraftChat.applyColors(
+					vminecraftSettings.getInstance().getRules());
 			//Display them
-			for (String str : vminecraftSettings.getInstance().getRules()) {
-				if(str.isEmpty())
-					player.sendMessage(Colors.Blue+str);
+			for (String str : rules ) {
+				if(!str.isEmpty())
+					player.sendMessage(Colors.Blue + str);
+				else
+					player.sendMessage(Colors.Blue + "!!!The Rules Have Not Been Set!!!");
 			}
 			return EXIT_SUCCESS;
 		}

+ 11 - 10
vminecraftSettings.java

@@ -124,8 +124,8 @@ public class vminecraftSettings {
 			cmdTp = properties.getBoolean("cmdTp",true);
 			cmdMasstp = properties.getBoolean("cmdMasstp",true);
 			cmdTphere = properties.getBoolean("cmdTphere",true);
-                        cmdSuicide = properties.getBoolean("cmdSuicide", true);
-                        cmdHeal = properties.getBoolean("cmdHeal",true);
+			cmdSuicide = properties.getBoolean("cmdSuicide", true);
+			cmdHeal = properties.getBoolean("cmdHeal",true);
 			globalmessages = properties.getBoolean("globalmessages",true);
 			cmdSay = properties.getBoolean("cmdSay",true);
 			cmdEzModo = properties.getBoolean("cmdEzModo",true);
@@ -171,7 +171,6 @@ public class vminecraftSettings {
 	public boolean cmdRules() {return cmdRules;}
 	public boolean globalmessages() {return globalmessages;}
 	public boolean cmdMasstp() {return cmdMasstp;}
-	public boolean cmdEzModo() {return cmdEzModo;}
 	public boolean cmdWho() {return cmdWho;}
 	public boolean stopFire() {return stopFire;}
 	public boolean stopTnt() {return stopTnt;}
@@ -179,18 +178,20 @@ public class vminecraftSettings {
         public boolean cmdHeal() {return cmdHeal;}
 	
 	//EzModo methods
+    public boolean cmdEzModo() {return cmdEzModo;}
 	public boolean isEzModo(String playerName) {return ezModo.contains(playerName);}
 	public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));}
 	public void addEzModo(String playerName) {ezModo.add(playerName);}
 	public int ezModoHealth() {return ezHealth;}
 	public String ezModoList() {return ezModo.toString();}
-        //Random death message method
-        public static String randomDeathMsg() {
-            if (deathMessages == null) {
-                return "died";
-            }
-            return deathMessages[ (int) (Math.random() * deathMessages.length)];
-        }
+	
+    //Random death message method
+    public static String randomDeathMsg() {
+    	if (deathMessages == null) {
+    		return "died";
+    	}
+    	return deathMessages[ (int) (Math.random() * deathMessages.length)];
+	}
 	
 	//=====================================================================
 	//Function:	getInstance