AdD "WAVE" and "RANDOMCASE" truE MEmE tExT. THIS comMiT MeSSage WAS BROUGht TO YoU by FAnCYcHAT
@@ -11,6 +11,7 @@ import com.matt.forgehax.util.mod.ToggleMod;
import com.matt.forgehax.util.mod.loader.RegisterMod;
import java.util.HashMap;
import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -26,7 +27,9 @@ public class FancyChat extends ToggleMod {
CIRCLE,
PARENTHESES,
SMALL,
- LEET
+ LEET,
+ WAVE,
+ RANDOMCASE
}
private static final String alphabet =
@@ -269,12 +272,9 @@ public class FancyChat extends ToggleMod {
}
}
- public String prettify(String message) {
- String messageOut;
+ private String makeLeet(String message) {
char[] messageArray;
- switch (font.get()) {
- case LEET:
message = message.replaceAll("(?i)dude", "d00d").replaceAll("(^|\\s)ph", "$1f");
messageArray = message.toCharArray();
@@ -306,12 +306,46 @@ public class FancyChat extends ToggleMod {
}
}
- messageOut = builder.toString();
- break;
+ return builder.toString();
+ }
- default:
- messageArray = message.toCharArray();
- int[] currentFont = FONT[font.get().ordinal()];
+ private String makeWave(String message) {
+ char[] messageArray = message.toCharArray();
+ ThreadLocalRandom rand = ThreadLocalRandom.current();
+ double span = rand.nextDouble(0.4D, 1.3D);
+ double xoff = rand.nextDouble(0, 32);
+ double yoff = rand.nextDouble(-0.4, 0.6);
+
+ for (int i = 0; i < messageArray.length; i++) {
+ if (waveCharIsUpper(i, span, xoff, yoff)) {
+ messageArray[i] = Character.toUpperCase(messageArray[i]);
+ }
+ }
+ return new String(messageArray);
+ }
+
+ private String randomCase(String message) {
+ char[] messageArray = message.toCharArray();
+ ThreadLocalRandom rand = ThreadLocalRandom.current();
+
+ for (int i = 0; i < messageArray.length; i++) {
+ if (rand.nextBoolean()) {
+ messageArray[i] = Character.toUpperCase(messageArray[i]);
+ } else {
+ messageArray[i] = Character.toLowerCase(messageArray[i]);
+ }
+ }
+ return new String(messageArray);
+ }
+
+ private boolean waveCharIsUpper(double x, double span, double xoff, double yoff) {
+ // defaults: span = 0.4, xoff=0, yoff=-0.5
+ return Math.sin(x*span + xoff)+yoff > 0;
+ }
+
+ private String changeAlphabet(String message, MODE fontType) {
+ char[] messageArray = message.toCharArray();
+ int[] currentFont = FONT[fontType.ordinal()];
int i = 0;
for (char c : messageArray) {
@@ -321,9 +355,19 @@ public class FancyChat extends ToggleMod {
}
i++;
}
- messageOut = new String(messageArray);
+ return new String(messageArray);
}
- return messageOut;
+ public String prettify(String message) {
+ switch (font.get()) {
+ case LEET:
+ return makeLeet(message);
+ case WAVE:
+ return makeWave(message);
+ case RANDOMCASE:
+ return randomCase(message);
+ default:
+ return changeAlphabet(message, font.get());
+ }
}
}
