forked from RepoMirrors/kami-blue
cleanup customchat code
This commit is contained in:
parent
ed612d01e9
commit
ae8e367998
|
@ -13,29 +13,24 @@ import static me.zeroeightsix.kami.KamiMod.*;
|
|||
|
||||
/**
|
||||
* Created by 086 on 8/04/2018.
|
||||
* Updated by S-B99 on 18/02/20
|
||||
* Updated by S-B99 on 12/03/20
|
||||
*/
|
||||
@Module.Info(name = "CustomChat", category = Module.Category.CHAT, description = "Adds a watermark to the end of your message to let others know you're using KAMI Blue", showOnArray = Module.ShowOnArray.OFF)
|
||||
public class CustomChat extends Module {
|
||||
|
||||
public Setting<Boolean> startupGlobal = register(Settings.b("Enable Automatically", true));
|
||||
public Setting<TextMode> textMode = register(Settings.e("Message", TextMode.ONTOP));
|
||||
public Setting<TextMode> textMode = register(Settings.e("Message", TextMode.ON_TOP));
|
||||
private Setting<DecoMode> decoMode = register(Settings.e("Separator", DecoMode.NONE));
|
||||
private Setting<Boolean> commands = register(Settings.b("Commands", false));
|
||||
public Setting<String> customText = register(Settings.stringBuilder("Custom Text").withValue("unchanged").withConsumer((old, value) -> {}).build());
|
||||
|
||||
public enum TextMode {
|
||||
NAME, ONTOP, WEBSITE, JAPANESE, CUSTOM
|
||||
}
|
||||
|
||||
private enum DecoMode {
|
||||
SEPARATOR, CLASSIC, NONE
|
||||
}
|
||||
private enum DecoMode { SEPARATOR, CLASSIC, NONE }
|
||||
public enum TextMode { NAME, ON_TOP, WEBSITE, JAPANESE, CUSTOM }
|
||||
public static String[] cmdCheck = new String[]{"/", ",", ".", "-", ";", "?", "*", "^", "&", Command.getCommandPrefix()};
|
||||
|
||||
private String getText(TextMode t) {
|
||||
switch (t) {
|
||||
case NAME: return KAMI_BLUE;
|
||||
case ONTOP: return KAMI_ONTOP;
|
||||
case ON_TOP: return KAMI_ONTOP;
|
||||
case WEBSITE: return KAMI_WEBSITE;
|
||||
case JAPANESE: return KAMI_JAPANESE_ONTOP;
|
||||
case CUSTOM: return customText.getValue();
|
||||
|
@ -56,23 +51,20 @@ public class CustomChat extends Module {
|
|||
public Listener<PacketEvent.Send> listener = new Listener<>(event -> {
|
||||
if (event.getPacket() instanceof CPacketChatMessage) {
|
||||
String s = ((CPacketChatMessage) event.getPacket()).getMessage();
|
||||
if (!commands.getValue()) {
|
||||
if (s.startsWith("/")) return;
|
||||
else if (s.startsWith(",")) return;
|
||||
else if (s.startsWith(".")) return;
|
||||
else if (s.startsWith("-")) return;
|
||||
else if (s.startsWith(";")) return;
|
||||
else if (s.startsWith("?")) return;
|
||||
else if (s.startsWith("*")) return;
|
||||
else if (s.startsWith("^")) return;
|
||||
else if (s.startsWith("&")) return;
|
||||
}
|
||||
if (!commands.getValue() && isCommand(s)) return;
|
||||
s += getFull(decoMode.getValue());
|
||||
if (s.length() >= 256) s = s.substring(0, 256);
|
||||
((CPacketChatMessage) event.getPacket()).message = s;
|
||||
}
|
||||
});
|
||||
|
||||
public boolean isCommand(String s) {
|
||||
for (String value : cmdCheck) {
|
||||
if (s.startsWith(value)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static long startTime = 0;
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
|
Loading…
Reference in New Issue