Skip to content

Commit

Permalink
fix: don't prevent moving shield to chests in disable offhand module
Browse files Browse the repository at this point in the history
  • Loading branch information
kernitus committed Oct 28, 2024
1 parent 8aa3fa3 commit b299df2
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;

Expand Down Expand Up @@ -52,7 +53,7 @@ public void reload() {
}

private void sendDeniedMessage(CommandSender sender) {
if (deniedMessage.trim().length() > 0)
if (!deniedMessage.trim().isEmpty())
Messenger.send(sender, deniedMessage);
}

Expand Down Expand Up @@ -83,8 +84,14 @@ public void onInventoryClick(InventoryClickEvent e) {
final Inventory clickedInventory = e.getClickedInventory();
if (clickedInventory == null) return;
final InventoryType inventoryType = clickedInventory.getType();
// If they're in their own inventory, and not chests etc.
if (inventoryType != InventoryType.PLAYER) return;
// Source inventory must be PLAYER
if(inventoryType != InventoryType.PLAYER) return;

final InventoryView view = e.getView();
// If neither of the inventories is CRAFTING, player cannot be moving stuff to the offhand
if (view.getBottomInventory().getType() != InventoryType.CRAFTING &&
view.getTopInventory().getType() != InventoryType.CRAFTING)
return;

// Prevent shift-clicking a shield into the offhand item slot
final ItemStack currentItem = e.getCurrentItem();
Expand Down

0 comments on commit b299df2

Please sign in to comment.