mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
Always return a TravelAgent; Fixes BUKKIT-3541
Recent changes caused PlayerPortalEvent to suddenly return null unexpectedly and could end up in NPEs resulting that did not before. This commit addresses that situation by always ensuring a TravelAgent instance is returned. The TravelAgent for world 0 is returned arbitrarily in an effort to compensate for plugins that are implementation dependent and expect some form of a TravelAgent to be accessible in the event at all times.
This commit is contained in:
parent
4d3865a036
commit
efe8e9a7f5
@ -1764,7 +1764,7 @@ public abstract class Entity {
|
||||
Location exit = exitWorld != null ? minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i)) : null;
|
||||
boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
|
||||
|
||||
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : null;
|
||||
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
|
||||
EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
|
||||
event.useTravelAgent(useTravelAgent);
|
||||
event.getEntity().getServer().getPluginManager().callEvent(event);
|
||||
|
@ -451,7 +451,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
}
|
||||
|
||||
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : null;
|
||||
TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().s() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
|
||||
PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
|
||||
event.useTravelAgent(useTravelAgent);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
@ -9,12 +9,17 @@ import org.bukkit.TravelAgent;
|
||||
|
||||
public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
|
||||
|
||||
public static TravelAgent DEFAULT = null;
|
||||
|
||||
private int searchRadius = 128;
|
||||
private int creationRadius = 16;
|
||||
private boolean canCreatePortal = true;
|
||||
|
||||
public CraftTravelAgent(WorldServer worldserver) {
|
||||
super(worldserver);
|
||||
if (DEFAULT == null && worldserver.dimension == 0) {
|
||||
DEFAULT = (TravelAgent) worldserver.s();
|
||||
}
|
||||
}
|
||||
|
||||
public Location findOrCreate(Location target) {
|
||||
|
Loading…
Reference in New Issue
Block a user