Skip to content

Commit

Permalink
Explain teleport cancel when unsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCurle committed Dec 24, 2023
1 parent 9c5fad8 commit 3f2ea65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public static int accept(CommandContext<CommandSourceStack> 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());

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/bareessentials/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",

Expand Down

0 comments on commit 3f2ea65

Please sign in to comment.