Skip to content

Commit

Permalink
Adjust how tp is prevented. #70
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jun 23, 2024
1 parent ab10887 commit cd5936d
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ public void onPlayerTeleport(PlayerTeleportEvent e) {
) {
return;
}

User u = User.getInstance(e.getPlayer());
// If the to-location is outside the box, cancel it
if (e.getTo() != null) {
Island i = addon.getIslands().getIsland(e.getFrom().getWorld(), u);
if (i == null || !i.onIsland(e.getTo())) {
u.sendMessage("boxed.general.errors.no-teleport-outside");
e.setCancelled(true);
}
addon.getIslands().getIslandAt(e.getTo()).ifPresent(i -> {
if (!i.onIsland(e.getTo())) {
u.sendMessage("boxed.general.errors.no-teleport-outside");
e.setCancelled(true);
}
});
}
}

Expand All @@ -77,7 +78,7 @@ public void onEnderPearlLand(ProjectileHitEvent e) {
if (is == null) {
return; // Nothing to do
}

// Get the box that the player is in
addon.getIslands().getIslandAt(u.getLocation()).ifPresent(fromIsland -> {
// Check that it is their box
Expand Down

0 comments on commit cd5936d

Please sign in to comment.