Search in sources :

Example 6 with ClickType

use of org.bukkit.event.inventory.ClickType in project Glowstone by GlowstoneMC.

the class WindowClickLogicTest method testAction.

// slot numbers are normalized: slot > 0 is 0 instead
@Test
public void testAction() {
    for (String[] testCase : actionMap) {
        ClickType clickType = ClickType.valueOf(testCase[0]);
        int slot = Integer.parseInt(testCase[1]);
        ItemStack cursor = parseItemStack(testCase[2]);
        ItemStack slotItem = parseItemStack(testCase[3]);
        String expected = testCase[4];
        InventoryType.SlotType slotType = (slot < 0) ? InventoryType.SlotType.OUTSIDE : InventoryType.SlotType.CONTAINER;
        String actual = String.valueOf(WindowClickLogic.getAction(clickType, slotType, cursor, slotItem));
        assertThat("Failure for click=" + clickType + ", slot=" + slot + ", cursor=" + testCase[2] + ", slotItem=" + testCase[3], actual, is(expected));
    }
}
Also used : ClickType(org.bukkit.event.inventory.ClickType) InventoryType(org.bukkit.event.inventory.InventoryType) ItemStack(org.bukkit.inventory.ItemStack) Test(org.junit.jupiter.api.Test)

Aggregations

ClickType (org.bukkit.event.inventory.ClickType)6 ItemStack (org.bukkit.inventory.ItemStack)5 Player (org.bukkit.entity.Player)3 EventHandler (org.bukkit.event.EventHandler)3 Inventory (org.bukkit.inventory.Inventory)3 InventoryType (org.bukkit.event.inventory.InventoryType)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DragTracker (net.glowstone.inventory.DragTracker)1 GlowCraftingInventory (net.glowstone.inventory.GlowCraftingInventory)1 GlowInventory (net.glowstone.inventory.GlowInventory)1 GlowPlayerInventory (net.glowstone.inventory.GlowPlayerInventory)1 SetWindowSlotMessage (net.glowstone.net.message.play.inv.SetWindowSlotMessage)1 InteractItemRunnable (org.anhcraft.spaciouslib.inventory.InteractItemRunnable)1 Block (org.bukkit.block.Block)1 Sign (org.bukkit.block.Sign)1 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)1 CraftItemEvent (org.bukkit.event.inventory.CraftItemEvent)1 InventoryAction (org.bukkit.event.inventory.InventoryAction)1 InventoryClickEvent (org.bukkit.event.inventory.InventoryClickEvent)1