--- a/net/minecraft/server/commands/SetSpawnCommand.java
+++ b/net/minecraft/server/commands/SetSpawnCommand.java
@@ -1,10 +1,12 @@
 package net.minecraft.server.commands;
 
 import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import com.mojang.brigadier.builder.RequiredArgumentBuilder;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import net.minecraft.commands.CommandSourceStack;
-import net.minecraft.commands.Commands;
 import net.minecraft.commands.arguments.AngleArgument;
 import net.minecraft.commands.arguments.EntityArgument;
 import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
@@ -15,75 +17,55 @@
 import net.minecraft.world.level.Level;
 
 public class SetSpawnCommand {
+
+    public SetSpawnCommand() {}
+
     public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
-        dispatcher.register(
-            Commands.literal("spawnpoint")
-                .requires(source -> source.hasPermission(2))
-                .executes(
-                    context -> setSpawn(
-                            context.getSource(),
-                            Collections.singleton(context.getSource().getPlayerOrException()),
-                            BlockPos.containing(context.getSource().getPosition()),
-                            0.0F
-                        )
-                )
-                .then(
-                    Commands.argument("targets", EntityArgument.players())
-                        .executes(
-                            context -> setSpawn(
-                                    context.getSource(),
-                                    EntityArgument.getPlayers(context, "targets"),
-                                    BlockPos.containing(context.getSource().getPosition()),
-                                    0.0F
-                                )
-                        )
-                        .then(
-                            Commands.argument("pos", BlockPosArgument.blockPos())
-                                .executes(
-                                    context -> setSpawn(
-                                            context.getSource(),
-                                            EntityArgument.getPlayers(context, "targets"),
-                                            BlockPosArgument.getSpawnablePos(context, "pos"),
-                                            0.0F
-                                        )
-                                )
-                                .then(
-                                    Commands.argument("angle", AngleArgument.angle())
-                                        .executes(
-                                            context -> setSpawn(
-                                                    context.getSource(),
-                                                    EntityArgument.getPlayers(context, "targets"),
-                                                    BlockPosArgument.getSpawnablePos(context, "pos"),
-                                                    AngleArgument.getAngle(context, "angle")
-                                                )
-                                        )
-                                )
-                        )
-                )
-        );
+        dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("spawnpoint").requires((commandlistenerwrapper) -> {
+            return commandlistenerwrapper.hasPermission(2);
+        })).executes((commandcontext) -> {
+            return SetSpawnCommand.setSpawn((CommandSourceStack) commandcontext.getSource(), Collections.singleton(((CommandSourceStack) commandcontext.getSource()).getPlayerOrException()), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()), 0.0F);
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("targets", EntityArgument.players()).executes((commandcontext) -> {
+            return SetSpawnCommand.setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()), 0.0F);
+        })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+            return SetSpawnCommand.setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPosArgument.getSpawnablePos(commandcontext, "pos"), 0.0F);
+        })).then(net.minecraft.commands.Commands.argument("angle", AngleArgument.angle()).executes((commandcontext) -> {
+            return SetSpawnCommand.setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPosArgument.getSpawnablePos(commandcontext, "pos"), AngleArgument.getAngle(commandcontext, "angle"));
+        })))));
     }
 
     private static int setSpawn(CommandSourceStack source, Collection<ServerPlayer> targets, BlockPos pos, float angle) {
-        ResourceKey<Level> resourceKey = source.getLevel().dimension();
+        ResourceKey<Level> resourcekey = source.getLevel().dimension();
+        Iterator iterator = targets.iterator();
 
-        for (ServerPlayer serverPlayer : targets) {
-            serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false);
+        final Collection<ServerPlayer> actualTargets = new java.util.ArrayList<>(); // Paper - Add PlayerSetSpawnEvent
+        while (iterator.hasNext()) {
+            ServerPlayer entityplayer = (ServerPlayer) iterator.next();
+
+            // Paper start - Add PlayerSetSpawnEvent
+            if (entityplayer.setRespawnPosition(resourcekey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) {
+                actualTargets.add(entityplayer);
+            }
+            // Paper end - Add PlayerSetSpawnEvent
+        }
+        // Paper start - Add PlayerSetSpawnEvent
+        if (actualTargets.isEmpty()) {
+            return 0;
         }
+        // Paper end - Add PlayerSetSpawnEvent
 
-        String string = resourceKey.location().toString();
-        if (targets.size() == 1) {
-            source.sendSuccess(
-                () -> Component.translatable(
-                        "commands.spawnpoint.success.single", pos.getX(), pos.getY(), pos.getZ(), angle, string, targets.iterator().next().getDisplayName()
-                    ),
-                true
-            );
+        String s = resourcekey.location().toString();
+
+        if (actualTargets.size() == 1) { // Paper - Add PlayerSetSpawnEvent
+            source.sendSuccess(() -> {
+                return Component.translatable("commands.spawnpoint.success.single", pos.getX(), pos.getY(), pos.getZ(), angle, s, ((ServerPlayer) actualTargets.iterator().next()).getDisplayName()); // Paper - Add PlayerSetSpawnEvent
+            }, true);
         } else {
-            source.sendSuccess(
-                () -> Component.translatable("commands.spawnpoint.success.multiple", pos.getX(), pos.getY(), pos.getZ(), angle, string, targets.size()), true
-            );
+            source.sendSuccess(() -> {
+                return Component.translatable("commands.spawnpoint.success.multiple", pos.getX(), pos.getY(), pos.getZ(), angle, s, actualTargets.size()); // Paper - Add PlayerSetSpawnEvent
+            }, true);
         }
 
-        return targets.size();
+        return actualTargets.size(); // Paper - Add PlayerSetSpawnEvent
     }
 }
