From 09d062991c5241a91739a93919c446fe8f417ee5 Mon Sep 17 00:00:00 2001 From: frikandelworst Date: Fri, 8 Mar 2024 15:30:25 +0100 Subject: [PATCH 1/2] Fixed tpll not working --- .../pluginmessaging/PluginMessagingComponent.java | 2 +- .../modules/navigation/components/tpll/TpllComponent.java | 7 +++---- .../navigation/components/tpll/listeners/TpllListener.java | 7 +++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/buildtheearth/modules/common/components/pluginmessaging/PluginMessagingComponent.java b/src/main/java/net/buildtheearth/modules/common/components/pluginmessaging/PluginMessagingComponent.java index 4bc54180..0dc9c100 100644 --- a/src/main/java/net/buildtheearth/modules/common/components/pluginmessaging/PluginMessagingComponent.java +++ b/src/main/java/net/buildtheearth/modules/common/components/pluginmessaging/PluginMessagingComponent.java @@ -55,7 +55,7 @@ public void onPluginMessageReceived(String channel, Player player, byte[] messag } // Add a new universal tpll target to the queue - if (subChannel.equals("Tpll")) { + if (subChannel.equals("TPLL")) { NavigationModule.getInstance().getTpllComponent().addTpllToQueue(in, player); } diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java index 6aec678c..99f681a0 100644 --- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java +++ b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java @@ -85,14 +85,13 @@ public void tpllPlayer(Player player, double[] coordinates, String targetServerN ChatHelper.logDebug("Starting universal tpll teleportation for %s to %s.", player.getDisplayName(), targetServerName); // Send a plugin message to the target server which adds the tpll to the queue ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("Tpll"); + out.writeUTF("TPLL"); out.writeUTF(targetServerName); - out.writeUTF(String.valueOf(coordinates[0])); - out.writeUTF(String.valueOf(coordinates[1])); + out.writeUTF(player.getUniqueId().toString()); + out.writeUTF(String.valueOf(coordinates[0]) + coordinates[1]); player.sendPluginMessage(BuildTeamTools.getInstance(), "BuildTeam", out.toByteArray()); // Switch the player to the target server - NetworkModule.getInstance().switchServer(player, targetServerName); ChatHelper.logDebug("Teleported player to the target server."); } diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java index 06a16509..cf3cef57 100644 --- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java +++ b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/listeners/TpllListener.java @@ -55,11 +55,13 @@ public void onTpll(PlayerCommandPreprocessEvent event) { */ private boolean isTpllCommand(PlayerCommandPreprocessEvent event) { // Check if the command starts with "tpll" - if (!event.getMessage().startsWith("tpll")) return false; + ChatHelper.logDebug(event.getMessage()); + if (!event.getMessage().startsWith("/tpll")) return false; ChatHelper.logDebug("Intercepted tpll command."); // Split the command to extract coordinates String[] splitMessage = event.getMessage().split(" "); + splitMessage[1] = splitMessage[1].replaceAll(",", " ").trim(); if (splitMessage.length < 3) return false; ChatHelper.logDebug("Command had the correct length (%s).", splitMessage.length); @@ -85,7 +87,8 @@ private CompletableFuture shouldIntercept(PlayerCommandPreprocessEvent if (!networkModule.getBuildTeam().isConnected() || !region.isConnected()) { event.getPlayer().sendMessage(ChatHelper.error("Either this server or the receiving server isn't connected to the network.")); - return CompletableFuture.completedFuture(true); + event.setCancelled(true); + return CompletableFuture.completedFuture(false); } if (region.getBuildTeam().getID() != networkModule.getBuildTeam().getID()) { From b3e5e0746c2b06df0fd3ab1c251f53c5ccbef694 Mon Sep 17 00:00:00 2001 From: MineFact <66020920+MineFact@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:47:24 +0100 Subject: [PATCH 2/2] Update TpllComponent.java --- .../modules/navigation/components/tpll/TpllComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java index 99f681a0..9516e780 100644 --- a/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java +++ b/src/main/java/net/buildtheearth/modules/navigation/components/tpll/TpllComponent.java @@ -89,7 +89,7 @@ public void tpllPlayer(Player player, double[] coordinates, String targetServerN out.writeUTF(targetServerName); out.writeUTF(player.getUniqueId().toString()); out.writeUTF(String.valueOf(coordinates[0]) + coordinates[1]); - player.sendPluginMessage(BuildTeamTools.getInstance(), "BuildTeam", out.toByteArray()); + player.sendPluginMessage(BuildTeamTools.getInstance(), "buildteamtools:buildteam", out.toByteArray()); // Switch the player to the target server ChatHelper.logDebug("Teleported player to the target server.");