From 91d247ebefcb2f784208b63e1479b6d50f48aa5a Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 15 Jun 2024 18:43:24 +0100 Subject: [PATCH 1/4] fix: tpaccept and tpdeny not working --- .../commands/impl/teleporting/TPACommand.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java b/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java index 98e3fde..5d90dcb 100644 --- a/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java +++ b/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java @@ -13,6 +13,7 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.*; import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.List; @@ -104,7 +105,13 @@ public int tpa(ServerPlayer player, ServerPlayer target, boolean here) { } public int tpaccept(ServerPlayer player, String id) { - TPARequest request = REQUESTS.get(id); + var uuid = attemptUuid(id); + if (uuid == null) { + player.displayClientMessage(Component.literal("Invalid request!"), false); + return 0; + } + + TPARequest request = REQUESTS.get(uuid); if (request == null) { player.displayClientMessage(Component.literal("Invalid request!"), false); @@ -130,8 +137,13 @@ public int tpaccept(ServerPlayer player, String id) { } public int tpdeny(ServerPlayer player, String id) { - TPARequest request = REQUESTS.get(id); + var uuid = attemptUuid(id); + if (uuid == null) { + player.displayClientMessage(Component.literal("Invalid request!"), false); + return 0; + } + TPARequest request = REQUESTS.get(uuid); if (request == null) { player.displayClientMessage(Component.literal("Invalid request!"), false); return 0; @@ -161,6 +173,15 @@ public static void clearRequests() { REQUESTS.clear(); } + @Nullable + private UUID attemptUuid(String id) { + try { + return UUID.fromString(id); + } catch (IllegalArgumentException e) { + return null; + } + } + public static HashMap requests() { return REQUESTS; } From a83c42b20b2d55ed6123de71a0cbe0aa9f593831 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 15 Jun 2024 18:43:24 +0100 Subject: [PATCH 2/4] fix: tpaccept and tpdeny not working https://github.com/FTBTeam/FTB-Mods-Issues/issues/1225 --- .../commands/impl/teleporting/TPACommand.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java b/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java index 98e3fde..5d90dcb 100644 --- a/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java +++ b/common/src/main/java/dev/ftb/mods/ftbessentials/commands/impl/teleporting/TPACommand.java @@ -13,6 +13,7 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.*; import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.List; @@ -104,7 +105,13 @@ public int tpa(ServerPlayer player, ServerPlayer target, boolean here) { } public int tpaccept(ServerPlayer player, String id) { - TPARequest request = REQUESTS.get(id); + var uuid = attemptUuid(id); + if (uuid == null) { + player.displayClientMessage(Component.literal("Invalid request!"), false); + return 0; + } + + TPARequest request = REQUESTS.get(uuid); if (request == null) { player.displayClientMessage(Component.literal("Invalid request!"), false); @@ -130,8 +137,13 @@ public int tpaccept(ServerPlayer player, String id) { } public int tpdeny(ServerPlayer player, String id) { - TPARequest request = REQUESTS.get(id); + var uuid = attemptUuid(id); + if (uuid == null) { + player.displayClientMessage(Component.literal("Invalid request!"), false); + return 0; + } + TPARequest request = REQUESTS.get(uuid); if (request == null) { player.displayClientMessage(Component.literal("Invalid request!"), false); return 0; @@ -161,6 +173,15 @@ public static void clearRequests() { REQUESTS.clear(); } + @Nullable + private UUID attemptUuid(String id) { + try { + return UUID.fromString(id); + } catch (IllegalArgumentException e) { + return null; + } + } + public static HashMap requests() { return REQUESTS; } From 2ccf7259c2d93dd6862d336396708efdfdd7893f Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Sun, 16 Jun 2024 22:01:15 +0100 Subject: [PATCH 3/4] build: version -> 2004.1.3, changelog updated --- CHANGELOG.md | 5 +++++ gradle.properties | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05ef7e5..36e5b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2004.1.3] + +### Fixed +* Fixed `/tpaccept` command failing with "Invalid request!" error + ## [2004.1.2] ### Changed diff --git a/gradle.properties b/gradle.properties index 94bef1b..4d62f2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ mod_id=ftbessentials archives_base_name=ftb-essentials maven_group=dev.ftb.mods minecraft_version=1.20.4 -mod_version=2004.1.2 +mod_version=2004.1.3 mod_author=FTB Team # Deps From 23ca1c3a09c87b59ec1d87ba034bdd50fae3663a Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Sun, 16 Jun 2024 22:03:52 +0100 Subject: [PATCH 4/4] ci: build on push to "1.**", not "1.*" --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d4d795..ec67c57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Java CI - Build on Push on: push: - branches: [ main, dev, "1.*" ] + branches: [ main, dev, "1.**" ] workflow_dispatch: inputs: skip_maven_publish: