mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-24 00:51:22 +01:00
Don't throw error when swapping armor slots into the offhand.
Lots of conflicting info here, but the offhand slot is in fact part of the quickbar/hotbar (yay bukkit naming) but does *not* use a hotbar "button", since it has its own hotkey (i.e., F by default instead of 0-8). The result is a hotbar_swap *action* with a swap_offhand *clicktype*. Fixes #1698.
This commit is contained in:
parent
04d5a3b437
commit
cbb3212082
@ -49,6 +49,7 @@
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
@ -58,6 +59,7 @@
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.createTarget;
|
||||
|
||||
@ -330,6 +332,9 @@ private ItemStack checkEquipped(InventoryClickEvent event) {
|
||||
return cursor;
|
||||
}
|
||||
case HOTBAR_SWAP:
|
||||
if (event.getClick() == ClickType.SWAP_OFFHAND) {
|
||||
return clickedInventory == null ? null : ((PlayerInventory) clickedInventory).getItemInOffHand();
|
||||
}
|
||||
return clickedInventory == null ? null : clickedInventory.getItem(event.getHotbarButton());
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user