Disable listening to EntityDamageEvent
This commit is contained in:
1 parent
c5fed56fe9
commit
2c282ab1cf
1 file changed
+12
-12
@@ -60,18 +60,18 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Protect island visits from falling into the void
|
// Protect island visits from falling into the void
|
||||||
@EventHandler(ignoreCancelled = true)
|
// @EventHandler(ignoreCancelled = true)
|
||||||
public void islandVisitProtection(EntityDamageEvent event) {
|
// public void islandVisitProtection(EntityDamageEvent event) {
|
||||||
Entity entity = event.getEntity();
|
// Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player player) {
|
// if (entity instanceof Player player) {
|
||||||
if (!canInteract(event, player)) {
|
// if (!canInteract(event, player)) {
|
||||||
if (event.getCause() == EntityDamageEvent.DamageCause.VOID || player.getLocation().getY() < 0) {
|
// if (event.getCause() == EntityDamageEvent.DamageCause.VOID || player.getLocation().getY() < 0) {
|
||||||
player.setFallDistance(0);
|
// player.setFallDistance(0);
|
||||||
player.teleportAsync(plugin.getServer().getWorlds().get(0).getSpawnLocation());
|
// player.teleportAsync(plugin.getServer().getWorlds().get(0).getSpawnLocation());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
boolean canInteract(Cancellable event, Player player) {
|
boolean canInteract(Cancellable event, Player player) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|||||||
Reference in new issue
Block a user