From 6f488fc615032e99f95b023a1763bd0f281fb41e Mon Sep 17 00:00:00 2001 From: 50ap5ud5 <50ap5ud5125@gmail.com> Date: Wed, 27 Dec 2023 17:26:26 +1100 Subject: [PATCH] Fixed upgrade command not actually working - Fixed UpgradeArgumentType to be of the type ResourceLocation as expected by the game --- .../arguments/UpgradeArgumentType.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java b/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java index 9adac005d..e5798f860 100644 --- a/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java +++ b/common/src/main/java/whocraft/tardis_refined/command/arguments/UpgradeArgumentType.java @@ -15,6 +15,7 @@ import whocraft.tardis_refined.common.capability.upgrades.Upgrades; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; +import whocraft.tardis_refined.common.tardis.themes.ShellTheme; import whocraft.tardis_refined.constants.ModMessages; import java.util.Collection; @@ -22,7 +23,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class UpgradeArgumentType implements ArgumentType { +public class UpgradeArgumentType implements ArgumentType { private static final Collection EXAMPLES = Stream.of(Upgrades.COORDINATE_INPUT).map((upgrade) -> { return upgrade != null ? upgrade.getId().toString() : ""; @@ -34,13 +35,9 @@ public static UpgradeArgumentType upgradeArgumentType() { } @Override - public Upgrade parse(StringReader reader) throws CommandSyntaxException { - ResourceLocation location = ResourceLocation.read(reader); - Upgrade upgrade = Upgrades.UPGRADE_DEFERRED_REGISTRY.getRegistry().get(location); - if (upgrade != null) { - return upgrade; - } - throw INVALID_UPGRADE_EXCEPTION.create(location); } + public ResourceLocation parse(StringReader reader) throws CommandSyntaxException { + return ResourceLocation.read(reader); + } @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { @@ -60,4 +57,12 @@ public static Upgrade getUpgrade(CommandContext context, Str else return upgrade; } + + public static ResourceLocation getUpgradeId(CommandContext context, String name) throws CommandSyntaxException { + ResourceLocation resourcelocation = context.getArgument(name, ResourceLocation.class); + if (Upgrades.UPGRADE_REGISTRY.get(resourcelocation) == null) + throw INVALID_UPGRADE_EXCEPTION.create(resourcelocation); + else + return resourcelocation; + } } \ No newline at end of file