update auto welcomer

This commit is contained in:
Lee 2023-03-08 13:39:15 +00:00
parent 511550db0c
commit 6a4ee4d070
3 changed files with 20 additions and 8 deletions

@ -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;
});
}

@ -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()) {

@ -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) {