From 6a4ee4d07021eb01781ed33996e99f7f54f3398f Mon Sep 17 00:00:00 2001 From: liam Date: Wed, 8 Mar 2023 13:39:15 +0000 Subject: [PATCH] update auto welcomer --- .../addon/impl/chat/AutoWelcomerAddon.java | 23 +++++++++++++++---- .../addon/impl/ui/OverlayAddon.java | 2 +- .../wildaddons/tpsmonitor/TpsMonitor.java | 3 +-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/fascinated/wildaddons/addon/impl/chat/AutoWelcomerAddon.java b/src/main/java/cc/fascinated/wildaddons/addon/impl/chat/AutoWelcomerAddon.java index c073ae0..94411f3 100644 --- a/src/main/java/cc/fascinated/wildaddons/addon/impl/chat/AutoWelcomerAddon.java +++ b/src/main/java/cc/fascinated/wildaddons/addon/impl/chat/AutoWelcomerAddon.java @@ -11,11 +11,11 @@ import java.util.concurrent.ThreadLocalRandom; public class AutoWelcomerAddon extends Addon { + private final boolean autoWelcome = true; + private boolean waitingForReply = false; + public AutoWelcomerAddon() { - super("Auto Welcomer", - "Automatically sends the welcome command when a new player joins.", - Category.CHAT - ); + super("Auto Welcomer", "Automatically sends the welcome command when a new player joins.", Category.CHAT); // TODO: actually check if we got the gem for welcoming } @@ -25,6 +25,13 @@ public class AutoWelcomerAddon extends Addon { if (!this.isEnabled()) { // This addon is disabled return; } + + if (waitingForReply && messageStripped.equals("+1 Gen for welcoming")) { + Statistic.PLAYERS_WELCOMED.increment(); // Increment the stat + waitingForReply = false; + return; + } + if (!PlayerListener.isMoving()) { // To prevent bans lol return; } @@ -38,6 +45,11 @@ public class AutoWelcomerAddon extends Addon { if (Main.getMinecraftClient().player.getName().getString().equals(name)) { return; } + + if (!autoWelcome) { // Stop running if auto welcome is disabled + return; + } + Main.getExecutorService().execute(() -> { try { // Sleep the thread for a randomized amount of time to make it look less suspicious @@ -46,7 +58,8 @@ public class AutoWelcomerAddon extends Addon { throw new RuntimeException(e); } PlayerUtils.sendMessage("/wc"); // Send the command - Statistic.PLAYERS_WELCOMED.increment(); // Increment the stat + + waitingForReply = true; }); } diff --git a/src/main/java/cc/fascinated/wildaddons/addon/impl/ui/OverlayAddon.java b/src/main/java/cc/fascinated/wildaddons/addon/impl/ui/OverlayAddon.java index aceff23..104bd14 100644 --- a/src/main/java/cc/fascinated/wildaddons/addon/impl/ui/OverlayAddon.java +++ b/src/main/java/cc/fascinated/wildaddons/addon/impl/ui/OverlayAddon.java @@ -44,8 +44,8 @@ public class OverlayAddon extends Addon { } lastY += 11; renderer.drawWithShadow(matrixStack, "IP: " + PlayerUtils.getCurrentServerIp(), 5, lastY, 0xffffff); - lastY += 11; + lastY += 13; renderer.drawWithShadow(matrixStack, "§7§nStatistics:", 5, lastY, 0xffffff); lastY += 11; for (Statistic statistic : Statistic.values()) { diff --git a/src/main/java/cc/fascinated/wildaddons/tpsmonitor/TpsMonitor.java b/src/main/java/cc/fascinated/wildaddons/tpsmonitor/TpsMonitor.java index a0733ef..3f0901f 100644 --- a/src/main/java/cc/fascinated/wildaddons/tpsmonitor/TpsMonitor.java +++ b/src/main/java/cc/fascinated/wildaddons/tpsmonitor/TpsMonitor.java @@ -14,10 +14,9 @@ public class TpsMonitor implements EventListener { @Override public void onPacketReceive(Packet packet) { - if (!(packet instanceof WorldTimeUpdateS2CPacket)) { + if (!(packet instanceof WorldTimeUpdateS2CPacket updatePacket)) { return; } - WorldTimeUpdateS2CPacket updatePacket = (WorldTimeUpdateS2CPacket) packet; long currentWorldTicks = updatePacket.getTime(); if (systemTime == 0) {