From 7c6c2c23cef495e1c4800e33d35186472096d603 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 30 Mar 2025 13:15:32 +0700 Subject: [PATCH] refactor: make the stuff in QueryPlugin a bit more readable and also completely remove the fucky auto remover to eliminate all issues. --- build-number.txt | 2 +- .../chomens_bot/plugins/QueryPlugin.java | 27 ++++--------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/build-number.txt b/build-number.txt index 0efdb05c..f541bbdc 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -2252 \ No newline at end of file +2258 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java index 1b17a137..4719a440 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java @@ -11,7 +11,6 @@ import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener { private final Bot bot; @@ -53,15 +52,9 @@ public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener { transactions.remove(transactionId); - if (children.size() == 1) { + if (children.size() == 1 || !(children.get(1) instanceof TextComponent)) { future.complete(null); } else { - if (!(children.get(1) instanceof TextComponent)) { - future.complete(null); - - return true; - } - final String stringOutput = ((TextComponent) children.get(1)).content(); future.complete(stringOutput); @@ -82,15 +75,6 @@ public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener { final UUID id = UUID.randomUUID(); ids.add(id); - // this probably doesn't do much, since even if the command returns - // no output, the tracker will still tellraw to the bot that this command has - // completed no matter what, but just in case, we'll remove the - // transactions and the ids here after 5 minutes - bot.executor.schedule(() -> { - transactions.remove(transactionId); - ids.remove(id); - }, 5, TimeUnit.MINUTES); - return Triple.of(future, transactionId, id); } @@ -108,11 +92,10 @@ public class QueryPlugin extends Bot.Listener implements ChatPlugin.Listener { Component.blockNBT( path, - // is there a better way of doing this? - BlockNBTComponent.Pos.fromString( - location.getX() + " " + - location.getY() + " " + - location.getZ() + BlockNBTComponent.WorldPos.worldPos( + BlockNBTComponent.WorldPos.Coordinate.absolute(location.getX()), + BlockNBTComponent.WorldPos.Coordinate.absolute(location.getY()), + BlockNBTComponent.WorldPos.Coordinate.absolute(location.getZ()) ) ) ),