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
|
--- a/net/minecraft/server/commands/SetSpawnCommand.java
+++ b/net/minecraft/server/commands/SetSpawnCommand.java
@@ -7,7 +7,6 @@
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;
@@ -21,42 +20,42 @@
public SetSpawnCommand() {}
- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) {
- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("spawnpoint").requires((commandsourcestack) -> {
- return commandsourcestack.hasPermission(2);
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
+ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("spawnpoint").requires((commandlistenerwrapper) -> {
+ return commandlistenerwrapper.hasPermission(2);
})).executes((commandcontext) -> {
return setSpawn((CommandSourceStack) commandcontext.getSource(), Collections.singleton(((CommandSourceStack) commandcontext.getSource()).getPlayerOrException()), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()), 0.0F);
- })).then(((RequiredArgumentBuilder) Commands.argument("targets", EntityArgument.players()).executes((commandcontext) -> {
+ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("targets", EntityArgument.players()).executes((commandcontext) -> {
return setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPos.containing(((CommandSourceStack) commandcontext.getSource()).getPosition()), 0.0F);
- })).then(((RequiredArgumentBuilder) Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
+ })).then(((RequiredArgumentBuilder) net.minecraft.commands.Commands.argument("pos", BlockPosArgument.blockPos()).executes((commandcontext) -> {
return setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPosArgument.getSpawnablePos(commandcontext, "pos"), 0.0F);
- })).then(Commands.argument("angle", AngleArgument.angle()).executes((commandcontext) -> {
+ })).then(net.minecraft.commands.Commands.argument("angle", AngleArgument.angle()).executes((commandcontext) -> {
return setSpawn((CommandSourceStack) commandcontext.getSource(), EntityArgument.getPlayers(commandcontext, "targets"), BlockPosArgument.getSpawnablePos(commandcontext, "pos"), AngleArgument.getAngle(commandcontext, "angle"));
})))));
}
- private static int setSpawn(CommandSourceStack commandsourcestack, Collection<ServerPlayer> collection, BlockPos blockpos, float f) {
- ResourceKey<Level> resourcekey = commandsourcestack.getLevel().dimension();
- Iterator iterator = collection.iterator();
+ private static int setSpawn(CommandSourceStack source, Collection<ServerPlayer> targets, BlockPos pos, float angle) {
+ ResourceKey<Level> resourcekey = source.getLevel().dimension();
+ Iterator iterator = targets.iterator();
while (iterator.hasNext()) {
- ServerPlayer serverplayer = (ServerPlayer) iterator.next();
+ ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- serverplayer.setRespawnPosition(resourcekey, blockpos, f, true, false);
+ entityplayer.setRespawnPosition(resourcekey, pos, angle, true, false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit
}
String s = resourcekey.location().toString();
- if (collection.size() == 1) {
- commandsourcestack.sendSuccess(() -> {
- return Component.translatable("commands.spawnpoint.success.single", blockpos.getX(), blockpos.getY(), blockpos.getZ(), f, s, ((ServerPlayer) collection.iterator().next()).getDisplayName());
+ if (targets.size() == 1) {
+ source.sendSuccess(() -> {
+ return Component.translatable("commands.spawnpoint.success.single", pos.getX(), pos.getY(), pos.getZ(), angle, s, ((ServerPlayer) targets.iterator().next()).getDisplayName());
}, true);
} else {
- commandsourcestack.sendSuccess(() -> {
- return Component.translatable("commands.spawnpoint.success.multiple", blockpos.getX(), blockpos.getY(), blockpos.getZ(), f, s, collection.size());
+ source.sendSuccess(() -> {
+ return Component.translatable("commands.spawnpoint.success.multiple", pos.getX(), pos.getY(), pos.getZ(), angle, s, targets.size());
}, true);
}
- return collection.size();
+ return targets.size();
}
}
|