summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-11-19 13:51:10 +1100
committermd_5 <git@md-5.net>2016-11-19 13:51:10 +1100
commit32048c46904db321719d30a9ed2312e361f8d889 (patch)
tree7c72960f7eda47c446c65ecb2c85d6c578dd2e1e /nms-patches
parent26377b763b2877b033d33ddd865d07faeb590d0c (diff)
downloadcraftbukkit-32048c46904db321719d30a9ed2312e361f8d889.tar
craftbukkit-32048c46904db321719d30a9ed2312e361f8d889.tar.gz
craftbukkit-32048c46904db321719d30a9ed2312e361f8d889.tar.lz
craftbukkit-32048c46904db321719d30a9ed2312e361f8d889.tar.xz
craftbukkit-32048c46904db321719d30a9ed2312e361f8d889.zip
SPIGOT-2795: InventoryClickEvent issues
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/PlayerConnection.patch20
1 files changed, 10 insertions, 10 deletions
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index 9bb29cef..d52bdf5d 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1154,7 +1154,7 @@
+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
+ if (packetplayinwindowclick.b() == -999) {
-+ if (player.inventory.getCarried() != null) {
++ if (!player.inventory.getCarried().isEmpty()) {
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
+ }
+ } else if (packetplayinwindowclick.b() < 0) {
@@ -1164,12 +1164,12 @@
+ if (slot != null) {
+ ItemStack clickedItem = slot.getItem();
+ ItemStack cursor = player.inventory.getCarried();
-+ if (clickedItem == null) {
-+ if (cursor != null) {
++ if (clickedItem.isEmpty()) {
++ if (!cursor.isEmpty()) {
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
+ }
+ } else if (slot.isAllowed(player)) {
-+ if (cursor == null) {
++ if (cursor.isEmpty()) {
+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
+ } else if (slot.isAllowed(cursor)) {
+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
@@ -1227,7 +1227,7 @@
+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
+ if (clickedSlot.isAllowed(player)) {
+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
-+ boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
++ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
+ if (clickedSlot.hasItem()) {
+ if (canCleanSwap) {
+ action = InventoryAction.HOTBAR_SWAP;
@@ -1239,7 +1239,7 @@
+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
+ }
+ }
-+ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
++ } else if (!clickedSlot.hasItem() && !hotbar.isEmpty() && clickedSlot.isAllowed(hotbar)) {
+ action = InventoryAction.HOTBAR_SWAP;
+ } else {
+ action = InventoryAction.NOTHING;
@@ -1256,7 +1256,7 @@
+ action = InventoryAction.NOTHING;
+ } else {
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) {
++ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried().isEmpty()) {
+ action = InventoryAction.CLONE_STACK;
+ } else {
+ action = InventoryAction.NOTHING;
@@ -1272,7 +1272,7 @@
+ if (packetplayinwindowclick.c() == 0) {
+ click = ClickType.DROP;
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
++ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
+ action = InventoryAction.DROP_ONE_SLOT;
+ } else {
+ action = InventoryAction.NOTHING;
@@ -1280,7 +1280,7 @@
+ } else if (packetplayinwindowclick.c() == 1) {
+ click = ClickType.CONTROL_DROP;
+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
++ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
+ action = InventoryAction.DROP_ALL_SLOT;
+ } else {
+ action = InventoryAction.NOTHING;
@@ -1301,7 +1301,7 @@
+ case PICKUP_ALL:
+ click = ClickType.DOUBLE_CLICK;
+ action = InventoryAction.NOTHING;
-+ if (packetplayinwindowclick.b() >= 0 && this.player.inventory.getCarried() != null) {
++ if (packetplayinwindowclick.b() >= 0 && !this.player.inventory.getCarried().isEmpty()) {
+ ItemStack cursor = this.player.inventory.getCarried();
+ action = InventoryAction.NOTHING;
+ // Quick check for if we have any of the item