Archiviert
13
0

SPIGOT-763: Directly changing to location in PlayerMoveEvent does not update location.

Dieser Commit ist enthalten in:
md_5 2015-04-09 10:11:40 +10:00
Ursprung 96c2c39245
Commit b4af37bf70

Datei anzeigen

@ -1,5 +1,5 @@
--- /home/matt/mc-dev-private//net/minecraft/server/PlayerConnection.java 2015-04-03 01:35:20.157517546 +0100 --- ../work/decompile-73f3c166/net/minecraft/server/PlayerConnection.java 2015-04-09 10:11:00.935204218 +1000
+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-03 01:35:20.177517546 +0100 +++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-04-09 10:11:00.939204199 +1000
@@ -17,6 +17,48 @@ @@ -17,6 +17,48 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -175,7 +175,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
this.h = true; this.h = true;
@@ -117,8 +221,65 @@ @@ -117,8 +221,66 @@
this.checkMovement = true; this.checkMovement = true;
} }
} }
@ -210,6 +210,7 @@
+ +
+ // Skip the first time we do this + // Skip the first time we do this
+ if (from.getX() != Double.MAX_VALUE) { + if (from.getX() != Double.MAX_VALUE) {
+ Location oldTo = to.clone();
+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
+ this.server.getPluginManager().callEvent(event); + this.server.getPluginManager().callEvent(event);
+ +
@ -222,7 +223,7 @@
+ /* If a Plugin has changed the To destination then we teleport the Player + /* If a Plugin has changed the To destination then we teleport the Player
+ there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. + there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
+ We only do this if the Event was not cancelled. */ + We only do this if the Event was not cancelled. */
+ if (!to.equals(event.getTo()) && !event.isCancelled()) { + if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN); + this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ return; + return;
+ } + }
@ -242,7 +243,7 @@
this.f = this.e; this.f = this.e;
double d7; double d7;
double d8; double d8;
@@ -212,12 +373,14 @@ @@ -212,12 +374,14 @@
double d11 = d7 - this.player.locX; double d11 = d7 - this.player.locX;
double d12 = d8 - this.player.locY; double d12 = d8 - this.player.locY;
double d13 = d9 - this.player.locZ; double d13 = d9 - this.player.locZ;
@ -261,7 +262,7 @@
PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")"); PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d14 + ", " + d15 + ", " + d16 + ")");
this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch); this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
return; return;
@@ -286,10 +449,53 @@ @@ -286,10 +450,53 @@
} }
public void a(double d0, double d1, double d2, float f, float f1) { public void a(double d0, double d1, double d2, float f, float f1) {
@ -316,7 +317,7 @@
this.checkMovement = false; this.checkMovement = false;
this.o = d0; this.o = d0;
this.p = d1; this.p = d1;
@@ -323,32 +529,49 @@ @@ -323,32 +530,49 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) { public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u());
@ -372,7 +373,7 @@
double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D); double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D);
double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D; double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D;
double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D); double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D);
@@ -363,7 +586,15 @@ @@ -363,7 +587,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else { } else {
@ -388,7 +389,7 @@
} }
} else { } else {
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
@@ -383,11 +614,22 @@ @@ -383,11 +615,22 @@
default: default:
throw new IllegalArgumentException("Invalid player action"); throw new IllegalArgumentException("Invalid player action");
} }
@ -411,7 +412,7 @@
ItemStack itemstack = this.player.inventory.getItemInHand(); ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = false; boolean flag = false;
BlockPosition blockposition = packetplayinblockplace.a(); BlockPosition blockposition = packetplayinblockplace.a();
@@ -399,7 +641,50 @@ @@ -399,7 +642,50 @@
return; return;
} }
@ -463,7 +464,7 @@
} else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) { } else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())}); ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
@@ -407,8 +692,19 @@ @@ -407,8 +693,19 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
flag = true; flag = true;
} else { } else {
@ -484,7 +485,7 @@
} }
flag = true; flag = true;
@@ -432,7 +728,8 @@ @@ -432,7 +729,8 @@
this.player.activeContainer.b(); this.player.activeContainer.b();
this.player.g = false; this.player.g = false;
@ -494,7 +495,7 @@
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand())); this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
} }
} }
@@ -446,8 +743,8 @@ @@ -446,8 +744,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer; WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length; int i = aworldserver.length;
@ -505,7 +506,7 @@
if (worldserver != null) { if (worldserver != null) {
entity = packetplayinspectate.a(worldserver); entity = packetplayinspectate.a(worldserver);
@@ -460,6 +757,8 @@ @@ -460,6 +758,8 @@
if (entity != null) { if (entity != null) {
this.player.e((Entity) this.player); this.player.e((Entity) this.player);
this.player.mount((Entity) null); this.player.mount((Entity) null);
@ -514,7 +515,7 @@
if (entity.world != this.player.world) { if (entity.world != this.player.world) {
WorldServer worldserver1 = this.player.u(); WorldServer worldserver1 = this.player.u();
WorldServer worldserver2 = (WorldServer) entity.world; WorldServer worldserver2 = (WorldServer) entity.world;
@@ -484,6 +783,9 @@ @@ -484,6 +784,9 @@
} else { } else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
} }
@ -524,7 +525,7 @@
} }
} }
@@ -492,14 +794,29 @@ @@ -492,14 +795,29 @@
public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
public void a(IChatBaseComponent ichatbasecomponent) { public void a(IChatBaseComponent ichatbasecomponent) {
@ -556,7 +557,7 @@
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
PlayerConnection.c.info("Stopping singleplayer server as player logged out"); PlayerConnection.c.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown(); this.minecraftServer.safeShutdown();
@@ -521,6 +838,15 @@ @@ -521,6 +839,15 @@
} }
} }
@ -572,7 +573,7 @@
try { try {
this.networkManager.handle(packet); this.networkManager.handle(packet);
} catch (Throwable throwable) { } catch (Throwable throwable) {
@@ -541,18 +867,34 @@ @@ -541,18 +868,34 @@
} }
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
@ -609,7 +610,7 @@
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
chatmessage.getChatModifier().setColor(EnumChatFormat.RED); chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
@@ -565,39 +907,249 @@ @@ -565,39 +908,249 @@
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@ -867,7 +868,7 @@
this.player.z(); this.player.z();
switch (PlayerConnection.SyntheticClass_1.b[packetplayinentityaction.b().ordinal()]) { switch (PlayerConnection.SyntheticClass_1.b[packetplayinentityaction.b().ordinal()]) {
case 1: case 1:
@@ -618,7 +1170,7 @@ @@ -618,7 +1171,7 @@
case 5: case 5:
this.player.a(false, true, true); this.player.a(false, true, true);
@ -876,7 +877,7 @@
break; break;
case 6: case 6:
@@ -640,6 +1192,7 @@ @@ -640,6 +1193,7 @@
} }
public void a(PacketPlayInUseEntity packetplayinuseentity) { public void a(PacketPlayInUseEntity packetplayinuseentity) {
@ -884,7 +885,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver); Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -654,18 +1207,71 @@ @@ -654,18 +1208,71 @@
} }
if (this.player.h(entity) < d0) { if (this.player.h(entity) < d0) {
@ -957,7 +958,7 @@
} }
} }
} }
@@ -680,7 +1286,8 @@ @@ -680,7 +1287,8 @@
switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) { switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) {
case 1: case 1:
if (this.player.viewingCredits) { if (this.player.viewingCredits) {
@ -967,7 +968,7 @@
} else if (this.player.u().getWorldData().isHardcore()) { } else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) {
this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!");
@@ -711,15 +1318,21 @@ @@ -711,15 +1319,21 @@
} }
public void a(PacketPlayInCloseWindow packetplayinclosewindow) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@ -990,7 +991,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
@@ -728,7 +1341,270 @@ @@ -728,7 +1342,270 @@
this.player.a(this.player.activeContainer, (List) arraylist); this.player.a(this.player.activeContainer, (List) arraylist);
} else { } else {
@ -1262,7 +1263,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
@@ -789,8 +1665,48 @@ @@ -789,8 +1666,48 @@
} }
boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize(); boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1312,7 +1313,7 @@
if (flag1 && flag2 && flag3) { if (flag1 && flag2 && flag3) {
if (itemstack == null) { if (itemstack == null) {
@@ -813,6 +1729,7 @@ @@ -813,6 +1730,7 @@
} }
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1320,7 +1321,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
@@ -823,6 +1740,7 @@ @@ -823,6 +1741,7 @@
} }
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1328,7 +1329,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z(); this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -839,14 +1757,30 @@ @@ -839,14 +1758,30 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) { if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@ -1360,7 +1361,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition); worldserver.notify(blockposition);
@@ -869,11 +1803,27 @@ @@ -869,11 +1804,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1389,7 +1390,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
@@ -913,13 +1863,15 @@ @@ -913,13 +1864,15 @@
itemstack1 = this.player.inventory.getItemInHand(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@ -1406,7 +1407,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -942,16 +1894,20 @@ @@ -942,16 +1895,20 @@
itemstack1 = this.player.inventory.getItemInHand(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) { if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
@ -1431,7 +1432,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -968,11 +1924,12 @@ @@ -968,11 +1925,12 @@
} }
} catch (Exception exception2) { } catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2); PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1445,7 +1446,7 @@
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
try { try {
@@ -1008,6 +1965,7 @@ @@ -1008,6 +1966,7 @@
} }
} catch (Exception exception3) { } catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3); PlayerConnection.c.error("Couldn\'t set command block", exception3);
@ -1453,7 +1454,7 @@
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
} }
@@ -1033,6 +1991,7 @@ @@ -1033,6 +1992,7 @@
} }
} catch (Exception exception4) { } catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", exception4); PlayerConnection.c.error("Couldn\'t set beacon", exception4);
@ -1461,7 +1462,7 @@
} }
} }
} else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) { } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
@@ -1048,7 +2007,28 @@ @@ -1048,7 +2008,28 @@
containeranvil.a(""); containeranvil.a("");
} }
} }