diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java index aaaf854..b6dc68c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Configuration.java @@ -87,6 +87,8 @@ public class Configuration { } public static class SelfCare { + public int delay = 225; + public boolean op = true; public boolean gamemode = true; public boolean endCredits = true; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java index ec304a2..6418edc 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java @@ -226,28 +226,36 @@ public class ChatPlugin extends Bot.Listener { } } - bot.session.send(new ServerboundChatCommandPacket( - removedMessage, - Instant.now().toEpochMilli(), - 0L, - Collections.emptyList(), - 0, - new BitSet() - )); + sendCommandInstantly(removedMessage); } else { - bot.session.send(new ServerboundChatPacket( - message, - Instant.now().toEpochMilli(), - 0L, - null, - 0, - new BitSet() - )); + sendChatInstantly(message); } queue.remove(0); } + public void sendCommandInstantly (String command) { + bot.session.send(new ServerboundChatCommandPacket( + command, + Instant.now().toEpochMilli(), + 0L, + Collections.emptyList(), + 0, + new BitSet() + )); + } + + public void sendChatInstantly (String message) { + bot.session.send(new ServerboundChatPacket( + message, + Instant.now().toEpochMilli(), + 0L, + null, + 0, + new BitSet() + )); + } + public void clearQueue () { queue.clear(); } public void send (String message) { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java index 19917af..088b38e 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/SelfCarePlugin.java @@ -94,21 +94,22 @@ public class SelfCarePlugin extends Bot.Listener { else if (selfCares.username && !username && bot.options.kaboom) bot.chat.send("/extras:username " + bot.username); // core + // TODO: improve lol else if (selfCares.icu.enabled && positionPacketsPerSecond > selfCares.icu.positionPacketsPerSecond) bot.core.run("essentials:sudo * icu stop"); else if (selfCares.vanish && !vanish && !visibility && bot.options.hasEssentials) { - if (bot.options.useChat) bot.chat.send("/essentials:vanish enable"); + if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:vanish enable"); else bot.core.run("essentials:vanish " + bot.username + " enable"); } else if (selfCares.nickname && !nickname && bot.options.hasEssentials) { - if (bot.options.useChat) bot.chat.send("/essentials:nick off"); + if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:nick off"); else bot.core.run("essentials:nickname " + bot.username + " off"); } else if (selfCares.socialspy && !socialspy && bot.options.hasEssentials) { - if (bot.options.useChat) bot.chat.send("/essentials:socialspy enable"); + if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:socialspy enable"); else bot.core.run("essentials:socialspy " + bot.username + " enable"); } else if (selfCares.mute && muted && bot.options.hasEssentials) { - if (bot.options.useChat) bot.chat.send("/essentials:mute " + bot.profile.getIdAsString()); + if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:mute " + bot.profile.getIdAsString()); else bot.core.run("essentials:mute " + bot.profile.getIdAsString()); muted = false; // too lazy fix and probably the worst fix? @@ -140,7 +141,7 @@ public class SelfCarePlugin extends Bot.Listener { check(); }; - checkTask = bot.executor.scheduleAtFixedRate(task, 0, bot.options.chatQueueDelay + 75, TimeUnit.MILLISECONDS); + checkTask = bot.executor.scheduleAtFixedRate(task, 0, bot.config.selfCare.delay, TimeUnit.MILLISECONDS); } public void packetReceived (ClientboundGameEventPacket packet) { diff --git a/src/main/resources/default-config.yml b/src/main/resources/default-config.yml index 20f92a5..a6163d8 100644 --- a/src/main/resources/default-config.yml +++ b/src/main/resources/default-config.yml @@ -61,6 +61,8 @@ core: customName: '[{"text":"ChomeNS ","color":"yellow"},{"text":"Core","color":"green"},{"text":"™","color":"gold"}]' selfCare: + delay: 225 # NOTE: self care does NOT use chat queue + # vanilla op: true gamemode: true