aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/commands/EffectCommands.java.patch
blob: 1af9a53d4d6a821f0f4b105e567093427b28e92c (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
--- a/net/minecraft/server/commands/EffectCommands.java
+++ b/net/minecraft/server/commands/EffectCommands.java
@@ -13,7 +13,6 @@
 import javax.annotation.Nullable;
 import net.minecraft.commands.CommandBuildContext;
 import net.minecraft.commands.CommandSourceStack;
-import net.minecraft.commands.Commands;
 import net.minecraft.commands.arguments.EntityArgument;
 import net.minecraft.commands.arguments.ResourceArgument;
 import net.minecraft.core.Holder;
@@ -32,60 +31,60 @@
 
     public EffectCommands() {}
 
-    public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher, CommandBuildContext commandbuildcontext) {
-        commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("effect").requires((commandsourcestack) -> {
-            return commandsourcestack.hasPermission(2);
-        })).then(((LiteralArgumentBuilder) Commands.literal("clear").executes((commandcontext) -> {
+    public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) {
+        dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("effect").requires((commandlistenerwrapper) -> {
+            return commandlistenerwrapper.hasPermission(2);
+        })).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("clear").executes((commandcontext) -> {
             return clearEffects((CommandSourceStack) commandcontext.getSource(), ImmutableList.of(((CommandSourceStack) commandcontext.getSource()).getEntityOrException()));
-        })).then(((RequiredArgumentBuilder) Commands.argument("targets", EntityArgument.entities()).executes((commandcontext) -> {
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("targets", EntityArgument.entities()).executes((commandcontext) -> {
             return clearEffects((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"));
-        })).then(Commands.argument("effect", ResourceArgument.resource(commandbuildcontext, Registries.MOB_EFFECT)).executes((commandcontext) -> {
+        })).then(net.minecraft.commands.Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)).executes((commandcontext) -> {
             return clearEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"));
-        }))))).then(Commands.literal("give").then(Commands.argument("targets", EntityArgument.entities()).then(((RequiredArgumentBuilder) ((RequiredArgumentBuilder) Commands.argument("effect", ResourceArgument.resource(commandbuildcontext, Registries.MOB_EFFECT)).executes((commandcontext) -> {
+        }))))).then(net.minecraft.commands.Commands.literal("give").then(net.minecraft.commands.Commands.argument("targets", EntityArgument.entities()).then(((RequiredArgumentBuilder) ((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("effect", ResourceArgument.resource(context, Registries.MOB_EFFECT)).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), (Integer) null, 0, true);
-        })).then(((RequiredArgumentBuilder) Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000)).executes((commandcontext) -> {
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000)).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), 0, true);
-        })).then(((RequiredArgumentBuilder) Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), IntegerArgumentType.getInteger(commandcontext, "amplifier"), true);
-        })).then(Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
+        })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), IntegerArgumentType.getInteger(commandcontext, "amplifier"), !BoolArgumentType.getBool(commandcontext, "hideParticles"));
-        }))))).then(((LiteralArgumentBuilder) Commands.literal("infinite").executes((commandcontext) -> {
+        }))))).then(((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("infinite").executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, 0, true);
-        })).then(((RequiredArgumentBuilder) Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, IntegerArgumentType.getInteger(commandcontext, "amplifier"), true);
-        })).then(Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
+        })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
             return giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, IntegerArgumentType.getInteger(commandcontext, "amplifier"), !BoolArgumentType.getBool(commandcontext, "hideParticles"));
         }))))))));
     }
 
-    private static int giveEffect(CommandSourceStack commandsourcestack, Collection<? extends Entity> collection, Holder<MobEffect> holder, @Nullable Integer integer, int i, boolean flag) throws CommandSyntaxException {
-        MobEffect mobeffect = (MobEffect) holder.value();
+    private static int giveEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> effect, @Nullable Integer seconds, int amplifier, boolean showParticles) throws CommandSyntaxException {
+        MobEffect mobeffectlist = (MobEffect) effect.value();
         int j = 0;
         int k;
 
-        if (integer != null) {
-            if (mobeffect.isInstantenous()) {
-                k = integer;
-            } else if (integer == -1) {
+        if (seconds != null) {
+            if (mobeffectlist.isInstantenous()) {
+                k = seconds;
+            } else if (seconds == -1) {
                 k = -1;
             } else {
-                k = integer * 20;
+                k = seconds * 20;
             }
-        } else if (mobeffect.isInstantenous()) {
+        } else if (mobeffectlist.isInstantenous()) {
             k = 1;
         } else {
             k = 600;
         }
 
-        Iterator iterator = collection.iterator();
+        Iterator iterator = targets.iterator();
 
         while (iterator.hasNext()) {
             Entity entity = (Entity) iterator.next();
 
             if (entity instanceof LivingEntity) {
-                MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, k, i, false, flag);
+                MobEffectInstance mobeffect = new MobEffectInstance(mobeffectlist, k, amplifier, false, showParticles);
 
-                if (((LivingEntity) entity).addEffect(mobeffectinstance, commandsourcestack.getEntity())) {
+                if (((LivingEntity) entity).addEffect(mobeffect, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
                     ++j;
                 }
             }
@@ -94,13 +93,13 @@
         if (j == 0) {
             throw EffectCommands.ERROR_GIVE_FAILED.create();
         } else {
-            if (collection.size() == 1) {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.give.success.single", mobeffect.getDisplayName(), ((Entity) collection.iterator().next()).getDisplayName(), k / 20);
+            if (targets.size() == 1) {
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.give.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName(), k / 20);
                 }, true);
             } else {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.give.success.multiple", mobeffect.getDisplayName(), collection.size(), k / 20);
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.give.success.multiple", mobeffectlist.getDisplayName(), targets.size(), k / 20);
                 }, true);
             }
 
@@ -108,14 +107,14 @@
         }
     }
 
-    private static int clearEffects(CommandSourceStack commandsourcestack, Collection<? extends Entity> collection) throws CommandSyntaxException {
+    private static int clearEffects(CommandSourceStack source, Collection<? extends Entity> targets) throws CommandSyntaxException {
         int i = 0;
-        Iterator iterator = collection.iterator();
+        Iterator iterator = targets.iterator();
 
         while (iterator.hasNext()) {
             Entity entity = (Entity) iterator.next();
 
-            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeAllEffects()) {
+            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
                 ++i;
             }
         }
@@ -123,13 +122,13 @@
         if (i == 0) {
             throw EffectCommands.ERROR_CLEAR_EVERYTHING_FAILED.create();
         } else {
-            if (collection.size() == 1) {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.clear.everything.success.single", ((Entity) collection.iterator().next()).getDisplayName());
+            if (targets.size() == 1) {
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.everything.success.single", ((Entity) targets.iterator().next()).getDisplayName());
                 }, true);
             } else {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.clear.everything.success.multiple", collection.size());
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.everything.success.multiple", targets.size());
                 }, true);
             }
 
@@ -137,15 +136,15 @@
         }
     }
 
-    private static int clearEffect(CommandSourceStack commandsourcestack, Collection<? extends Entity> collection, Holder<MobEffect> holder) throws CommandSyntaxException {
-        MobEffect mobeffect = (MobEffect) holder.value();
+    private static int clearEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> effect) throws CommandSyntaxException {
+        MobEffect mobeffectlist = (MobEffect) effect.value();
         int i = 0;
-        Iterator iterator = collection.iterator();
+        Iterator iterator = targets.iterator();
 
         while (iterator.hasNext()) {
             Entity entity = (Entity) iterator.next();
 
-            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(mobeffect)) {
+            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
                 ++i;
             }
         }
@@ -153,13 +152,13 @@
         if (i == 0) {
             throw EffectCommands.ERROR_CLEAR_SPECIFIC_FAILED.create();
         } else {
-            if (collection.size() == 1) {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.clear.specific.success.single", mobeffect.getDisplayName(), ((Entity) collection.iterator().next()).getDisplayName());
+            if (targets.size() == 1) {
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.specific.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName());
                 }, true);
             } else {
-                commandsourcestack.sendSuccess(() -> {
-                    return Component.translatable("commands.effect.clear.specific.success.multiple", mobeffect.getDisplayName(), collection.size());
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.specific.success.multiple", mobeffectlist.getDisplayName(), targets.size());
                 }, true);
             }