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 { public class AutoWelcomerAddon extends Addon {
private final boolean autoWelcome = true;
private boolean waitingForReply = false;
public AutoWelcomerAddon() { public AutoWelcomerAddon() {
super("Auto Welcomer", super("Auto Welcomer", "Automatically sends the welcome command when a new player joins.", Category.CHAT);
"Automatically sends the welcome command when a new player joins.",
Category.CHAT
);
// TODO: actually check if we got the gem for welcoming // 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 if (!this.isEnabled()) { // This addon is disabled
return; 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 if (!PlayerListener.isMoving()) { // To prevent bans lol
return; return;
} }
@ -38,6 +45,11 @@ public class AutoWelcomerAddon extends Addon {
if (Main.getMinecraftClient().player.getName().getString().equals(name)) { if (Main.getMinecraftClient().player.getName().getString().equals(name)) {
return; return;
} }
if (!autoWelcome) { // Stop running if auto welcome is disabled
return;
}
Main.getExecutorService().execute(() -> { Main.getExecutorService().execute(() -> {
try { try {
// Sleep the thread for a randomized amount of time to make it look less suspicious // 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); throw new RuntimeException(e);
} }
PlayerUtils.sendMessage("/wc"); // Send the command 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; lastY += 11;
renderer.drawWithShadow(matrixStack, "IP: " + PlayerUtils.getCurrentServerIp(), 5, lastY, 0xffffff); renderer.drawWithShadow(matrixStack, "IP: " + PlayerUtils.getCurrentServerIp(), 5, lastY, 0xffffff);
lastY += 11;
lastY += 13;
renderer.drawWithShadow(matrixStack, "§7§nStatistics:", 5, lastY, 0xffffff); renderer.drawWithShadow(matrixStack, "§7§nStatistics:", 5, lastY, 0xffffff);
lastY += 11; lastY += 11;
for (Statistic statistic : Statistic.values()) { for (Statistic statistic : Statistic.values()) {

@ -14,10 +14,9 @@ public class TpsMonitor implements EventListener {
@Override @Override
public void onPacketReceive(Packet<?> packet) { public void onPacketReceive(Packet<?> packet) {
if (!(packet instanceof WorldTimeUpdateS2CPacket)) { if (!(packet instanceof WorldTimeUpdateS2CPacket updatePacket)) {
return; return;
} }
WorldTimeUpdateS2CPacket updatePacket = (WorldTimeUpdateS2CPacket) packet;
long currentWorldTicks = updatePacket.getTime(); long currentWorldTicks = updatePacket.getTime();
if (systemTime == 0) { if (systemTime == 0) {