diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch b/patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch new file mode 100644 index 0000000000..362597edc4 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch @@ -0,0 +1,199 @@ +--- a/net/minecraft/commands/arguments/EntityArgument.java ++++ b/net/minecraft/commands/arguments/EntityArgument.java +@@ -36,25 +36,25 @@ + final boolean single; + final boolean playersOnly; + +- protected EntityArgument(boolean flag, boolean flag1) { +- this.single = flag; +- this.playersOnly = flag1; ++ protected EntityArgument(boolean single, boolean playersOnly) { ++ this.single = single; ++ this.playersOnly = playersOnly; + } + + public static EntityArgument entity() { + return new EntityArgument(true, false); + } + +- public static Entity getEntity(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- return ((EntitySelector) commandcontext.getArgument(s, EntitySelector.class)).findSingleEntity((CommandSourceStack) commandcontext.getSource()); ++ public static Entity getEntity(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ return ((EntitySelector) context.getArgument(name, EntitySelector.class)).findSingleEntity((CommandSourceStack) context.getSource()); + } + + public static EntityArgument entities() { + return new EntityArgument(false, false); + } + +- public static Collection<? extends Entity> getEntities(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- Collection<? extends Entity> collection = getOptionalEntities(commandcontext, s); ++ public static Collection<? extends Entity> getEntities(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ Collection<? extends Entity> collection = getOptionalEntities(context, name); + + if (collection.isEmpty()) { + throw EntityArgument.NO_ENTITIES_FOUND.create(); +@@ -63,28 +63,28 @@ + } + } + +- public static Collection<? extends Entity> getOptionalEntities(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- return ((EntitySelector) commandcontext.getArgument(s, EntitySelector.class)).findEntities((CommandSourceStack) commandcontext.getSource()); ++ public static Collection<? extends Entity> getOptionalEntities(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ return ((EntitySelector) context.getArgument(name, EntitySelector.class)).findEntities((CommandSourceStack) context.getSource()); + } + +- public static Collection<ServerPlayer> getOptionalPlayers(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- return ((EntitySelector) commandcontext.getArgument(s, EntitySelector.class)).findPlayers((CommandSourceStack) commandcontext.getSource()); ++ public static Collection<ServerPlayer> getOptionalPlayers(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ return ((EntitySelector) context.getArgument(name, EntitySelector.class)).findPlayers((CommandSourceStack) context.getSource()); + } + + public static EntityArgument player() { + return new EntityArgument(true, true); + } + +- public static ServerPlayer getPlayer(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- return ((EntitySelector) commandcontext.getArgument(s, EntitySelector.class)).findSinglePlayer((CommandSourceStack) commandcontext.getSource()); ++ public static ServerPlayer getPlayer(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ return ((EntitySelector) context.getArgument(name, EntitySelector.class)).findSinglePlayer((CommandSourceStack) context.getSource()); + } + + public static EntityArgument players() { + return new EntityArgument(false, true); + } + +- public static Collection<ServerPlayer> getPlayers(CommandContext<CommandSourceStack> commandcontext, String s) throws CommandSyntaxException { +- List<ServerPlayer> list = ((EntitySelector) commandcontext.getArgument(s, EntitySelector.class)).findPlayers((CommandSourceStack) commandcontext.getSource()); ++ public static Collection<ServerPlayer> getPlayers(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException { ++ List<ServerPlayer> list = ((EntitySelector) context.getArgument(name, EntitySelector.class)).findPlayers((CommandSourceStack) context.getSource()); + + if (list.isEmpty()) { + throw EntityArgument.NO_PLAYERS_FOUND.create(); +@@ -93,11 +93,16 @@ + } + } + +- @Override +- public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException { ++ public EntitySelector parse(StringReader reader) throws CommandSyntaxException { ++ // CraftBukkit start ++ return parse(reader, false); ++ } ++ ++ public EntitySelector parse(StringReader stringreader, boolean overridePermissions) throws CommandSyntaxException { ++ // CraftBukkit end + boolean flag = false; +- EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader); +- EntitySelector entityselector = entityselectorparser.parse(); ++ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader); ++ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit + + if (entityselector.getMaxResults() > 1 && this.single) { + if (this.playersOnly) { +@@ -115,26 +120,25 @@ + } + } + +- @Override + public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> commandcontext, SuggestionsBuilder suggestionsbuilder) { + Object object = commandcontext.getSource(); + + if (object instanceof SharedSuggestionProvider) { +- SharedSuggestionProvider sharedsuggestionprovider = (SharedSuggestionProvider) object; ++ SharedSuggestionProvider icompletionprovider = (SharedSuggestionProvider) object; + StringReader stringreader = new StringReader(suggestionsbuilder.getInput()); + + stringreader.setCursor(suggestionsbuilder.getStart()); +- EntitySelectorParser entityselectorparser = new EntitySelectorParser(stringreader, sharedsuggestionprovider.hasPermission(2)); ++ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, icompletionprovider.hasPermission(2)); + + try { +- entityselectorparser.parse(); ++ argumentparserselector.parse(); + } catch (CommandSyntaxException commandsyntaxexception) { + ; + } + +- return entityselectorparser.fillSuggestions(suggestionsbuilder, (suggestionsbuilder1) -> { +- Collection<String> collection = sharedsuggestionprovider.getOnlinePlayerNames(); +- Iterable<String> iterable = this.playersOnly ? collection : Iterables.concat(collection, sharedsuggestionprovider.getSelectedEntities()); ++ return argumentparserselector.fillSuggestions(suggestionsbuilder, (suggestionsbuilder1) -> { ++ Collection<String> collection = icompletionprovider.getOnlinePlayerNames(); ++ Iterable<String> iterable = this.playersOnly ? collection : Iterables.concat(collection, icompletionprovider.getSelectedEntities()); + + SharedSuggestionProvider.suggest((Iterable) iterable, suggestionsbuilder1); + }); +@@ -143,7 +147,6 @@ + } + } + +- @Override + public Collection<String> getExamples() { + return EntityArgument.EXAMPLES; + } +@@ -155,38 +158,34 @@ + + public Info() {} + +- @Override +- public void serializeToNetwork(EntityArgument.Info.Template entityargument_info_template, FriendlyByteBuf friendlybytebuf) { ++ public void serializeToNetwork(EntityArgument.Info.Template template, FriendlyByteBuf buffer) { + int i = 0; + +- if (entityargument_info_template.single) { ++ if (template.single) { + i |= 1; + } + +- if (entityargument_info_template.playersOnly) { ++ if (template.playersOnly) { + i |= 2; + } + +- friendlybytebuf.writeByte(i); ++ buffer.writeByte(i); + } + + @Override +- @Override +- public EntityArgument.Info.Template deserializeFromNetwork(FriendlyByteBuf friendlybytebuf) { +- byte b0 = friendlybytebuf.readByte(); ++ public EntityArgument.Info.Template deserializeFromNetwork(FriendlyByteBuf buffer) { ++ byte b0 = buffer.readByte(); + + return new EntityArgument.Info.Template((b0 & 1) != 0, (b0 & 2) != 0); + } + +- @Override +- public void serializeToJson(EntityArgument.Info.Template entityargument_info_template, JsonObject jsonobject) { +- jsonobject.addProperty("amount", entityargument_info_template.single ? "single" : "multiple"); +- jsonobject.addProperty("type", entityargument_info_template.playersOnly ? "players" : "entities"); ++ public void serializeToJson(EntityArgument.Info.Template template, JsonObject json) { ++ json.addProperty("amount", template.single ? "single" : "multiple"); ++ json.addProperty("type", template.playersOnly ? "players" : "entities"); + } + +- @Override +- public EntityArgument.Info.Template unpack(EntityArgument entityargument) { +- return new EntityArgument.Info.Template(entityargument.single, entityargument.playersOnly); ++ public EntityArgument.Info.Template unpack(EntityArgument argument) { ++ return new EntityArgument.Info.Template(argument.single, argument.playersOnly); + } + + public final class Template implements ArgumentTypeInfo.Template<EntityArgument> { +@@ -200,13 +199,11 @@ + } + + @Override +- @Override +- public EntityArgument instantiate(CommandBuildContext commandbuildcontext) { ++ public EntityArgument instantiate(CommandBuildContext context) { + return new EntityArgument(this.single, this.playersOnly); + } + + @Override +- @Override + public ArgumentTypeInfo<EntityArgument, ?> type() { + return Info.this; + } |