Commits
md_5 authored c175d4f6121
1601 1601 | if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) { |
1602 1602 | this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display())); |
1603 1603 | |
1604 1604 | @Override |
1605 1605 | public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { |
1606 1606 | PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); |
1607 1607 | + if (this.player.isImmobile()) return; // CraftBukkit |
1608 1608 | this.player.resetLastActionTime(); |
1609 1609 | if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { |
1610 1610 | if (!this.player.containerMenu.stillValid(this.player)) { |
1611 - | |
1611 + | |
1612 1612 | |
1613 1613 | boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; |
1614 1614 | boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); |
1615 1615 | + if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).getItem(), packetplayinsetcreativeslot.itemStack()))) { // Insist on valid slot |
1616 1616 | + // CraftBukkit start - Call click event |
1617 1617 | + InventoryView inventory = this.player.inventoryMenu.getBukkitView(); |
1618 1618 | + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.itemStack()); |
1619 1619 | + |
1620 1620 | + SlotType type = SlotType.QUICKBAR; |
1621 1621 | + if (flag) { |
1635 1635 | + switch (event.getResult()) { |
1636 1636 | + case ALLOW: |
1637 1637 | + // Plugin cleared the id / stacksize checks |
1638 1638 | + flag2 = true; |
1639 1639 | + break; |
1640 1640 | + case DEFAULT: |
1641 1641 | + break; |
1642 1642 | + case DENY: |
1643 1643 | + // Reset the slot |
1644 1644 | + if (packetplayinsetcreativeslot.slotNum() >= 0) { |
1645 - | + this.player.connection.send(new PacketPlayOutSetSlot(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinsetcreativeslot.slotNum(), this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).getItem())); |
1646 - | + this.player.connection.send(new PacketPlayOutSetSlot(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY)); |
1645 + | + this.player.inventoryMenu.sendAllDataToRemote(); |
1647 1646 | + } |
1648 1647 | + return; |
1649 1648 | + } |
1650 1649 | + } |
1651 1650 | + // CraftBukkit end |
1652 1651 | |
1653 1652 | if (flag1 && flag2) { |
1654 1653 | this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); |
1655 - | |
1654 + | |
1656 1655 | } |
1657 1656 | |
1658 1657 | private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) { |
1659 1658 | + if (this.player.isImmobile()) return; // CraftBukkit |
1660 1659 | this.player.resetLastActionTime(); |
1661 1660 | WorldServer worldserver = this.player.serverLevel(); |
1662 1661 | BlockPosition blockposition = packetplayinupdatesign.getPos(); |
1663 - | |
1662 + | |
1664 1663 | @Override |
1665 1664 | public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { |
1666 1665 | PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); |
1667 1666 | - this.player.getAbilities().flying = packetplayinabilities.isFlying() && this.player.getAbilities().mayfly; |
1668 1667 | + // CraftBukkit start |
1669 1668 | + if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != packetplayinabilities.isFlying()) { |
1670 1669 | + PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.player.getBukkitEntity(), packetplayinabilities.isFlying()); |
1671 1670 | + this.cserver.getPluginManager().callEvent(event); |
1672 1671 | + if (!event.isCancelled()) { |
1673 1672 | + this.player.getAbilities().flying = packetplayinabilities.isFlying(); // Actually set the player's flying status |
1674 1673 | + } else { |
1675 1674 | + this.player.onUpdateAbilities(); // Tell the player their ability was reverted |
1676 1675 | + } |
1677 1676 | + } |
1678 1677 | + // CraftBukkit end |
1679 1678 | } |
1680 1679 | |
1681 1680 | @Override |
1682 - | |
1681 + | |
1683 1682 | if (!this.waitingForSwitchToConfig) { |
1684 1683 | throw new IllegalStateException("Client acknowledged config, but none was requested"); |
1685 1684 | } else { |
1686 1685 | - this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation()))); |
1687 1686 | + this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation()), this.player)); // CraftBukkit |
1688 1687 | } |
1689 1688 | } |
1690 1689 | |
1691 - | |
1690 + | |
1692 1691 | }); |
1693 1692 | } |
1694 1693 | |
1695 1694 | - @Override |
1696 1695 | - public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {} |
1697 1696 | + // CraftBukkit start - handled in super |
1698 1697 | + // @Override |
1699 1698 | + // public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {} |
1700 1699 | + // CraftBukkit end |
1701 1700 | |