Update RemoveMobsListener.java

Prevent null value
This commit is contained in:
DinoFeng 2024-08-19 21:38:48 +08:00 committed by GitHub
parent 09c9e9348b
commit 04745330c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,8 @@ public class RemoveMobsListener extends FlagListener {
|| e.getCause().equals(TeleportCause.SPECTATE)) {
return;
}
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()) {
@ -35,6 +37,8 @@ public class RemoveMobsListener extends FlagListener {
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onUserRespawn(PlayerRespawnEvent e) {
// Only process if flag is active