aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2021-07-30 17:49:30 -0400
committerbowser0000 <bowser0000@gmail.com>2021-07-30 17:49:30 -0400
commit342c6c8c6096db1e3e0e2ea4363ba34764f1121b (patch)
treed658ff0b36726fc8e8617a6ebe4ce9fac958e357
parentd534e7e9da3c3d20825cda831f2814249e212d5a (diff)
downloadSkyblockMod-342c6c8c6096db1e3e0e2ea4363ba34764f1121b.tar.gz
SkyblockMod-342c6c8c6096db1e3e0e2ea4363ba34764f1121b.tar.bz2
SkyblockMod-342c6c8c6096db1e3e0e2ea4363ba34764f1121b.zip
Add rainbow colour names
-rw-r--r--src/main/java/me/Danker/features/ColouredNames.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/features/ColouredNames.java b/src/main/java/me/Danker/features/ColouredNames.java
index 2156f3a..cba327a 100644
--- a/src/main/java/me/Danker/features/ColouredNames.java
+++ b/src/main/java/me/Danker/features/ColouredNames.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
public class ColouredNames {
public static List<String> users = new ArrayList<>();
+ public static final EnumChatFormatting[] RAINBOW_COLOURS = new EnumChatFormatting[]{EnumChatFormatting.RED, EnumChatFormatting.GOLD, EnumChatFormatting.YELLOW, EnumChatFormatting.GREEN, EnumChatFormatting.AQUA, EnumChatFormatting.BLUE, EnumChatFormatting.DARK_PURPLE};
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
@@ -76,8 +77,23 @@ public class ColouredNames {
Matcher prevColourMat = Pattern.compile("(?:.*(?:(?<colour>\\u00a7[0-9a-fbr])" + name + ")\\b.*)").matcher(text);
if (prevColourMat.matches()) {
+ if (colour.equals("§z")) {
+ StringBuilder rainbowName = new StringBuilder();
+ for (int i = 0; i < name.length(); i++) {
+ rainbowName.append(RAINBOW_COLOURS[i % 7]).append(name.charAt(i));
+ }
+ return text.replaceAll(namePattern, rainbowName + prevColourMat.group("colour"));
+ }
return text.replaceAll(namePattern, colour + name + prevColourMat.group("colour"));
}
+
+ if (colour.equals("§z")) {
+ StringBuilder rainbowName = new StringBuilder();
+ for (int i = 0; i < name.length(); i++) {
+ rainbowName.append(RAINBOW_COLOURS[i % 7]).append(name.charAt(i));
+ }
+ return text.replaceAll(namePattern, rainbowName.toString() + EnumChatFormatting.WHITE);
+ }
return text.replaceAll(namePattern, colour + name + EnumChatFormatting.WHITE);
}