Skip to content

Commit

Permalink
protect world spawn column rather than bubble
Browse files Browse the repository at this point in the history
this will help prevent vertical grief
  • Loading branch information
TehBrian committed Oct 27, 2023
1 parent 2464b55 commit d0d975f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onInteract(final PlayerInteractEvent event) {

@EventHandler(priority = EventPriority.LOW)
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player player) {
if (event.getDamager() instanceof final Player player) {
this.handle(event, player, event.getEntity().getLocation());
}
}
Expand Down Expand Up @@ -151,8 +151,11 @@ private <T extends Cancellable> void handle(
}

private boolean isWithinWorldSpawn(final Location location) {
final Location worldSpawn = location.getWorld().getSpawnLocation();
return location.distanceSquared(worldSpawn) < SPAWN_PROTECTION_RADIUS_SQUARED;
final Location loc1 = location.clone();
loc1.setY(0);
final Location loc2 = location.getWorld().getSpawnLocation();
loc2.setY(0);
return loc1.distanceSquared(loc2) < SPAWN_PROTECTION_RADIUS_SQUARED;
}

}

0 comments on commit d0d975f

Please sign in to comment.