Skip to content

Commit

Permalink
Merge pull request #2474 from DinoFengz/patch-1
Browse files Browse the repository at this point in the history
Update RemoveMobsListener.java
  • Loading branch information
tastybento authored Aug 21, 2024
2 parents fdbb248 + 9305bf7 commit 6cbbdad
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ public void onUserTeleport(PlayerTeleportEvent e) {
|| e.getCause().equals(TeleportCause.SPECTATE)) {
return;
}
// Return if this is a small teleport
if (e.getTo().getWorld().equals(e.getPlayer().getWorld()) &&
e.getTo().distanceSquared(e.getPlayer().getLocation()) < getPlugin().getSettings().getClearRadius() * getPlugin().getSettings().getClearRadius()) {
return;
}
// Only process if flag is active
if (getIslands().locationIsOnIsland(e.getPlayer(), e.getTo()) && Flags.REMOVE_MOBS.isSetForWorld(e.getTo().getWorld())) {
Bukkit.getScheduler().runTask(getPlugin(), () -> getIslands().clearArea(e.getTo()));

if(e.getTo() != null) {
// Return if this is a small teleport
if (e.getTo().getWorld().equals(e.getPlayer().getWorld()) &&
e.getTo().distanceSquared(e.getPlayer().getLocation()) < getPlugin().getSettings().getClearRadius() * getPlugin().getSettings().getClearRadius()) {
return;
}

// Only process if flag is active
if (getIslands().locationIsOnIsland(e.getPlayer(), e.getTo()) && Flags.REMOVE_MOBS.isSetForWorld(e.getTo().getWorld())) {
Bukkit.getScheduler().runTask(getPlugin(), () -> getIslands().clearArea(e.getTo()));
}
}

}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
Expand Down

0 comments on commit 6cbbdad

Please sign in to comment.