mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Fixed IncompatibleClassChangeError on inventory transactions (fixes #571)
This commit is contained in:
parent
40e7f04774
commit
ce8c194e0d
@ -80,7 +80,7 @@ public final class CraftItemListener extends Queue implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory bottomInventory = event.getView().getBottomInventory();
|
||||
Inventory bottomInventory = player.getInventory();
|
||||
if (bottomInventory.getType() != InventoryType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.inventory.BlockInventoryHolder;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
@ -251,7 +250,12 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
||||
// Perform this check to prevent triggering onInventoryInteractAsync when a user is just clicking items in their own inventory
|
||||
Inventory inventory = null;
|
||||
try {
|
||||
inventory = event.getView().getInventory(event.getRawSlot());
|
||||
try {
|
||||
inventory = event.getView().getInventory(event.getRawSlot());
|
||||
}
|
||||
catch (IncompatibleClassChangeError e) {
|
||||
inventory = event.getClickedInventory();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return;
|
||||
@ -288,19 +292,16 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
||||
protected void onInventoryDragEvent(InventoryDragEvent event) {
|
||||
boolean movedItem = false;
|
||||
boolean enderChest = false;
|
||||
InventoryView inventoryView = event.getView();
|
||||
for (Integer slot : event.getRawSlots()) {
|
||||
Inventory inventory = inventoryView.getInventory(slot);
|
||||
if (inventory == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
InventoryHolder inventoryHolder = inventory.getHolder();
|
||||
enderChest = inventory.equals(event.getWhoClicked().getEnderChest());
|
||||
if ((inventoryHolder != null && (inventoryHolder instanceof BlockInventoryHolder || inventoryHolder instanceof DoubleChest)) || enderChest) {
|
||||
movedItem = true;
|
||||
break;
|
||||
}
|
||||
Inventory inventory = event.getInventory();
|
||||
if (inventory == null || inventory.equals(event.getWhoClicked().getInventory())) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryHolder inventoryHolder = inventory.getHolder();
|
||||
enderChest = inventory.equals(event.getWhoClicked().getEnderChest());
|
||||
if ((inventoryHolder != null && (inventoryHolder instanceof BlockInventoryHolder || inventoryHolder instanceof DoubleChest)) || enderChest) {
|
||||
movedItem = true;
|
||||
}
|
||||
|
||||
if (!movedItem) {
|
||||
|
Loading…
Reference in New Issue
Block a user