@@ -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);
|
||||
@@ -708,10 +1009,60 @@
|
||||
@@ -712,10 +1013,60 @@
|
||||
}
|
||||
|
||||
public void a(double d0, double d1, double d2, float f, float f1) {
|
||||
@@ -569,7 +569,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;
|
||||
@@ -723,6 +1074,14 @@
|
||||
@@ -727,6 +1078,14 @@
|
||||
this.teleportAwait = 0;
|
||||
}
|
||||
|
||||
@@ -584,7 +584,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));
|
||||
@@ -731,6 +1090,7 @@
|
||||
@@ -735,6 +1094,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
|
||||
@@ -592,73 +592,73 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
BlockPosition blockposition = packetplayinblockdig.b();
|
||||
|
||||
@@ -740,13 +1100,45 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
|
||||
@@ -744,13 +1104,45 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
|
||||
|
||||
- this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
|
||||
- this.player.a(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.server.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.a(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getName() + " dropped their items too quickly!");
|
||||
+ this.disconnect("You dropped your items too quickly (Hacking?)");
|
||||
- this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
|
||||
- this.player.a(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.server.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.n(false);
|
||||
}
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.a(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -777,7 +1169,15 @@
|
||||
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
||||
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
|
||||
} else {
|
||||
+ // CraftBukkit start - fire PlayerInteractEvent
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.c(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = worldserver.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getName() + " dropped their items too quickly!");
|
||||
+ this.disconnect("You dropped your items too quickly (Hacking?)");
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else {
|
||||
if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
||||
@@ -796,11 +1196,13 @@
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.n(false);
|
||||
}
|
||||
|
||||
@@ -781,7 +1173,15 @@
|
||||
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
|
||||
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
|
||||
} else {
|
||||
+ // CraftBukkit start - fire PlayerInteractEvent
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.c(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = worldserver.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else {
|
||||
if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
|
||||
@@ -800,11 +1200,13 @@
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid player action");
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -670,7 +670,7 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
EnumHand enumhand = packetplayinuseitem.b();
|
||||
ItemStack itemstack = this.player.b(enumhand);
|
||||
@@ -814,6 +1216,14 @@
|
||||
@@ -818,6 +1220,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 +685,7 @@
|
||||
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
}
|
||||
|
||||
@@ -824,13 +1234,53 @@
|
||||
@@ -828,13 +1238,53 @@
|
||||
@Override
|
||||
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
|
||||
@@ -740,7 +740,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,7 +1295,7 @@
|
||||
@@ -849,7 +1299,7 @@
|
||||
Entity entity = packetplayinspectate.a(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -749,7 +749,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -854,7 +1304,12 @@
|
||||
@@ -858,7 +1308,12 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -763,7 +763,7 @@
|
||||
|
||||
@Override
|
||||
public void a(PacketPlayInBoatMove packetplayinboatmove) {
|
||||
@@ -869,11 +1324,26 @@
|
||||
@@ -873,11 +1328,26 @@
|
||||
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
@@ -778,7 +778,7 @@
|
||||
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
|
||||
+ /*
|
||||
this.minecraftServer.invalidatePingSample();
|
||||
this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW));
|
||||
this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW));
|
||||
+ */
|
||||
+
|
||||
this.player.n();
|
||||
@@ -791,7 +791,7 @@
|
||||
if (this.isExemptPlayer()) {
|
||||
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||
this.minecraftServer.safeShutdown(false);
|
||||
@@ -899,6 +1369,15 @@
|
||||
@@ -903,6 +1373,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,7 +807,7 @@
|
||||
try {
|
||||
this.networkManager.sendPacket(packet, genericfuturelistener);
|
||||
} catch (Throwable throwable) {
|
||||
@@ -915,18 +1394,38 @@
|
||||
@@ -919,18 +1398,38 @@
|
||||
@Override
|
||||
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
|
||||
@@ -848,7 +848,7 @@
|
||||
this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
|
||||
} else {
|
||||
this.player.resetIdleTimer();
|
||||
@@ -936,41 +1435,257 @@
|
||||
@@ -940,41 +1439,257 @@
|
||||
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
|
||||
@@ -909,7 +909,7 @@
|
||||
+ this.chat(s, true);
|
||||
+ // CraftBukkit end - the below is for reference. :)
|
||||
} else {
|
||||
ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s});
|
||||
ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s});
|
||||
|
||||
this.minecraftServer.getPlayerList().sendMessage(chatmessage, false);
|
||||
}
|
||||
@@ -1113,7 +1113,7 @@
|
||||
this.player.resetIdleTimer();
|
||||
IJumpable ijumpable;
|
||||
|
||||
@@ -1034,6 +1749,7 @@
|
||||
@@ -1038,6 +1753,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
|
||||
@@ -1121,7 +1121,7 @@
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
Entity entity = packetplayinuseentity.a((World) worldserver);
|
||||
|
||||
@@ -1049,20 +1765,74 @@
|
||||
@@ -1053,20 +1769,74 @@
|
||||
if (this.player.h(entity) < d0) {
|
||||
EnumHand enumhand;
|
||||
|
||||
@@ -1197,7 +1197,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1102,15 +1872,21 @@
|
||||
@@ -1106,15 +1876,21 @@
|
||||
@Override
|
||||
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
|
||||
@@ -1221,7 +1221,7 @@
|
||||
NonNullList<ItemStack> nonnulllist = NonNullList.a();
|
||||
|
||||
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
|
||||
@@ -1119,8 +1895,274 @@
|
||||
@@ -1123,8 +1899,274 @@
|
||||
|
||||
this.player.a(this.player.activeContainer, nonnulllist);
|
||||
} else {
|
||||
@@ -1230,10 +1230,10 @@
|
||||
+ if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) {
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
+
|
||||
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
|
||||
+ SlotType type = inventory.getSlotType(packetplayinwindowclick.c());
|
||||
+
|
||||
|
||||
+ InventoryClickEvent event;
|
||||
+ ClickType click = ClickType.UNKNOWN;
|
||||
+ InventoryAction action = InventoryAction.UNKNOWN;
|
||||
@@ -1497,7 +1497,7 @@
|
||||
if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
|
||||
this.player.e = true;
|
||||
@@ -1160,6 +2202,7 @@
|
||||
@@ -1164,6 +2206,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
|
||||
@@ -1505,7 +1505,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());
|
||||
@@ -1192,6 +2235,43 @@
|
||||
@@ -1196,6 +2239,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
||||
@@ -1549,7 +1549,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -1217,6 +2297,7 @@
|
||||
@@ -1221,6 +2301,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInTransaction packetplayintransaction) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
|
||||
@@ -1557,7 +1557,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()) {
|
||||
@@ -1228,6 +2309,7 @@
|
||||
@@ -1232,6 +2313,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
|
||||
@@ -1565,9 +1565,9 @@
|
||||
this.player.resetIdleTimer();
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
BlockPosition blockposition = packetplayinupdatesign.b();
|
||||
@@ -1244,14 +2326,30 @@
|
||||
@@ -1248,14 +2330,30 @@
|
||||
|
||||
if (!tileentitysign.c() || tileentitysign.d() != this.player) {
|
||||
if (!tileentitysign.d() || tileentitysign.f() != this.player) {
|
||||
this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
|
||||
+ this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
|
||||
return;
|
||||
@@ -1597,7 +1597,7 @@
|
||||
|
||||
tileentitysign.update();
|
||||
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
||||
@@ -1261,6 +2359,7 @@
|
||||
@@ -1265,6 +2363,7 @@
|
||||
|
||||
@Override
|
||||
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
|
||||
@@ -1605,7 +1605,7 @@
|
||||
if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) {
|
||||
int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive);
|
||||
|
||||
@@ -1275,7 +2374,17 @@
|
||||
@@ -1279,7 +2378,17 @@
|
||||
@Override
|
||||
public void a(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
|
||||
@@ -1624,7 +1624,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1284,8 +2393,50 @@
|
||||
@@ -1288,8 +2397,50 @@
|
||||
this.player.a(packetplayinsettings);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user