Archiviert
13
0

SPIGOT-2311: Cancelling PlayerPortalEvent causes invulnerability until relog

Dieser Commit ist enthalten in:
md_5 2016-05-25 18:25:49 +10:00
Ursprung ef3ccc94e0
Commit 042911fef4

Datei anzeigen

@ -391,7 +391,7 @@
entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.playerConnection = entityplayer.playerConnection;
entityplayer1.copyTo(entityplayer, flag); entityplayer1.copyTo(entityplayer, flag);
@@ -415,43 +578,156 @@ @@ -415,43 +578,157 @@
entityplayer1.a(s); entityplayer1.a(s);
} }
@ -520,7 +520,6 @@
+ Location exit = null; + Location exit = null;
+ boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END + boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
+ if (exitWorld != null) { + if (exitWorld != null) {
+ entityplayer.ck = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+ if ((cause == TeleportCause.END_PORTAL) && (i == 0)) { + if ((cause == TeleportCause.END_PORTAL) && (i == 0)) {
+ // THE_END -> NORMAL; use bed if available, otherwise default spawn + // THE_END -> NORMAL; use bed if available, otherwise default spawn
+ exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); + exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
@ -557,6 +556,8 @@
+ Vector velocity = entityplayer.getBukkitEntity().getVelocity(); + Vector velocity = entityplayer.getBukkitEntity().getVelocity();
+ exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity); + exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);
+ +
+
+ entityplayer.ck = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+ this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we + this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
+ if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) { + if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
+ entityplayer.getBukkitEntity().setVelocity(velocity); + entityplayer.getBukkitEntity().setVelocity(velocity);
@ -566,7 +567,7 @@
public void f(EntityPlayer entityplayer) { public void f(EntityPlayer entityplayer) {
GameProfile gameprofile = entityplayer.getProfile(); GameProfile gameprofile = entityplayer.getProfile();
int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0; int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0;
@@ -490,12 +766,111 @@ @@ -490,12 +767,111 @@
} }
public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) {
@ -678,7 +679,7 @@
if (entity.dimension == -1) { if (entity.dimension == -1) {
d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D);
d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D);
@@ -514,6 +889,8 @@ @@ -514,6 +890,8 @@
BlockPosition blockposition; BlockPosition blockposition;
if (i == 1) { if (i == 1) {
@ -687,7 +688,7 @@
blockposition = worldserver1.getSpawn(); blockposition = worldserver1.getSpawn();
} else { } else {
blockposition = worldserver1.getDimensionSpawn(); blockposition = worldserver1.getDimensionSpawn();
@@ -527,16 +904,27 @@ @@ -527,16 +905,27 @@
worldserver.entityJoinedWorld(entity, false); worldserver.entityJoinedWorld(entity, false);
} }
} }
@ -718,7 +719,7 @@
worldserver1.entityJoinedWorld(entity, false); worldserver1.entityJoinedWorld(entity, false);
} }
@@ -544,6 +932,7 @@ @@ -544,6 +933,7 @@
} }
entity.spawnIn(worldserver1); entity.spawnIn(worldserver1);
@ -726,7 +727,7 @@
} }
public void tick() { public void tick() {
@@ -561,6 +950,25 @@ @@ -561,6 +951,25 @@
} }
@ -752,7 +753,7 @@
public void a(Packet<?> packet, int i) { public void a(Packet<?> packet, int i) {
for (int j = 0; j < this.players.size(); ++j) { for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -659,11 +1067,23 @@ @@ -659,11 +1068,23 @@
this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile))); this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile)));
this.b(this.a(gameprofile.getId()), i); this.b(this.a(gameprofile.getId()), i);
@ -776,7 +777,7 @@
} }
private void b(EntityPlayer entityplayer, int i) { private void b(EntityPlayer entityplayer, int i) {
@@ -688,7 +1108,7 @@ @@ -688,7 +1109,7 @@
} }
public boolean isOp(GameProfile gameprofile) { public boolean isOp(GameProfile gameprofile) {
@ -785,7 +786,7 @@
} }
@Nullable @Nullable
@@ -712,6 +1132,12 @@ @@ -712,6 +1133,12 @@
for (int j = 0; j < this.players.size(); ++j) { for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@ -798,7 +799,7 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) { if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX; double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY; double d5 = d1 - entityplayer.locY;
@@ -759,21 +1185,26 @@ @@ -759,21 +1186,26 @@
public void reloadWhitelist() {} public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) { public void b(EntityPlayer entityplayer, WorldServer worldserver) {
@ -830,7 +831,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
} }
@@ -786,7 +1217,7 @@ @@ -786,7 +1218,7 @@
} }
public String[] getSeenPlayers() { public String[] getSeenPlayers() {
@ -839,7 +840,7 @@
} }
public boolean getHasWhitelist() { public boolean getHasWhitelist() {
@@ -836,16 +1267,26 @@ @@ -836,16 +1268,26 @@
public void u() { public void u() {
for (int i = 0; i < this.players.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
@ -868,7 +869,7 @@
} }
public void sendMessage(IChatBaseComponent ichatbasecomponent) { public void sendMessage(IChatBaseComponent ichatbasecomponent) {
@@ -882,8 +1323,10 @@ @@ -882,8 +1324,10 @@
WorldServer[] aworldserver = this.server.worldServer; WorldServer[] aworldserver = this.server.worldServer;
int j = aworldserver.length; int j = aworldserver.length;