diff --git a/src/main/java/uk/gemwire/bareessentials/commands/CmdSpawn.java b/src/main/java/uk/gemwire/bareessentials/commands/CmdSpawn.java index 1dd2324..a783c19 100644 --- a/src/main/java/uk/gemwire/bareessentials/commands/CmdSpawn.java +++ b/src/main/java/uk/gemwire/bareessentials/commands/CmdSpawn.java @@ -47,8 +47,9 @@ public static int execute(CommandSourceStack player) { player.sendSystemMessage(Component.translatable(Language.getInstance() .getOrDefault("bareessentials.spawn.tospawn"))); // Random teleport = cancel if the destination is unsafe - player.getPlayer().randomTeleport(level.getSharedSpawnPos().getX() + 0.5, level.getSharedSpawnPos().getY(), - level.getSharedSpawnPos().getZ() + 0.5, false); + if (!player.getPlayer().randomTeleport(level.getSharedSpawnPos().getX() + 0.5, level.getSharedSpawnPos().getY(), level.getSharedSpawnPos().getZ() + 0.5, false)) + player.sendSystemMessage(Component.translatable(Language.getInstance().getOrDefault("bareessentials.teleport.unsafe"))); + cd.setCooldownFor(player.getPlayer(), "spawn", level.getGameTime() + (5 * 20 * 60)); } else { player.sendSystemMessage(Component.translatable(Language.getInstance().getOrDefault("bareessentials.cooldown.active"), cd.getRemainingTimeFor(player.getPlayer(), "spawn")/20)); diff --git a/src/main/java/uk/gemwire/bareessentials/commands/CmdTeleportRequest.java b/src/main/java/uk/gemwire/bareessentials/commands/CmdTeleportRequest.java index 544bd2e..1ba4e15 100644 --- a/src/main/java/uk/gemwire/bareessentials/commands/CmdTeleportRequest.java +++ b/src/main/java/uk/gemwire/bareessentials/commands/CmdTeleportRequest.java @@ -91,7 +91,9 @@ public static int accept(CommandContext pSource) { target.sendSystemMessage(Component.translatable(Language.getInstance() .getOrDefault("bareessentials.tpa.inprogress"), Component.translatable(Language.getInstance().getOrDefault("bareessentials.targetyou")) )); - request.sender().randomTeleport(target.getX(), target.getY(), target.getZ(), false); + + if (!request.sender().randomTeleport(target.getX(), target.getY(), target.getZ(), false)) + request.sender().sendSystemMessage(Component.translatable(Language.getInstance().getOrDefault("bareessentials.teleport.unsafe"))); PendingTeleports.removeRequestFrom(request.sender()); diff --git a/src/main/resources/assets/bareessentials/lang/en_us.json b/src/main/resources/assets/bareessentials/lang/en_us.json index 6144059..d394b0e 100644 --- a/src/main/resources/assets/bareessentials/lang/en_us.json +++ b/src/main/resources/assets/bareessentials/lang/en_us.json @@ -9,6 +9,8 @@ "bareessentials.tpa.denied": "%s denied your teleport request.", "bareessentials.tpa.denysuccess": "Incoming teleport request denied.", + "bareessentials.teleport.unsafe": "Destination is unsafe to travel to, teleport cancelled.", + "bareessentials.spawn.setworldspawn.success": "Global spawn point set to: [X: %s, Y: %s, Z: %s]", "bareessentials.spawn.tospawn": "Teleporting to world spawn...",