SPIGOT-5171: Don't fire PlayerTeleportEvent if not actually moving

Dieser Commit ist enthalten in:
md_5 2019-07-16 10:15:59 +10:00
Ursprung 2349feb849
Commit f554183c3a

Datei anzeigen

@ -507,7 +507,7 @@
this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
this.player.onGround = packetplayinflying.b();
this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
@@ -712,10 +1013,60 @@
@@ -712,10 +1013,66 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@ -535,6 +535,12 @@
+ float pitch = f1;
+
+ Location to = new Location(this.getPlayer().getWorld(), x, y, z, yaw, pitch);
+ // SPIGOT-5171: Triggered on join
+ if (from.equals(to)) {
+ this.internalTeleport(d0, d1, d2, f, f1, set);
+ return;
+ }
+
+ PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause);
+ this.server.getPluginManager().callEvent(event);
+
@ -569,7 +575,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
@@ -727,6 +1078,14 @@
@@ -727,6 +1084,14 @@
this.teleportAwait = 0;
}
@ -584,7 +590,7 @@
this.A = this.e;
this.player.setLocation(d0, d1, d2, f, f1);
this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
@@ -735,6 +1094,7 @@
@@ -735,6 +1100,7 @@
@Override
public void a(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
@ -592,7 +598,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.b();
@@ -744,13 +1104,45 @@
@@ -744,13 +1110,45 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
@ -640,7 +646,7 @@
this.player.n(false);
}
@@ -781,7 +1173,15 @@
@@ -781,7 +1179,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
} else {
@ -656,7 +662,7 @@
}
} else {
if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
@@ -800,11 +1200,13 @@
@@ -800,11 +1206,13 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@ -670,7 +676,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.b();
ItemStack itemstack = this.player.b(enumhand);
@@ -818,6 +1220,14 @@
@@ -818,6 +1226,14 @@
this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO));
} else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
@ -685,7 +691,7 @@
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
}
@@ -828,13 +1238,53 @@
@@ -828,13 +1244,53 @@
@Override
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
@ -740,7 +746,7 @@
}
}
@@ -849,7 +1299,7 @@
@@ -849,7 +1305,7 @@
Entity entity = packetplayinspectate.a(worldserver);
if (entity != null) {
@ -749,7 +755,7 @@
return;
}
}
@@ -858,7 +1308,12 @@
@@ -858,7 +1314,12 @@
}
@Override
@ -763,7 +769,7 @@
@Override
public void a(PacketPlayInBoatMove packetplayinboatmove) {
@@ -873,11 +1328,26 @@
@@ -873,11 +1334,26 @@
@Override
public void a(IChatBaseComponent ichatbasecomponent) {
@ -791,7 +797,7 @@
if (this.isExemptPlayer()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown(false);
@@ -903,6 +1373,15 @@
@@ -903,6 +1379,15 @@
}
}
@ -807,7 +813,7 @@
try {
this.networkManager.sendPacket(packet, genericfuturelistener);
} catch (Throwable throwable) {
@@ -919,18 +1398,38 @@
@@ -919,18 +1404,38 @@
@Override
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
@ -848,7 +854,7 @@
this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
} else {
this.player.resetIdleTimer();
@@ -940,41 +1439,257 @@
@@ -940,41 +1445,257 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@ -1113,7 +1119,7 @@
this.player.resetIdleTimer();
IJumpable ijumpable;
@@ -1038,6 +1753,7 @@
@@ -1038,6 +1759,7 @@
@Override
public void a(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
@ -1121,7 +1127,7 @@
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
@@ -1053,20 +1769,74 @@
@@ -1053,20 +1775,74 @@
if (this.player.h(entity) < d0) {
EnumHand enumhand;
@ -1197,7 +1203,7 @@
}
}
}
@@ -1106,15 +1876,21 @@
@@ -1106,15 +1882,21 @@
@Override
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
@ -1221,7 +1227,7 @@
NonNullList<ItemStack> nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
@@ -1123,8 +1899,274 @@
@@ -1123,8 +1905,274 @@
this.player.a(this.player.activeContainer, nonnulllist);
} else {
@ -1233,7 +1239,7 @@
+
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
+ SlotType type = inventory.getSlotType(packetplayinwindowclick.c());
+
+ InventoryClickEvent event;
+ ClickType click = ClickType.UNKNOWN;
+ InventoryAction action = InventoryAction.UNKNOWN;
@ -1423,7 +1429,7 @@
+ }
+ }
+ }
+
+ event.setCancelled(cancelled);
+ Container oldContainer = this.player.activeContainer; // SPIGOT-1224
+ server.getPluginManager().callEvent(event);
@ -1497,7 +1503,7 @@
if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
this.player.e = true;
@@ -1164,6 +2206,7 @@
@@ -1164,6 +2212,7 @@
@Override
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
@ -1505,7 +1511,7 @@
this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c());
@@ -1196,6 +2239,43 @@
@@ -1196,6 +2245,43 @@
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1549,7 +1555,7 @@
if (flag1 && flag2) {
if (itemstack.isEmpty()) {
@@ -1221,6 +2301,7 @@
@@ -1221,6 +2307,7 @@
@Override
public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
@ -1557,7 +1563,7 @@
int i = this.player.activeContainer.windowId;
if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
@@ -1232,6 +2313,7 @@
@@ -1232,6 +2319,7 @@
@Override
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
@ -1565,7 +1571,7 @@
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinupdatesign.b();
@@ -1248,14 +2330,30 @@
@@ -1248,14 +2336,30 @@
if (!tileentitysign.d() || tileentitysign.f() != this.player) {
this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
@ -1597,7 +1603,7 @@
tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
@@ -1265,6 +2363,7 @@
@@ -1265,6 +2369,7 @@
@Override
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1605,7 +1611,7 @@
if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) {
int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive);
@@ -1279,7 +2378,17 @@
@@ -1279,7 +2384,17 @@
@Override
public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
@ -1624,7 +1630,7 @@
}
@Override
@@ -1288,8 +2397,50 @@
@@ -1288,8 +2403,50 @@
this.player.a(packetplayinsettings);
}