Commits

md_5 authored 3eb7236e443
SPIGOT-6217: Missed PlayerEditBookEvent when editing books
No tags

nms-patches/PlayerConnection.patch

Modified
373 373 + for (int i = 0; i < nbttaglist.size(); ++i) {
374 374 list.add(nbttaglist.getString(i));
375 375 }
376 376
377 377 - i = packetplayinbedit.d();
378 378 + int i = packetplayinbedit.d();
379 379 + // CraftBukkit end
380 380 if (PlayerInventory.d(i) || i == 40) {
381 381 this.a((List) list, flag ? (list1) -> {
382 382 this.a((String) list1.get(0), list1.subList(1, list1.size()), i);
383 -@@ -664,7 +873,7 @@
383 +@@ -635,7 +844,9 @@
384 + NBTTagList nbttaglist = new NBTTagList();
385 +
386 + list.stream().map(NBTTagString::a).forEach(nbttaglist::add);
387 ++ ItemStack old = itemstack.cloneItemStack(); // CraftBukkit
388 + itemstack.a("pages", (NBTBase) nbttaglist);
389 ++ CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit
390 + }
391 + }
392 +
393 +@@ -664,7 +875,7 @@
384 394 }
385 395
386 396 itemstack1.a("pages", (NBTBase) nbttaglist);
387 397 - this.player.inventory.setItem(i, itemstack1);
388 398 + this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, itemstack, itemstack1)); // CraftBukkit
389 399 }
390 400 }
391 401
392 -@@ -702,7 +911,7 @@
402 +@@ -702,7 +913,7 @@
393 403 } else {
394 404 WorldServer worldserver = this.player.getWorldServer();
395 405
396 406 - if (!this.player.viewingCredits) {
397 407 + if (!this.player.viewingCredits && !this.player.isFrozen()) { // CraftBukkit
398 408 if (this.e == 0) {
399 409 this.syncPosition();
400 410 }
401 -@@ -712,13 +921,21 @@
411 +@@ -712,13 +923,21 @@
402 412 this.A = this.e;
403 413 this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
404 414 }
405 415 -
406 416 + this.allowedPlayerTicks = 20; // CraftBukkit
407 417 } else {
408 418 this.A = this.e;
409 419 if (this.player.isPassenger()) {
410 420 this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch));
411 421 this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
414 424 + // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify
415 425 + double prevX = player.locX();
416 426 + double prevY = player.locY();
417 427 + double prevZ = player.locZ();
418 428 + float prevYaw = player.yaw;
419 429 + float prevPitch = player.pitch;
420 430 + // CraftBukkit end
421 431 double d0 = this.player.locX();
422 432 double d1 = this.player.locY();
423 433 double d2 = this.player.locZ();
424 -@@ -743,15 +960,33 @@
434 +@@ -743,15 +962,33 @@
425 435 ++this.receivedMovePackets;
426 436 int i = this.receivedMovePackets - this.processedMovePackets;
427 437
428 438 - if (i > 5) {
429 439 + // CraftBukkit start - handle custom speeds and skipped ticks
430 440 + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
431 441 + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1);
432 442 + this.lastTick = (int) (System.currentTimeMillis() / 50);
433 443 +
434 444 + if (i > Math.max(this.allowedPlayerTicks, 5)) {
450 460 +
451 461 if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean(GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isGliding())) {
452 462 float f2 = this.player.isGliding() ? 300.0F : 100.0F;
453 463
454 464 - if (d11 - d10 > (double) (f2 * (float) i) && !this.isExemptPlayer()) {
455 465 + if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) {
456 466 + // CraftBukkit end
457 467 PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9);
458 468 this.a(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch);
459 469 return;
460 -@@ -770,6 +1005,7 @@
470 +@@ -770,6 +1007,7 @@
461 471 }
462 472
463 473 this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
464 474 + this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move
465 475 double d12 = d8;
466 476
467 477 d7 = d4 - this.player.locX();
468 -@@ -791,10 +1027,74 @@
478 +@@ -791,10 +1029,74 @@
469 479 if (!this.player.noclip && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) {
470 480 this.a(d0, d1, d2, f, f1);
471 481 } else {
472 482 - 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() && this.a((Entity) this.player);
473 483 + // CraftBukkit start - fire PlayerMoveEvent
474 484 + // Rest to old location first
475 485 + this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch);
476 486 +
477 487 + Player player = this.getPlayer();
478 488 + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
535 545 + // MC-135989, SPIGOT-5564: isRiptiding
536 546 + 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() && this.a((Entity) this.player) && !this.player.isRiptiding();
537 547 + // CraftBukkit end
538 548 this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
539 549 this.player.a(this.player.locY() - d3, packetplayinflying.b());
540 550 - this.player.setOnGround(packetplayinflying.b());
541 551 + // this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - moved up
542 552 if (flag) {
543 553 this.player.fallDistance = 0.0F;
544 554 }
545 -@@ -823,10 +1123,66 @@
555 +@@ -823,10 +1125,66 @@
546 556 }
547 557
548 558 public void a(double d0, double d1, double d2, float f, float f1) {
549 559 - this.a(d0, d1, d2, f, f1, Collections.emptySet());
550 560 + this.a(d0, d1, d2, f, f1, Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet());
551 561 + }
552 562 +
553 563 + // CraftBukkit start - Delegate to teleport(Location)
554 564 + public void a(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) {
555 565 + this.a(d0, d1, d2, f, f1, Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet(), cause);
603 613 + }
604 614 + if (Float.isNaN(f1)) {
605 615 + f1 = 0;
606 616 + }
607 617 +
608 618 + this.justTeleported = true;
609 619 + // CraftBukkit end
610 620 double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX() : 0.0D;
611 621 double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY() : 0.0D;
612 622 double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ() : 0.0D;
613 -@@ -838,6 +1194,14 @@
623 +@@ -838,6 +1196,14 @@
614 624 this.teleportAwait = 0;
615 625 }
616 626
617 627 + // CraftBukkit start - update last location
618 628 + this.lastPosX = this.teleportPos.x;
619 629 + this.lastPosY = this.teleportPos.y;
620 630 + this.lastPosZ = this.teleportPos.z;
621 631 + this.lastYaw = f;
622 632 + this.lastPitch = f1;
623 633 + // CraftBukkit end
624 634 +
625 635 this.A = this.e;
626 636 this.player.setLocation(d0, d1, d2, f, f1);
627 637 this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
628 -@@ -846,6 +1210,7 @@
638 +@@ -846,6 +1212,7 @@
629 639 @Override
630 640 public void a(PacketPlayInBlockDig packetplayinblockdig) {
631 641 PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
632 642 + if (this.player.isFrozen()) return; // CraftBukkit
633 643 BlockPosition blockposition = packetplayinblockdig.b();
634 644
635 645 this.player.resetIdleTimer();
636 -@@ -856,14 +1221,46 @@
646 +@@ -856,14 +1223,46 @@
637 647 if (!this.player.isSpectator()) {
638 648 ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
639 649
640 650 - this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
641 651 - this.player.a(EnumHand.MAIN_HAND, itemstack);
642 652 + // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
643 653 + CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
644 654 + CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND));
645 655 + PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone());
646 656 + this.server.getPluginManager().callEvent(swapItemsEvent);
675 685 + if (this.dropCount >= 20) {
676 686 + LOGGER.warn(this.player.getName() + " dropped their items too quickly!");
677 687 + this.disconnect("You dropped your items too quickly (Hacking?)");
678 688 + return;
679 689 + }
680 690 + }
681 691 + // CraftBukkit end
682 692 this.player.dropItem(false);
683 693 }
684 694
685 -@@ -900,6 +1297,7 @@
695 +@@ -900,6 +1299,7 @@
686 696 @Override
687 697 public void a(PacketPlayInUseItem packetplayinuseitem) {
688 698 PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer());
689 699 + if (this.player.isFrozen()) return; // CraftBukkit
690 700 WorldServer worldserver = this.player.getWorldServer();
691 701 EnumHand enumhand = packetplayinuseitem.b();
692 702 ItemStack itemstack = this.player.b(enumhand);
693 -@@ -910,6 +1308,14 @@
703 +@@ -910,6 +1310,14 @@
694 704 this.player.resetIdleTimer();
695 705 if (blockposition.getY() < this.minecraftServer.getMaxBuildHeight()) {
696 706 if (this.teleportPos == null && this.player.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) {
697 707 + // CraftBukkit start - Check if we can actually do something over this large a distance
698 708 + Location eyeLoc = this.getPlayer().getEyeLocation();
699 709 + double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
700 710 + if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
701 711 + return;
702 712 + }
703 713 + this.player.clearActiveItem(); // SPIGOT-4706
704 714 + // CraftBukkit end
705 715 EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
706 716
707 717 if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && a(this.player, itemstack)) {
708 -@@ -933,12 +1339,51 @@
718 +@@ -933,12 +1341,51 @@
709 719 @Override
710 720 public void a(PacketPlayInBlockPlace packetplayinblockplace) {
711 721 PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
712 722 + if (this.player.isFrozen()) return; // CraftBukkit
713 723 WorldServer worldserver = this.player.getWorldServer();
714 724 EnumHand enumhand = packetplayinblockplace.b();
715 725 ItemStack itemstack = this.player.b(enumhand);
716 726
717 727 this.player.resetIdleTimer();
718 728 if (!itemstack.isEmpty()) {
750 760 + player.playerInteractManager.firedInteract = false;
751 761 + }
752 762 +
753 763 + if (cancelled) {
754 764 + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
755 765 + return;
756 766 + }
757 767 EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand);
758 768
759 769 if (enuminteractionresult.b()) {
760 -@@ -959,7 +1404,7 @@
770 +@@ -959,7 +1406,7 @@
761 771 Entity entity = packetplayinspectate.a(worldserver);
762 772
763 773 if (entity != null) {
764 774 - this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch);
765 775 + this.player.a(worldserver, entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
766 776 return;
767 777 }
768 778 }
769 -@@ -968,7 +1413,12 @@
779 +@@ -968,7 +1415,12 @@
770 780 }
771 781
772 782 @Override
773 783 - public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
774 784 + // CraftBukkit start
775 785 + public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
776 786 + PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.getWorldServer());
777 787 + this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
778 788 + }
779 789 + // CraftBukkit end
780 790
781 791 @Override
782 792 public void a(PacketPlayInBoatMove packetplayinboatmove) {
783 -@@ -983,11 +1433,26 @@
793 +@@ -983,11 +1435,26 @@
784 794
785 795 @Override
786 796 public void a(IChatBaseComponent ichatbasecomponent) {
787 797 + // CraftBukkit start - Rarely it would send a disconnect line twice
788 798 + if (this.processedDisconnect) {
789 799 + return;
790 800 + } else {
791 801 + this.processedDisconnect = true;
792 802 + }
793 803 + // CraftBukkit end
801 811 this.player.p();
802 812 - this.minecraftServer.getPlayerList().disconnect(this.player);
803 813 + String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
804 814 + if ((quitMessage != null) && (quitMessage.length() > 0)) {
805 815 + this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));
806 816 + }
807 817 + // CraftBukkit end
808 818 ITextFilter itextfilter = this.player.Q();
809 819
810 820 if (itextfilter != null) {
811 -@@ -1019,6 +1484,15 @@
821 +@@ -1019,6 +1486,15 @@
812 822 }
813 823 }
814 824
815 825 + // CraftBukkit start
816 826 + if (packet == null) {
817 827 + return;
818 828 + } else if (packet instanceof PacketPlayOutSpawnPosition) {
819 829 + PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
820 830 + this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.position.getX(), packet6.position.getY(), packet6.position.getZ());
821 831 + }
822 832 + // CraftBukkit end
823 833 +
824 834 try {
825 835 this.networkManager.sendPacket(packet, genericfuturelistener);
826 836 } catch (Throwable throwable) {
827 -@@ -1035,7 +1509,16 @@
837 +@@ -1035,7 +1511,16 @@
828 838 @Override
829 839 public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
830 840 PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
831 841 + if (this.player.isFrozen()) return; // CraftBukkit
832 842 if (packetplayinhelditemslot.b() >= 0 && packetplayinhelditemslot.b() < PlayerInventory.getHotbarSize()) {
833 843 + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.b());
834 844 + this.server.getPluginManager().callEvent(event);
835 845 + if (event.isCancelled()) {
836 846 + this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
837 847 + this.player.resetIdleTimer();
838 848 + return;
839 849 + }
840 850 + // CraftBukkit end
841 851 if (this.player.inventory.itemInHandIndex != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) {
842 852 this.player.clearActiveItem();
843 853 }
844 -@@ -1044,65 +1527,286 @@
854 +@@ -1044,65 +1529,286 @@
845 855 this.player.resetIdleTimer();
846 856 } else {
847 857 PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString());
848 858 + this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit
849 859 }
850 860 }
851 861
852 862 @Override
853 863 public void a(PacketPlayInChat packetplayinchat) {
854 864 + // CraftBukkit start - async chat
1130 1140 +
1131 1141 + if (e2.isCancelled()) {
1132 1142 + return;
1133 1143 + }
1134 1144 + break;
1135 1145 + }
1136 1146 + // CraftBukkit end
1137 1147 this.player.resetIdleTimer();
1138 1148 IJumpable ijumpable;
1139 1149
1140 -@@ -1160,6 +1864,7 @@
1150 +@@ -1160,6 +1866,7 @@
1141 1151 @Override
1142 1152 public void a(PacketPlayInUseEntity packetplayinuseentity) {
1143 1153 PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
1144 1154 + if (this.player.isFrozen()) return; // CraftBukkit
1145 1155 WorldServer worldserver = this.player.getWorldServer();
1146 1156 Entity entity = packetplayinuseentity.a((World) worldserver);
1147 1157
1148 -@@ -1173,18 +1878,72 @@
1158 +@@ -1173,18 +1880,72 @@
1149 1159 ItemStack itemstack = enumhand != null ? this.player.b(enumhand).cloneItemStack() : ItemStack.b;
1150 1160 Optional<EnumInteractionResult> optional = Optional.empty();
1151 1161
1152 1162 + ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit
1153 1163 +
1154 1164 + if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
1155 1165 + || packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
1156 1166 + // CraftBukkit start
1157 1167 + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
1158 1168 + Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem();
1212 1222 this.player.attack(entity);
1213 1223 +
1214 1224 + // CraftBukkit start
1215 1225 + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
1216 1226 + this.player.updateInventory(this.player.activeContainer);
1217 1227 + }
1218 1228 + // CraftBukkit end
1219 1229 }
1220 1230
1221 1231 if (optional.isPresent() && ((EnumInteractionResult) optional.get()).a()) {
1222 -@@ -1231,15 +1990,21 @@
1232 +@@ -1231,15 +1992,21 @@
1223 1233 @Override
1224 1234 public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
1225 1235 PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
1226 1236 +
1227 1237 + if (this.player.isFrozen()) return; // CraftBukkit
1228 1238 + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
1229 1239 +
1230 1240 this.player.o();
1231 1241 }
1232 1242
1236 1246 + if (this.player.isFrozen()) return; // CraftBukkit
1237 1247 this.player.resetIdleTimer();
1238 1248 - if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player)) {
1239 1249 - if (this.player.isSpectator()) {
1240 1250 + if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit
1241 1251 + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
1242 1252 + if (false/*this.player.isSpectator()*/) { // CraftBukkit
1243 1253 NonNullList<ItemStack> nonnulllist = NonNullList.a();
1244 1254
1245 1255 for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
1246 -@@ -1248,8 +2013,274 @@
1256 +@@ -1248,8 +2015,274 @@
1247 1257
1248 1258 this.player.a(this.player.activeContainer, nonnulllist);
1249 1259 } else {
1250 1260 - ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player);
1251 1261 + // CraftBukkit start - Call InventoryClickEvent
1252 1262 + if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) {
1253 1263 + return;
1254 1264 + }
1255 1265 +
1256 1266 + InventoryView inventory = this.player.activeContainer.getBukkitView();
1512 1522 + if (event instanceof CraftItemEvent) {
1513 1523 + // Need to update the inventory on crafting to
1514 1524 + // correctly support custom recipes
1515 1525 + player.updateInventory(player.activeContainer);
1516 1526 + }
1517 1527 + }
1518 1528 + // CraftBukkit end
1519 1529 if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
1520 1530 this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
1521 1531 this.player.e = true;
1522 -@@ -1289,6 +2320,7 @@
1532 +@@ -1289,6 +2322,7 @@
1523 1533 @Override
1524 1534 public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
1525 1535 PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
1526 1536 + if (this.player.isFrozen()) return; // CraftBukkit
1527 1537 this.player.resetIdleTimer();
1528 1538 if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
1529 1539 this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c());
1530 -@@ -1321,6 +2353,43 @@
1540 +@@ -1321,6 +2355,43 @@
1531 1541
1532 1542 boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
1533 1543 boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
1534 1544 + if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot
1535 1545 + // CraftBukkit start - Call click event
1536 1546 + InventoryView inventory = this.player.defaultContainer.getBukkitView();
1537 1547 + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
1538 1548 +
1539 1549 + SlotType type = SlotType.QUICKBAR;
1540 1550 + if (flag) {
1564 1574 + this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.b(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem()));
1565 1575 + this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.b));
1566 1576 + }
1567 1577 + return;
1568 1578 + }
1569 1579 + }
1570 1580 + // CraftBukkit end
1571 1581
1572 1582 if (flag1 && flag2) {
1573 1583 if (itemstack.isEmpty()) {
1574 -@@ -1342,6 +2411,7 @@
1584 +@@ -1342,6 +2413,7 @@
1575 1585 @Override
1576 1586 public void a(PacketPlayInTransaction packetplayintransaction) {
1577 1587 PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
1578 1588 + if (this.player.isFrozen()) return; // CraftBukkit
1579 1589 int i = this.player.activeContainer.windowId;
1580 1590
1581 1591 if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
1582 -@@ -1360,6 +2430,7 @@
1592 +@@ -1360,6 +2432,7 @@
1583 1593 }
1584 1594
1585 1595 private void a(PacketPlayInUpdateSign packetplayinupdatesign, List<String> list) {
1586 1596 + if (this.player.isFrozen()) return; // CraftBukkit
1587 1597 this.player.resetIdleTimer();
1588 1598 WorldServer worldserver = this.player.getWorldServer();
1589 1599 BlockPosition blockposition = packetplayinupdatesign.b();
1590 -@@ -1376,12 +2447,28 @@
1600 +@@ -1376,12 +2449,28 @@
1591 1601
1592 1602 if (!tileentitysign.d() || tileentitysign.f() != this.player) {
1593 1603 PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString());
1594 1604 + this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
1595 1605 return;
1596 1606 }
1597 1607
1598 1608 + // CraftBukkit start
1599 1609 + Player player = this.server.getPlayer(this.player);
1600 1610 + int x = packetplayinupdatesign.b().getX();
1610 1620 + this.server.getPluginManager().callEvent(event);
1611 1621 +
1612 1622 + if (!event.isCancelled()) {
1613 1623 + System.arraycopy(org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()), 0, tileentitysign.lines, 0, 4);
1614 1624 + tileentitysign.isEditable = false;
1615 1625 + }
1616 1626 + // CraftBukkit end
1617 1627
1618 1628 tileentitysign.update();
1619 1629 worldserver.notify(blockposition, iblockdata, iblockdata, 3);
1620 -@@ -1391,6 +2478,7 @@
1630 +@@ -1391,6 +2480,7 @@
1621 1631
1622 1632 @Override
1623 1633 public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
1624 1634 + PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit
1625 1635 if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) {
1626 1636 int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive);
1627 1637
1628 -@@ -1405,7 +2493,17 @@
1638 +@@ -1405,7 +2495,17 @@
1629 1639 @Override
1630 1640 public void a(PacketPlayInAbilities packetplayinabilities) {
1631 1641 PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
1632 1642 - this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly;
1633 1643 + // CraftBukkit start
1634 1644 + if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
1635 1645 + PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
1636 1646 + this.server.getPluginManager().callEvent(event);
1637 1647 + if (!event.isCancelled()) {
1638 1648 + this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status
1639 1649 + } else {
1640 1650 + this.player.updateAbilities(); // Tell the player their ability was reverted
1641 1651 + }
1642 1652 + }
1643 1653 + // CraftBukkit end
1644 1654 }
1645 1655
1646 1656 @Override
1647 -@@ -1414,8 +2512,50 @@
1657 +@@ -1414,8 +2514,50 @@
1648 1658 this.player.a(packetplayinsettings);
1649 1659 }
1650 1660
1651 1661 - @Override
1652 1662 - public void a(PacketPlayInCustomPayload packetplayincustompayload) {}
1653 1663 + // CraftBukkit start
1654 1664 + private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
1655 1665 + private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
1656 1666 +
1657 1667 + @Override

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut