Browse Source

Added xmas style coloring, use ^x to color things as such

nossr50 14 years ago
parent
commit
0e043afddb
1 changed files with 66 additions and 0 deletions
  1. 66 0
      vMinecraftChat.java

+ 66 - 0
vMinecraftChat.java

@@ -24,6 +24,14 @@ public class vMinecraftChat {
 			Colors.DarkPurple, 
 			Colors.DarkPurple, 
 			Colors.Purple,
 			Colors.Purple,
 			Colors.LightPurple};
 			Colors.LightPurple};
+        protected static final String[] xmas = new String[] {
+            Colors.Red,
+            Colors.Red,
+            Colors.White,
+            Colors.White,
+            Colors.Green,
+            Colors.Green,
+        };
 
 
 	//=====================================================================
 	//=====================================================================
 	//Function:	gmsg
 	//Function:	gmsg
@@ -252,6 +260,25 @@ public class vMinecraftChat {
 			if(counter==rainbow.length) counter = 0;
 			if(counter==rainbow.length) counter = 0;
 		}
 		}
 		return temp;
 		return temp;
+    }
+    //=====================================================================
+	//Function:	xmas
+	//Input:	String msg: The string to colorify
+	//Output:	String: The xmas colored result
+	//Use:		Makes a string more festive
+	//=====================================================================
+    public static String xmas(String msg){
+    	String temp = "";
+		int counter=0;
+		//Loop through the message applying the colors
+		for(int x=0; x<msg.length(); x++)
+		{
+			temp += xmas[counter]+msg.charAt(x);
+			
+			if(msg.charAt(x)!=' ') counter++;
+			if(counter==xmas.length) counter = 0;
+		}
+		return temp;
     }
     }
 	//=====================================================================
 	//=====================================================================
 	//Function:	getName
 	//Function:	getName
@@ -369,6 +396,12 @@ public class vMinecraftChat {
 			case 'r':
 			case 'r':
 				color = "^r";
 				color = "^r";
 				break;
 				break;
+                        case 'x':
+                            color = "^x";
+                            break;
+                        case 'X':
+                            color = "^x";
+                            break;
 			default:
 			default:
 				color = null;
 				color = null;
 				break;
 				break;
@@ -564,6 +597,38 @@ public class vMinecraftChat {
 										x++;
 										x++;
 									}
 									}
 									
 									
+									//If it reached another color instead of the end
+									if(x < msg.length() && msg.charAt(x) == '^'
+											|| x < msg.length()
+											&&  msg.charAt(x) == Colors.Red.charAt(0) )
+									{
+										taste = false;
+										i = 0;
+										x--;
+									}
+								}
+                                                              if(taste || recentColor.equals("^x"))
+								{
+									//Skip the quake code for xmas
+									if(recentColor.equals("^x"))
+									{
+										x += 2;
+									}
+									
+									//Taste keeps it going with xmas 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 += xmas[i] + msg.charAt(x);
+										
+										if(msg.charAt(x) != ' ') i++;
+										if(i == xmas.length) i = 0;
+										x++;
+									}
+									
 									//If it reached another color instead of the end
 									//If it reached another color instead of the end
 									if(x < msg.length() && msg.charAt(x) == '^'
 									if(x < msg.length() && msg.charAt(x) == '^'
 											|| x < msg.length()
 											|| x < msg.length()
@@ -575,6 +640,7 @@ public class vMinecraftChat {
 									}
 									}
 								}
 								}
 								else
 								else
+                                                                
 								{
 								{
 									//Add the color
 									//Add the color
 									temp += recentColor;
 									temp += recentColor;