Skip to content

Commit 4e16bd4

Browse files
committed
Fix parsing errors for advancement and recipe argument
1 parent 461ff87 commit 4e16bd4

File tree

15 files changed

+143
-3
lines changed
  • commandapi-platforms/commandapi-bukkit
    • commandapi-bukkit-core/src/main/java/dev/jorel/commandapi
    • commandapi-bukkit-nms
      • commandapi-bukkit-1.16.5/src/main/java/dev/jorel/commandapi/nms
      • commandapi-bukkit-1.21.2/src/main/java/dev/jorel/commandapi/nms
      • commandapi-bukkit-nms-common/src/main/java/dev/jorel/commandapi/nms
    • commandapi-bukkit-test
      • commandapi-bukkit-test-impl-1.16.5/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.17/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.18/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.19.2/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.19.4/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.20.2/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.20.3/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.20.5/src/main/java/dev/jorel/commandapi/test
      • commandapi-bukkit-test-impl-1.20/src/main/java/dev/jorel/commandapi/test

15 files changed

+143
-3
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/arguments/AdvancementArgument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class AdvancementArgument extends SafeOverrideableArgument<Advancement, A
4040
* @param nodeName the name of the node for argument
4141
*/
4242
public AdvancementArgument(String nodeName) {
43-
super(nodeName, CommandAPIBukkit.get()._ArgumentMinecraftKeyRegistered(), fromKey(Advancement::getKey));
43+
super(nodeName, CommandAPIBukkit.get()._ArgumentAdvancement(), fromKey(Advancement::getKey));
4444
}
4545

4646
@Override

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/arguments/RecipeArgument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class RecipeArgument extends SafeOverrideableArgument<Recipe, Recipe> imp
3939
* @param nodeName the name of the node for this argument
4040
*/
4141
public RecipeArgument(String nodeName) {
42-
super(nodeName, CommandAPIBukkit.get()._ArgumentMinecraftKeyRegistered(), fromKey((Recipe r) -> ((Keyed) r).getKey()));
42+
super(nodeName, CommandAPIBukkit.get()._ArgumentRecipe(), fromKey((Recipe r) -> ((Keyed) r).getKey()));
4343
}
4444

4545
@Override

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/nms/NMS.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474

7575
public interface NMS<CommandListenerWrapper> {
7676

77+
/**
78+
* @return Advancement argument (api:advancement)
79+
*/
80+
ArgumentType<?> _ArgumentAdvancement();
81+
7782
/**
7883
* @return Angle argument (minecraft:angle)
7984
*/
@@ -193,6 +198,11 @@ public interface NMS<CommandListenerWrapper> {
193198
*/
194199
ArgumentType<?> _ArgumentProfile();
195200

201+
/**
202+
* @return Recipe argument (api:recipe)
203+
*/
204+
ArgumentType<?> _ArgumentRecipe();
205+
196206
/**
197207
* @return Rotation argument (minecraft:rotation)
198208
*/

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.16.5/src/main/java/dev/jorel/commandapi/nms/NMS_1_16_R3.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ protected NamespacedKey fromMinecraftKey(MinecraftKey key) {
236236
return NamespacedKey.fromString(key.getNamespace() + ":" + key.getKey());
237237
}
238238

239+
@Override
240+
public ArgumentType<?> _ArgumentAdvancement() {
241+
return _ArgumentMinecraftKeyRegistered();
242+
}
243+
239244
@Override
240245
public ArgumentType<?> _ArgumentAngle() { return ArgumentAngle.a(); }
241246

@@ -315,6 +320,11 @@ public ArgumentType<?> _ArgumentEntity(ArgumentSubType subType) {
315320
@Override
316321
public ArgumentType<?> _ArgumentProfile() { return ArgumentProfile.a(); }
317322

323+
@Override
324+
public ArgumentType<?> _ArgumentRecipe() {
325+
return _ArgumentMinecraftKeyRegistered();
326+
}
327+
318328
@Override
319329
public ArgumentType<?> _ArgumentRotation() { return ArgumentRotation.a(); }
320330

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-1.21.2/src/main/java/dev/jorel/commandapi/nms/NMS_1_21_R2.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import net.minecraft.commands.arguments.ResourceKeyArgument;
4343
import net.minecraft.core.Holder;
44+
import net.minecraft.resources.ResourceKey;
4445
import net.minecraft.util.profiling.Profiler;
4546
import org.bukkit.Bukkit;
4647
import org.bukkit.Color;
@@ -249,6 +250,11 @@ private static NamespacedKey fromResourceLocation(ResourceLocation key) {
249250
return NamespacedKey.fromString(key.getNamespace() + ":" + key.getPath());
250251
}
251252

253+
@Override
254+
public ArgumentType<?> _ArgumentAdvancement() {
255+
return ResourceKeyArgument.key(Registries.ADVANCEMENT);
256+
}
257+
252258
@Override
253259
public final ArgumentType<?> _ArgumentBlockPredicate() {
254260
return BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT);
@@ -295,6 +301,11 @@ public final ArgumentType<?> _ArgumentParticle() {
295301
return ParticleArgument.particle(COMMAND_BUILD_CONTEXT);
296302
}
297303

304+
@Override
305+
public ArgumentType<?> _ArgumentRecipe() {
306+
return ResourceKeyArgument.key(Registries.RECIPE);
307+
}
308+
298309
@Override
299310
public final ArgumentType<?> _ArgumentSyntheticBiome() {
300311
return ResourceArgument.resource(COMMAND_BUILD_CONTEXT, Registries.BIOME);
@@ -769,7 +780,7 @@ public Object getPotionEffect(CommandContext<CommandSourceStack> cmdCtx, String
769780
@Override
770781
public final Recipe getRecipe(CommandContext<CommandSourceStack> cmdCtx, String key) throws CommandSyntaxException {
771782
RecipeHolder<?> recipe = ResourceKeyArgument.getRecipe(cmdCtx, key);
772-
return new ComplexRecipeImpl(fromResourceLocation(recipe.id().location()), recipe.toBukkitRecipe());
783+
return new ComplexRecipeImpl(fromResourceLocation(recipe.id().registry()), recipe.toBukkitRecipe());
773784
}
774785

775786
@Override

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-nms/commandapi-bukkit-nms-common/src/main/java/dev/jorel/commandapi/nms/NMS_Common.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ private static NamespacedKey fromResourceLocation(ResourceLocation key) {
9393
return NamespacedKey.fromString(key.getNamespace() + ":" + key.getPath());
9494
}
9595

96+
@Override
97+
public ArgumentType<?> _ArgumentAdvancement() {
98+
return ResourceLocationArgument.id();
99+
}
100+
96101
@Override
97102
public final ArgumentType<?> _ArgumentAngle() {
98103
return AngleArgument.angle();
@@ -189,6 +194,11 @@ public final ArgumentType<?> _ArgumentNBTCompound() {
189194
@Unimplemented(because = VERSION_SPECIFIC_IMPLEMENTATION, introducedIn = "1.19.3")
190195
public abstract ArgumentType<?> _ArgumentParticle();
191196

197+
@Override
198+
public ArgumentType<?> _ArgumentRecipe() {
199+
return ResourceLocationArgument.id();
200+
}
201+
192202
@Override
193203
public final ArgumentType<?> _ArgumentPosition() {
194204
return BlockPosArgument.blockPos();

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.16.5/src/main/java/dev/jorel/commandapi/test/MockNMS.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.stream.StreamSupport;
1313

1414
import be.seeseemelk.mockbukkit.help.HelpMapMock;
15+
import com.mojang.brigadier.arguments.ArgumentType;
1516
import dev.jorel.commandapi.*;
1617
import org.bukkit.Bukkit;
1718
import org.bukkit.Color;
@@ -252,6 +253,16 @@ private void registerDefaultRecipes() {
252253
* MockPlatform overrides *
253254
**************************/
254255

256+
@Override
257+
public ArgumentType<?> _ArgumentAdvancement() {
258+
return baseNMS._ArgumentAdvancement();
259+
}
260+
261+
@Override
262+
public ArgumentType<?> _ArgumentRecipe() {
263+
return baseNMS._ArgumentRecipe();
264+
}
265+
255266
@Override
256267
public ItemFactory getItemFactory() {
257268
return CraftItemFactory.instance();

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.17/src/main/java/dev/jorel/commandapi/test/MockNMS.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.stream.StreamSupport;
1212

1313
import be.seeseemelk.mockbukkit.help.HelpMapMock;
14+
import com.mojang.brigadier.arguments.ArgumentType;
1415
import dev.jorel.commandapi.*;
1516
import net.minecraft.commands.Commands;
1617
import org.bukkit.Bukkit;
@@ -236,6 +237,16 @@ private void registerDefaultRecipes() {
236237
* MockPlatform overrides *
237238
**************************/
238239

240+
@Override
241+
public ArgumentType<?> _ArgumentAdvancement() {
242+
return baseNMS._ArgumentAdvancement();
243+
}
244+
245+
@Override
246+
public ArgumentType<?> _ArgumentRecipe() {
247+
return baseNMS._ArgumentRecipe();
248+
}
249+
239250
@Override
240251
public ItemFactory getItemFactory() {
241252
return CraftItemFactory.instance();

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.18/src/main/java/dev/jorel/commandapi/test/MockNMS.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.stream.StreamSupport;
1313

1414
import be.seeseemelk.mockbukkit.help.HelpMapMock;
15+
import com.mojang.brigadier.arguments.ArgumentType;
1516
import dev.jorel.commandapi.*;
1617
import net.minecraft.commands.Commands;
1718
import org.bukkit.Bukkit;
@@ -253,6 +254,16 @@ private void registerDefaultRecipes() {
253254
* MockPlatform overrides *
254255
**************************/
255256

257+
@Override
258+
public ArgumentType<?> _ArgumentAdvancement() {
259+
return baseNMS._ArgumentAdvancement();
260+
}
261+
262+
@Override
263+
public ArgumentType<?> _ArgumentRecipe() {
264+
return baseNMS._ArgumentRecipe();
265+
}
266+
256267
@Override
257268
public ItemFactory getItemFactory() {
258269
return CraftItemFactory.instance();

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.19.2/src/main/java/dev/jorel/commandapi/test/MockNMS.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.stream.StreamSupport;
1313

1414
import be.seeseemelk.mockbukkit.help.HelpMapMock;
15+
import com.mojang.brigadier.arguments.ArgumentType;
1516
import dev.jorel.commandapi.*;
1617
import net.minecraft.commands.Commands;
1718
import org.bukkit.Bukkit;
@@ -249,6 +250,16 @@ private void registerDefaultRecipes() {
249250
* MockPlatform overrides *
250251
**************************/
251252

253+
@Override
254+
public ArgumentType<?> _ArgumentAdvancement() {
255+
return baseNMS._ArgumentAdvancement();
256+
}
257+
258+
@Override
259+
public ArgumentType<?> _ArgumentRecipe() {
260+
return baseNMS._ArgumentRecipe();
261+
}
262+
252263
@Override
253264
public ItemFactory getItemFactory() {
254265
return CraftItemFactory.instance();

0 commit comments

Comments
 (0)