aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/commands/arguments/EntityArgument.java.patch
blob: 362597edc4c5c36fb1c6bf34277cb773c72ee8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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;
             }