SPIGOT-3497: Cancelled EntityPortalEvent leads to incorrect behaviour

This commit is contained in:
md_5 2017-08-08 20:35:29 +10:00
parent 61a31ca0c7
commit 27b8bf9116

View File

@ -539,7 +539,7 @@
}
}
@@ -1893,19 +2236,75 @@
@@ -1893,19 +2236,76 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = this.C_();
@ -583,6 +583,7 @@
+ event.useTravelAgent(useTravelAgent);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
+ agent.setCanCreatePortal(oldCanCreate);
+ return null;
+ }
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
@ -618,7 +619,7 @@
BlockPosition blockposition;
if (i == 1) {
@@ -1934,12 +2333,18 @@
@@ -1934,12 +2334,18 @@
blockposition = new BlockPosition(this);
}
@ -638,7 +639,7 @@
if (j == 1 && i == 1) {
BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
@@ -1947,6 +2352,7 @@
@@ -1947,6 +2353,7 @@
} else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
@ -646,7 +647,7 @@
boolean flag = entity.attachedToPlayer;
@@ -1954,13 +2360,21 @@
@@ -1954,13 +2361,21 @@
worldserver1.addEntity(entity);
entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false);
@ -669,7 +670,7 @@
return entity;
} else {
return null;
@@ -2064,6 +2478,11 @@
@@ -2064,6 +2479,11 @@
}
public void setCustomName(String s) {
@ -681,7 +682,7 @@
this.datawatcher.set(Entity.aB, s);
}
@@ -2121,7 +2540,26 @@
@@ -2121,7 +2541,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@ -709,7 +710,7 @@
}
public float getHeadHeight() {
@@ -2295,7 +2733,7 @@
@@ -2295,7 +2734,7 @@
for (Iterator iterator = this.bF().iterator(); iterator.hasNext(); entity.a(oclass, set)) {
entity = (Entity) iterator.next();
if (oclass.isAssignableFrom(entity.getClass())) {