From 3dc1ff9d6e47cef6b114f6edacd67ceeec33b530 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 19 Jun 2025 17:15:07 +0700 Subject: [PATCH] feat: actual ayunboom server self care --- build-number.txt | 2 +- .../java/me/chayapak1/chomens_bot/Bot.java | 2 - .../chayapak1/chomens_bot/Configuration.java | 2 +- .../chomens_bot/plugins/SelfCarePlugin.java | 4 ++ .../selfCares/ayunboom/AyunBoomSelfCare.java | 43 +++++++++++++++++++ src/main/resources/default-config.yml | 3 +- 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 src/main/java/me/chayapak1/chomens_bot/selfCares/ayunboom/AyunBoomSelfCare.java diff --git a/build-number.txt b/build-number.txt index 26b3ecce..93fed3dd 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3462 \ No newline at end of file +3464 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/Bot.java b/src/main/java/me/chayapak1/chomens_bot/Bot.java index 13f42e1c..cf9f5504 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Bot.java +++ b/src/main/java/me/chayapak1/chomens_bot/Bot.java @@ -258,8 +258,6 @@ public class Bot extends SessionAdapter { this.listener.dispatch(listener -> listener.connected(new ConnectedEvent(session))); session.send(ServerboundPlayerLoadedPacket.INSTANCE); - - if (!options.loginMessage.isBlank()) this.chat.send(options.loginMessage); } private void packetReceived (final ClientboundCustomQueryPacket packet) { diff --git a/src/main/java/me/chayapak1/chomens_bot/Configuration.java b/src/main/java/me/chayapak1/chomens_bot/Configuration.java index 15c8ade1..36780a4c 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Configuration.java +++ b/src/main/java/me/chayapak1/chomens_bot/Configuration.java @@ -156,6 +156,7 @@ public class Configuration { public String serverName; public String discordChannelId; public String ircChannel; + public boolean isAyunBoom = false; public boolean hidden = false; public boolean useCore = true; public boolean useCorePlaceBlock = false; @@ -166,7 +167,6 @@ public class Configuration { public boolean resolveSRV = true; public int reconnectDelay = 2000; public int chatQueueDelay = 125; - public String loginMessage = ""; public EssentialsMessages essentialsMessages = new EssentialsMessages(); public CoreRateLimit coreRateLimit = new CoreRateLimit(); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java index 6e916731..0b2f481b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/SelfCarePlugin.java @@ -5,6 +5,7 @@ import me.chayapak1.chomens_bot.data.listener.Listener; import me.chayapak1.chomens_bot.data.player.PlayerEntry; import me.chayapak1.chomens_bot.data.selfCare.SelfCare; import me.chayapak1.chomens_bot.data.selfCare.SelfData; +import me.chayapak1.chomens_bot.selfCares.ayunboom.AyunBoomSelfCare; import me.chayapak1.chomens_bot.selfCares.essentials.*; import me.chayapak1.chomens_bot.selfCares.kaboom.commandSpy.CommandSpySelfCare; import me.chayapak1.chomens_bot.selfCares.kaboom.extras.PrefixSelfCare; @@ -53,6 +54,9 @@ public class SelfCarePlugin implements Listener { // kaboom - iControlUwU selfCares.add(new IControlUSelfCare(bot)); + // ayunboom + selfCares.add(new AyunBoomSelfCare(bot)); + // essentials selfCares.add(new VanishSelfCare(bot)); selfCares.add(new NicknameSelfCare(bot)); diff --git a/src/main/java/me/chayapak1/chomens_bot/selfCares/ayunboom/AyunBoomSelfCare.java b/src/main/java/me/chayapak1/chomens_bot/selfCares/ayunboom/AyunBoomSelfCare.java new file mode 100644 index 00000000..9c4e8b38 --- /dev/null +++ b/src/main/java/me/chayapak1/chomens_bot/selfCares/ayunboom/AyunBoomSelfCare.java @@ -0,0 +1,43 @@ +package me.chayapak1.chomens_bot.selfCares.ayunboom; + +import me.chayapak1.chomens_bot.Bot; +import me.chayapak1.chomens_bot.data.selfCare.SelfCare; +import net.kyori.adventure.text.Component; +import org.geysermc.mcprotocollib.network.packet.Packet; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket; + +public class AyunBoomSelfCare extends SelfCare { + public AyunBoomSelfCare (final Bot bot) { + super(bot); + } + + @Override + public boolean shouldRun () { + return bot.options.isAyunBoom; + } + + @Override + public void onPacketReceived (final Packet packet) { + if (packet instanceof final ClientboundLoginPacket t_packet) onPacketReceived(t_packet); + } + + private void onPacketReceived (final ClientboundLoginPacket ignoredPacket) { + this.needsRunning = true; + } + + @Override + public void onMessageReceived (final Component component, final String string) { + if (string.equals("Unable to connect you to ayunboom. Please try again later.")) this.needsRunning = true; + else if (string.equals("You are already connected to this server!")) this.needsRunning = false; + } + + @Override + public void run () { + bot.chat.sendCommandInstantly("server ayunboom"); + } + + @Override + public void cleanup () { + this.needsRunning = true; + } +} diff --git a/src/main/resources/default-config.yml b/src/main/resources/default-config.yml index 8ad26c22..c4366b64 100644 --- a/src/main/resources/default-config.yml +++ b/src/main/resources/default-config.yml @@ -140,7 +140,6 @@ bots: # useCorePlaceBlock - uses the place block core instead of the main core. only used if useCore is enabled # useChat - when the bot tellraws it will chat instead of using the core to run tellraw # useSNBTComponents - if the server is >=1.21.5, it's pretty likely that you can enable this since 1.21.5 supports SNBT components - # loginMessage - the message to send when the bot received the login packet, this can also be a command, just prefix it with `/` # coreCommandSpy - set to true if server supports enabling player's commandspy through command block, defaults to true # logConnectionStatusMessages - logs connecting and disconnected messages to console (and the log file) and discord if set to true, defaults to true # resolveSRV - whether to resolve SRV records on the server. the notchian minecraft doesn't resolve them @@ -161,12 +160,12 @@ bots: # serverName: 'Localhost' # discordChannelId: '1234567890' # ircChannel: '#chomens/localhost' + # isAyunBoom: false # hidden: false # useCore: true # useCorePlaceBlock: false # useChat: false # useSNBTComponents: true - # loginMessage: '' # coreCommandSpy: true # logConnectionStatusMessages: true # resolveSRV: true