flewkey
/
mc.2a03.party
Archived
1
0
Fork 0

Verify spawn exists before teleporting

Signed-off-by: Ryan Fox <flewkey@2a03.party>
This commit is contained in:
Ryan Fox 2019-07-27 21:54:35 +00:00
parent 4533e486dc
commit 8bb516465d
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,14 @@ public class SpawnCommand {
public static void register(CommandDispatcher<CommandSource> dispatcher) { public static void register(CommandDispatcher<CommandSource> dispatcher) {
LiteralArgumentBuilder<CommandSource> literalargumentbuilder = Commands.func_197057_a("spawn").executes((source) -> { LiteralArgumentBuilder<CommandSource> literalargumentbuilder = Commands.func_197057_a("spawn").executes((source) -> {
PlayerPosition position = Config.parsePosition(Config.getData("spawn")); PlayerPosition position = Config.parsePosition(Config.getData("spawn"));
if (position.world == null) {
if (source.getSource().func_197034_c(2)) {
source.getSource().func_197030_a(new TranslationTextComponent("Spawn not found, do /spawn set"), false);
} else {
source.getSource().func_197030_a(new TranslationTextComponent("Spawn not found, ask an admin to set it"), false);
}
return 1;
}
((ServerPlayerEntity)source.getSource().func_197035_h()).func_200619_a(position.world, position.x, position.y, position.z, position.yaw, position.pitch); ((ServerPlayerEntity)source.getSource().func_197035_h()).func_200619_a(position.world, position.x, position.y, position.z, position.yaw, position.pitch);
source.getSource().func_197030_a(new TranslationTextComponent("Teleported to the spawn point"), true); source.getSource().func_197030_a(new TranslationTextComponent("Teleported to the spawn point"), true);
return 1; return 1;