--- a/net/minecraft/server/commands/EffectCommands.java
+++ b/net/minecraft/server/commands/EffectCommands.java
@@ -4,13 +4,15 @@
 import com.mojang.brigadier.CommandDispatcher;
 import com.mojang.brigadier.arguments.BoolArgumentType;
 import com.mojang.brigadier.arguments.IntegerArgumentType;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import com.mojang.brigadier.builder.RequiredArgumentBuilder;
 import com.mojang.brigadier.exceptions.CommandSyntaxException;
 import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import java.util.Collection;
+import java.util.Iterator;
 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;
@@ -22,208 +24,112 @@
 import net.minecraft.world.entity.LivingEntity;
 
 public class EffectCommands {
+
     private static final SimpleCommandExceptionType ERROR_GIVE_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.give.failed"));
-    private static final SimpleCommandExceptionType ERROR_CLEAR_EVERYTHING_FAILED = new SimpleCommandExceptionType(
-        Component.translatable("commands.effect.clear.everything.failed")
-    );
-    private static final SimpleCommandExceptionType ERROR_CLEAR_SPECIFIC_FAILED = new SimpleCommandExceptionType(
-        Component.translatable("commands.effect.clear.specific.failed")
-    );
+    private static final SimpleCommandExceptionType ERROR_CLEAR_EVERYTHING_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.clear.everything.failed"));
+    private static final SimpleCommandExceptionType ERROR_CLEAR_SPECIFIC_FAILED = new SimpleCommandExceptionType(Component.translatable("commands.effect.clear.specific.failed"));
+
+    public EffectCommands() {}
 
     public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext registryAccess) {
-        dispatcher.register(
-            Commands.literal("effect")
-                .requires(source -> source.hasPermission(2))
-                .then(
-                    Commands.literal("clear")
-                        .executes(context -> clearEffects(context.getSource(), ImmutableList.of(context.getSource().getEntityOrException())))
-                        .then(
-                            Commands.argument("targets", EntityArgument.entities())
-                                .executes(context -> clearEffects(context.getSource(), EntityArgument.getEntities(context, "targets")))
-                                .then(
-                                    Commands.argument("effect", ResourceArgument.resource(registryAccess, Registries.MOB_EFFECT))
-                                        .executes(
-                                            context -> clearEffect(
-                                                    context.getSource(),
-                                                    EntityArgument.getEntities(context, "targets"),
-                                                    ResourceArgument.getMobEffect(context, "effect")
-                                                )
-                                        )
-                                )
-                        )
-                )
-                .then(
-                    Commands.literal("give")
-                        .then(
-                            Commands.argument("targets", EntityArgument.entities())
-                                .then(
-                                    Commands.argument("effect", ResourceArgument.resource(registryAccess, Registries.MOB_EFFECT))
-                                        .executes(
-                                            context -> giveEffect(
-                                                    context.getSource(),
-                                                    EntityArgument.getEntities(context, "targets"),
-                                                    ResourceArgument.getMobEffect(context, "effect"),
-                                                    null,
-                                                    0,
-                                                    true
-                                                )
-                                        )
-                                        .then(
-                                            Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000))
-                                                .executes(
-                                                    context -> giveEffect(
-                                                            context.getSource(),
-                                                            EntityArgument.getEntities(context, "targets"),
-                                                            ResourceArgument.getMobEffect(context, "effect"),
-                                                            IntegerArgumentType.getInteger(context, "seconds"),
-                                                            0,
-                                                            true
-                                                        )
-                                                )
-                                                .then(
-                                                    Commands.argument("amplifier", IntegerArgumentType.integer(0, 255))
-                                                        .executes(
-                                                            context -> giveEffect(
-                                                                    context.getSource(),
-                                                                    EntityArgument.getEntities(context, "targets"),
-                                                                    ResourceArgument.getMobEffect(context, "effect"),
-                                                                    IntegerArgumentType.getInteger(context, "seconds"),
-                                                                    IntegerArgumentType.getInteger(context, "amplifier"),
-                                                                    true
-                                                                )
-                                                        )
-                                                        .then(
-                                                            Commands.argument("hideParticles", BoolArgumentType.bool())
-                                                                .executes(
-                                                                    context -> giveEffect(
-                                                                            context.getSource(),
-                                                                            EntityArgument.getEntities(context, "targets"),
-                                                                            ResourceArgument.getMobEffect(context, "effect"),
-                                                                            IntegerArgumentType.getInteger(context, "seconds"),
-                                                                            IntegerArgumentType.getInteger(context, "amplifier"),
-                                                                            !BoolArgumentType.getBool(context, "hideParticles")
-                                                                        )
-                                                                )
-                                                        )
-                                                )
-                                        )
-                                        .then(
-                                            Commands.literal("infinite")
-                                                .executes(
-                                                    context -> giveEffect(
-                                                            context.getSource(),
-                                                            EntityArgument.getEntities(context, "targets"),
-                                                            ResourceArgument.getMobEffect(context, "effect"),
-                                                            -1,
-                                                            0,
-                                                            true
-                                                        )
-                                                )
-                                                .then(
-                                                    Commands.argument("amplifier", IntegerArgumentType.integer(0, 255))
-                                                        .executes(
-                                                            context -> giveEffect(
-                                                                    context.getSource(),
-                                                                    EntityArgument.getEntities(context, "targets"),
-                                                                    ResourceArgument.getMobEffect(context, "effect"),
-                                                                    -1,
-                                                                    IntegerArgumentType.getInteger(context, "amplifier"),
-                                                                    true
-                                                                )
-                                                        )
-                                                        .then(
-                                                            Commands.argument("hideParticles", BoolArgumentType.bool())
-                                                                .executes(
-                                                                    context -> giveEffect(
-                                                                            context.getSource(),
-                                                                            EntityArgument.getEntities(context, "targets"),
-                                                                            ResourceArgument.getMobEffect(context, "effect"),
-                                                                            -1,
-                                                                            IntegerArgumentType.getInteger(context, "amplifier"),
-                                                                            !BoolArgumentType.getBool(context, "hideParticles")
-                                                                        )
-                                                                )
-                                                        )
-                                                )
-                                        )
-                                )
-                        )
-                )
-        );
+        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 EffectCommands.clearEffects((CommandSourceStack) commandcontext.getSource(), ImmutableList.of(((CommandSourceStack) commandcontext.getSource()).getEntityOrException()));
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("targets", EntityArgument.entities()).executes((commandcontext) -> {
+            return EffectCommands.clearEffects((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"));
+        })).then(net.minecraft.commands.Commands.argument("effect", ResourceArgument.resource(registryAccess, Registries.MOB_EFFECT)).executes((commandcontext) -> {
+            return EffectCommands.clearEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"));
+        }))))).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(registryAccess, Registries.MOB_EFFECT)).executes((commandcontext) -> {
+            return EffectCommands.giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), (Integer) null, 0, true);
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("seconds", IntegerArgumentType.integer(1, 1000000)).executes((commandcontext) -> {
+            return EffectCommands.giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), 0, true);
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
+            return EffectCommands.giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), IntegerArgumentType.getInteger(commandcontext, "seconds"), IntegerArgumentType.getInteger(commandcontext, "amplifier"), true);
+        })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
+            return EffectCommands.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) net.minecraft.commands.Commands.literal("infinite").executes((commandcontext) -> {
+            return EffectCommands.giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, 0, true);
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("amplifier", IntegerArgumentType.integer(0, 255)).executes((commandcontext) -> {
+            return EffectCommands.giveEffect((CommandSourceStack) commandcontext.getSource(), EntityArgument.getEntities(commandcontext, "targets"), ResourceArgument.getMobEffect(commandcontext, "effect"), -1, IntegerArgumentType.getInteger(commandcontext, "amplifier"), true);
+        })).then(net.minecraft.commands.Commands.argument("hideParticles", BoolArgumentType.bool()).executes((commandcontext) -> {
+            return EffectCommands.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 source,
-        Collection<? extends Entity> targets,
-        Holder<MobEffect> statusEffect,
-        @Nullable Integer seconds,
-        int amplifier,
-        boolean showParticles
-    ) throws CommandSyntaxException {
-        MobEffect mobEffect = statusEffect.value();
-        int i = 0;
-        int j;
+    private static int giveEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> statusEffect, @Nullable Integer seconds, int amplifier, boolean showParticles) throws CommandSyntaxException {
+        MobEffect mobeffectlist = (MobEffect) statusEffect.value();
+        int j = 0;
+        int k;
+
         if (seconds != null) {
-            if (mobEffect.isInstantenous()) {
-                j = seconds;
+            if (mobeffectlist.isInstantenous()) {
+                k = seconds;
             } else if (seconds == -1) {
-                j = -1;
+                k = -1;
             } else {
-                j = seconds * 20;
+                k = seconds * 20;
             }
-        } else if (mobEffect.isInstantenous()) {
-            j = 1;
+        } else if (mobeffectlist.isInstantenous()) {
+            k = 1;
         } else {
-            j = 600;
+            k = 600;
         }
 
-        for (Entity entity : targets) {
+        Iterator iterator = targets.iterator();
+
+        while (iterator.hasNext()) {
+            Entity entity = (Entity) iterator.next();
+
             if (entity instanceof LivingEntity) {
-                MobEffectInstance mobEffectInstance = new MobEffectInstance(statusEffect, j, amplifier, false, showParticles);
-                if (((LivingEntity)entity).addEffect(mobEffectInstance, source.getEntity())) {
-                    i++;
+                MobEffectInstance mobeffect = new MobEffectInstance(statusEffect, k, amplifier, false, showParticles);
+
+                if (((LivingEntity) entity).addEffect(mobeffect, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
+                    ++j;
                 }
             }
         }
 
-        if (i == 0) {
-            throw ERROR_GIVE_FAILED.create();
+        if (j == 0) {
+            throw EffectCommands.ERROR_GIVE_FAILED.create();
         } else {
             if (targets.size() == 1) {
-                source.sendSuccess(
-                    () -> Component.translatable(
-                            "commands.effect.give.success.single", mobEffect.getDisplayName(), targets.iterator().next().getDisplayName(), j / 20
-                        ),
-                    true
-                );
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.give.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName(), k / 20);
+                }, true);
             } else {
-                source.sendSuccess(
-                    () -> Component.translatable("commands.effect.give.success.multiple", mobEffect.getDisplayName(), targets.size(), j / 20), true
-                );
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.give.success.multiple", mobeffectlist.getDisplayName(), targets.size(), k / 20);
+                }, true);
             }
 
-            return i;
+            return j;
         }
     }
 
     private static int clearEffects(CommandSourceStack source, Collection<? extends Entity> targets) throws CommandSyntaxException {
         int i = 0;
+        Iterator iterator = targets.iterator();
 
-        for (Entity entity : targets) {
-            if (entity instanceof LivingEntity && ((LivingEntity)entity).removeAllEffects()) {
-                i++;
+        while (iterator.hasNext()) {
+            Entity entity = (Entity) iterator.next();
+
+            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
+                ++i;
             }
         }
 
         if (i == 0) {
-            throw ERROR_CLEAR_EVERYTHING_FAILED.create();
+            throw EffectCommands.ERROR_CLEAR_EVERYTHING_FAILED.create();
         } else {
             if (targets.size() == 1) {
-                source.sendSuccess(
-                    () -> Component.translatable("commands.effect.clear.everything.success.single", targets.iterator().next().getDisplayName()), true
-                );
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.everything.success.single", ((Entity) targets.iterator().next()).getDisplayName());
+                }, true);
             } else {
-                source.sendSuccess(() -> Component.translatable("commands.effect.clear.everything.success.multiple", targets.size()), true);
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.everything.success.multiple", targets.size());
+                }, true);
             }
 
             return i;
@@ -231,29 +137,29 @@
     }
 
     private static int clearEffect(CommandSourceStack source, Collection<? extends Entity> targets, Holder<MobEffect> statusEffect) throws CommandSyntaxException {
-        MobEffect mobEffect = statusEffect.value();
+        MobEffect mobeffectlist = (MobEffect) statusEffect.value();
         int i = 0;
+        Iterator iterator = targets.iterator();
 
-        for (Entity entity : targets) {
-            if (entity instanceof LivingEntity && ((LivingEntity)entity).removeEffect(statusEffect)) {
-                i++;
+        while (iterator.hasNext()) {
+            Entity entity = (Entity) iterator.next();
+
+            if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(statusEffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
+                ++i;
             }
         }
 
         if (i == 0) {
-            throw ERROR_CLEAR_SPECIFIC_FAILED.create();
+            throw EffectCommands.ERROR_CLEAR_SPECIFIC_FAILED.create();
         } else {
             if (targets.size() == 1) {
-                source.sendSuccess(
-                    () -> Component.translatable(
-                            "commands.effect.clear.specific.success.single", mobEffect.getDisplayName(), targets.iterator().next().getDisplayName()
-                        ),
-                    true
-                );
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.specific.success.single", mobeffectlist.getDisplayName(), ((Entity) targets.iterator().next()).getDisplayName());
+                }, true);
             } else {
-                source.sendSuccess(
-                    () -> Component.translatable("commands.effect.clear.specific.success.multiple", mobEffect.getDisplayName(), targets.size()), true
-                );
+                source.sendSuccess(() -> {
+                    return Component.translatable("commands.effect.clear.specific.success.multiple", mobeffectlist.getDisplayName(), targets.size());
+                }, true);
             }
 
             return i;
