Fix NPE for teleport events without target location

Fixes #2111
This commit is contained in:
Joo200 2024-07-22 21:42:44 +02:00
parent 16ea4625c9
commit 8ffc81ad74

View File

@ -350,6 +350,11 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null) {
// The target location for PlayerTeleportEvents can be null.
// Those events will be ignored by the server, so we can ignore them too.
return;
}
Player player = event.getPlayer();
if (com.sk89q.worldguard.bukkit.util.Entities.isNPC(player)) return;
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);