diff --git a/build-number.txt b/build-number.txt index 146f94f8..778f0006 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3051 \ No newline at end of file +3060 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java index 4afeb9b8..554ea227 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java @@ -234,7 +234,7 @@ public class CorePlugin implements Listener { final CompletableFuture trackedFuture = new CompletableFuture<>(); - final CompletableFuture future = bot.query.block(useCargo, coreBlock, "LastOutput"); + final CompletableFuture future = bot.query.block(useCargo, coreBlock, "LastOutput", true); future.thenApply(output -> { if (output == null) return null; 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 05304c9b..6690aac7 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/QueryPlugin.java @@ -5,6 +5,7 @@ import me.chayapak1.chomens_bot.Bot; import me.chayapak1.chomens_bot.data.listener.Listener; import me.chayapak1.chomens_bot.util.UUIDUtilities; import net.kyori.adventure.text.*; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.apache.commons.lang3.tuple.Triple; import org.cloudburstmc.math.vector.Vector3i; import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent; @@ -117,25 +118,30 @@ public class QueryPlugin implements Listener { final List children = cargo.children(); if ( - children.size() > 2 || - !(children.getFirst() instanceof final TextComponent firstChild) + children.size() > 3 || + !(children.get(0) instanceof final TextComponent transactionIdTextComponent) || + !(children.get(1) instanceof final TextComponent interpretTextComponent) ) return; try { - final long transactionId = Long.parseLong(firstChild.content()); + final long transactionId = Long.parseLong(transactionIdTextComponent.content()); if (!transactions.containsKey(transactionId)) return; + final boolean interpret = Boolean.parseBoolean(interpretTextComponent.content()); + final CompletableFuture future = transactions.get(transactionId); transactions.remove(transactionId); - if (children.size() == 1) { + if (children.size() == 2) { future.complete(""); - } else if (!(children.get(1) instanceof TextComponent)) { + } else if (!interpret && !(children.get(2) instanceof TextComponent)) { future.complete(null); } else { - final String stringOutput = ((TextComponent) children.get(1)).content(); + final String stringOutput = interpret + ? GsonComponentSerializer.gson().serialize(children.get(2)) // seems very + : ((TextComponent) children.get(2)).content(); future.complete(stringOutput); } @@ -154,9 +160,9 @@ public class QueryPlugin implements Listener { return Triple.of(future, transactionId, id); } - public CompletableFuture block (final Vector3i location, final String path) { return block(false, location, path); } + public CompletableFuture block (final Vector3i location, final String path) { return block(false, location, path, false); } - public CompletableFuture block (final boolean useCargo, final Vector3i location, final String path) { + public CompletableFuture block (final boolean useCargo, final Vector3i location, final String path, final boolean interpret) { final Triple, Long, UUID> triple = getFutureAndId(); final UUID id = triple.getRight(); @@ -165,10 +171,13 @@ public class QueryPlugin implements Listener { final Component component = Component .text(id.toString()) .append(Component.text(transactionId)) + .append(Component.text(interpret)) .append( Component.blockNBT( path, + interpret, + BlockNBTComponent.WorldPos.worldPos( BlockNBTComponent.WorldPos.Coordinate.absolute(location.getX()), BlockNBTComponent.WorldPos.Coordinate.absolute(location.getY()), @@ -194,6 +203,7 @@ public class QueryPlugin implements Listener { final Component component = Component .text(id.toString()) .append(Component.text(transactionId)) + .append(Component.text(false)) .append( Component.entityNBT( path,