mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-17 21:33:49 -07:00
Fix NPE on null loc for EntityTeleportEvent
EntityTeleportEvent#setTo is marked as nullable and so is the getTo method. This fixes the handling of a null "to" location by treating it the same as the event being cancelled. This is already existing behavior for the EntityPortalEvent (which extends EntityTeleportEvent).
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
public class TeleportCommand {
|
||||
|
||||
@@ -167,7 +173,30 @@
|
||||
@@ -167,7 +173,31 @@
|
||||
float f4 = Mth.wrapDegrees(f2);
|
||||
float f5 = Mth.wrapDegrees(f3);
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
+ Location to = new Location(world.getWorld(), d3, d4, d5, f4, f5);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(target.getBukkitEntity(), target.getBukkitEntity().getLocation(), to);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (event.isCancelled() || event.getTo() == null) { // Paper
|
||||
+ return;
|
||||
+ }
|
||||
+ to = event.getTo(); // Paper - actually track new location
|
||||
+
|
||||
+ d3 = to.getX();
|
||||
+ d4 = to.getY();
|
||||
|
Reference in New Issue
Block a user