aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/1043-Brigadier-based-command-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/1043-Brigadier-based-command-API.patch')
-rw-r--r--patches/server/1043-Brigadier-based-command-API.patch39
1 files changed, 37 insertions, 2 deletions
diff --git a/patches/server/1043-Brigadier-based-command-API.patch b/patches/server/1043-Brigadier-based-command-API.patch
index 2dd9a7550d..a318e2e061 100644
--- a/patches/server/1043-Brigadier-based-command-API.patch
+++ b/patches/server/1043-Brigadier-based-command-API.patch
@@ -9,6 +9,8 @@ public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE
public net.minecraft.server.ReloadableServerResources registryLookup
public net.minecraft.server.ReloadableServerResources
+Co-authored-by: Jake Potrebic <[email protected]>
+
diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
index 4b4f812eb13d5f03bcf3f8724d8aa8dbbc724e8b..a4d5d7017e0be79844b996de85a63cad5f8488bc 100644
--- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java
@@ -1068,10 +1070,10 @@ index 0000000000000000000000000000000000000000..72966584089d3fee9778f572727c9b7f
+}
diff --git a/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java b/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java
new file mode 100644
-index 0000000000000000000000000000000000000000..5f0b46cb2b3f53a81a949fa64690133baa0a304b
+index 0000000000000000000000000000000000000000..93edb22c8500e79f86b101ef38955bca45a8d3a9
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/argument/VanillaArgumentProviderImpl.java
-@@ -0,0 +1,321 @@
+@@ -0,0 +1,354 @@
+package io.papermc.paper.command.brigadier.argument;
+
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
@@ -1096,6 +1098,10 @@ index 0000000000000000000000000000000000000000..5f0b46cb2b3f53a81a949fa64690133b
+import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
+import io.papermc.paper.entity.LookAnchor;
+import io.papermc.paper.math.Position;
++import io.papermc.paper.registry.PaperRegistries;
++import io.papermc.paper.registry.RegistryAccess;
++import io.papermc.paper.registry.RegistryKey;
++import io.papermc.paper.registry.TypedKey;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
@@ -1119,6 +1125,8 @@ index 0000000000000000000000000000000000000000..5f0b46cb2b3f53a81a949fa64690133b
+import net.minecraft.commands.arguments.MessageArgument;
+import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
+import net.minecraft.commands.arguments.RangeArgument;
++import net.minecraft.commands.arguments.ResourceArgument;
++import net.minecraft.commands.arguments.ResourceKeyArgument;
+import net.minecraft.commands.arguments.ResourceLocationArgument;
+import net.minecraft.commands.arguments.ScoreboardSlotArgument;
+import net.minecraft.commands.arguments.StyleArgument;
@@ -1139,6 +1147,7 @@ index 0000000000000000000000000000000000000000..5f0b46cb2b3f53a81a949fa64690133b
+import net.minecraft.world.level.Level;
+import org.bukkit.GameMode;
+import org.bukkit.HeightMap;
++import org.bukkit.Keyed;
+import org.bukkit.NamespacedKey;
+import org.bukkit.World;
+import org.bukkit.block.BlockState;
@@ -1349,6 +1358,32 @@ index 0000000000000000000000000000000000000000..5f0b46cb2b3f53a81a949fa64690133b
+ return this.wrap(TemplateRotationArgument.templateRotation(), mirror -> StructureRotation.valueOf(mirror.name()));
+ }
+
++ @Override
++ public <T> ArgumentType<TypedKey<T>> resourceKey(final RegistryKey<T> registryKey) {
++ return this.wrap(
++ ResourceKeyArgument.key(PaperRegistries.toNms(registryKey)),
++ nmsRegistryKey -> TypedKey.create(registryKey, CraftNamespacedKey.fromMinecraft(nmsRegistryKey.location()))
++ );
++ }
++
++ @Override
++ public <T> ArgumentType<T> resource(final RegistryKey<T> registryKey) {
++ return this.resourceRaw(registryKey);
++ }
++
++ @SuppressWarnings({"unchecked", "rawtypes", "UnnecessaryLocalVariable"})
++ private <T, K extends Keyed> ArgumentType<T> resourceRaw(final RegistryKey registryKeyRaw) { // TODO remove Keyed
++ final RegistryKey<K> registryKey = registryKeyRaw;
++ return (ArgumentType<T>) this.wrap(
++ ResourceArgument.resource(PaperCommands.INSTANCE.getBuildContext(), PaperRegistries.toNms(registryKey)),
++ resource -> requireNonNull(
++ RegistryAccess.registryAccess()
++ .getRegistry(registryKey)
++ .get(CraftNamespacedKey.fromMinecraft(resource.key().location()))
++ )
++ );
++ }
++
+ private <T> ArgumentType<T> wrap(final ArgumentType<T> base) {
+ return this.wrap(base, identity -> identity);
+ }