Created
December 23, 2011 09:42
-
-
Save bartenbach/1513737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void rainbowize(CommandSender sender, String[] args){ | |
String colorMessage = ""; | |
String fullMessage = ""; | |
for(String y : args){ | |
colorMessage = appendColors(y); | |
fullMessage+=colorMessage+" "; | |
} | |
Player player = (Player) sender; | |
player.chat(fullMessage); | |
} | |
private String appendColors(String y) { | |
StringBuilder sb = new StringBuilder(y); | |
for(int x = 0; x < y.length()*3; x+=3){ | |
sb.insert(x, getRandomColor()); | |
} | |
return sb.toString(); | |
} | |
private ChatColor getRandomColor(){ | |
Random rdm = new Random(); | |
int zz = rdm.nextInt(16); | |
ChatColor randomColor = ChatColor.getByCode(zz); | |
return randomColor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment