Closed SolsticeSpectrum closed 3 years ago
Btw I don't understand why you remove prefix for /msg but you don't remove suffix for /msg
I'm gonna be honest with you that I didn't quite understand your thinking why did you had those regexes for prefix but not suffix but this works. Also I had to put empty string there because else it was doubling the prefix.
@BleachSubscribe
public void onPacketSend(EventSendPacket event) {
if (event.getPacket() instanceof ChatMessageC2SPacket) {
String empty = "";
String text = ((ChatMessageC2SPacket) event.getPacket()).getChatMessage();
if (text.startsWith("/") || text.startsWith("!") || text.startsWith("/r") || text.startsWith("/reply") || text.startsWith("/msg") || text.startsWith("/tell") || text.startsWith("/w")) {
return;
}
if (getSetting(0).asToggle().state) {
text = fonts.get(getSetting(0).asToggle().getChild(0).asMode().mode).replace(text);
}
if (getSetting(1).asToggle().state) {
text = prefix + text;
}
if (getSetting(2).asToggle().state) {
text = text + suffix;
}
if (getSetting(5).asToggle().state) {
String key = getRandomString(4);
text = encrypt(text, key) + "\u00ff" + key;
}
if (!text.equals(((ChatMessageC2SPacket) event.getPacket()).getChatMessage())) {
FabricReflect.writeField(event.getPacket(), empty + text, "field_12764", "chatMessage");
}
}
}
Oh that code also affects the encryption I see Well it is funky to be honest
And I don't understand what it does anyway
The code is there so suffix/encryption works in messages
Okay yeah I found my issue. The issue was that I used /pm instead of /msg and the code does not count with that
and i removed prefix form /msg so it doesn't screw up the command but i realized now i could just put it after the /msg instead of removing it
Yeah that would be nice also put /pm there
Btw having encryption enabled screws /register command
The problem with the code is that it completely destroys prefix btw
Whenever I set prefix, it doesn't display it.
Also encryption only works when I type directly into public chat. When I type into pm/msg/whisper it does not work. It would be nice to encrypt PM messages because then admins can't understand what we are typing on non anarchy servers and we don't get kicked for spamming into public chat.