mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 10:44:39 +01:00
43 lines
2.3 KiB
Diff
43 lines
2.3 KiB
Diff
--- a/net/minecraft/server/commands/SetSpawnCommand.java
|
|
+++ b/net/minecraft/server/commands/SetSpawnCommand.java
|
|
@@ -66,24 +_,34 @@
|
|
private static int setSpawn(CommandSourceStack source, Collection<ServerPlayer> targets, BlockPos pos, float angle) {
|
|
ResourceKey<Level> resourceKey = source.getLevel().dimension();
|
|
|
|
+ final Collection<ServerPlayer> 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
|
|
}
|
|
}
|