--- a/net/minecraft/server/commands/SetSpawnCommand.java +++ b/net/minecraft/server/commands/SetSpawnCommand.java @@ -66,24 +_,34 @@ private static int setSpawn(CommandSourceStack source, Collection targets, BlockPos pos, float angle) { ResourceKey resourceKey = source.getLevel().dimension(); + final Collection actualTargets = new java.util.ArrayList<>(); // Paper - Add PlayerSetSpawnEvent for (ServerPlayer serverPlayer : targets) { - serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false); - } + // Paper start - Add PlayerSetSpawnEvent + if (serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) { + actualTargets.add(serverPlayer); + } + // 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) { + if (actualTargets.size() == 1) { // Paper - Add PlayerSetSpawnEvent source.sendSuccess( () -> Component.translatable( - "commands.spawnpoint.success.single", pos.getX(), pos.getY(), pos.getZ(), angle, string, targets.iterator().next().getDisplayName() + "commands.spawnpoint.success.single", pos.getX(), pos.getY(), pos.getZ(), angle, string, 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 + () -> Component.translatable("commands.spawnpoint.success.multiple", pos.getX(), pos.getY(), pos.getZ(), angle, string, actualTargets.size()), true // Paper - Add PlayerSetSpawnEvent ); } - return targets.size(); + return actualTargets.size(); // Paper - Add PlayerSetSpawnEvent } }