Java 类org.bukkit.event.inventory.InventoryType.SlotType 实例源码

项目:NucleusFramework    文件:ChestViewTest.java   
/**
 * Make sure the "onItemsPickup" method is invoked when
 * items are picked up in the inventory view.
 */
@Test
public void testOnItemsPickup() {

    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(2);

    // check "onItemsPickup" is invoked
    assertTrue(view.itemsPickup != null);
}
项目:NucleusFramework    文件:ChestViewTest.java   
/**
 * Make sure the "onItemsPlaced" method is invoked when
 * items are placed in the inventory view.
 */
@Test
public void testOnItemsPlaced() {
    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PLACE_ALL);

    BukkitTester.pause(2);

    // check "onItemsPlaced" is invoked
    assertTrue(view.itemsPlaced != null);
}
项目:NucleusFramework    文件:ChestViewTest.java   
/**
 * Make sure the "onItemsDropped" method is invoked when
 * items are dropped from the inventory view.
 */
@Test
public void testOnItemsDropped() {

    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.DROP_ALL_CURSOR);

    BukkitTester.pause(2);

    // check "onItemsDropped" is invoked
    assertTrue(view.itemsDropped != null);
}
项目:NucleusFramework    文件:MenuViewTest.java   
/**
 * Make sure {@link #onItemSelect} is invoked when a menu item is clicked
 * and that the correct {@link MenuItem} is passed into the invoked method.
 */
@Test
public void testOnItemSelected() {
    MockMenuView view = new MockMenuView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    MenuItem menuItem = new MenuItemBuilder(Material.WOOD).build(0);
    menuItem.setVisible(view, true);

    // select/click the menu item
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(2);

    // check "onItemSelected" is invoked with correct menu item
    assertEquals(menuItem, view.selected);
}
项目:Thermos-Bukkit    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Thermos-Bukkit    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Thermos-Bukkit    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:Statz    文件:VillagerTradesListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVillagerTrade(final InventoryClickEvent event) {

    final PlayerStat stat = PlayerStat.VILLAGER_TRADES;

    // Thanks to Lolmewn for this code (https://bitbucket.org/Lolmewn/stats/src/4eae2db1b21038a91b7d39181f27bdd3cd987324/src/main/java/nl/lolmewn/stats/stats/bukkit/BukkitTrades.java?at=3.0&fileviewer=file-view-default)

    if (event.getInventory().getType() != InventoryType.MERCHANT) {
        return;
    }
    if (!event.getSlotType().equals(SlotType.RESULT)) {
        return;
    }
    if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
            && !event.getAction().equals(InventoryAction.PICKUP_ALL)) {
        return;
    }
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getWhoClicked();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    ItemStack item = event.getCurrentItem();

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
            StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", item.getAmount(), "world",
                    player.getWorld().getName(), "trade", item.getType().toString()));

}
项目:CauldronGit    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:CauldronGit    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:CauldronGit    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:acidisland    文件:TopTen.java   
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
public void onInventoryClick(InventoryClickEvent event) {
    Inventory inventory = event.getInventory(); // The inventory that was clicked in
    if (inventory.getName() == null) {
        return;
    }
    // The player that clicked the item
    Player player = (Player) event.getWhoClicked();
    if (!inventory.getTitle().equals(plugin.myLocale(player.getUniqueId()).topTenGuiTitle)) {
        return;
    }
    event.setCancelled(true);
    player.updateInventory();
    if(event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.SKULL_ITEM) && event.getCurrentItem().hasItemMeta()){
        Util.runCommand(player, "is warp " + ((SkullMeta)event.getCurrentItem().getItemMeta()).getOwner());
        player.closeInventory();
        return;
    }
    if (event.getSlotType().equals(SlotType.OUTSIDE)) {
        player.closeInventory();
        return;
    }
    if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
        player.closeInventory();
        return;
    }
}
项目:askyblock    文件:TopTen.java   
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
public void onInventoryClick(InventoryClickEvent event) {
    Inventory inventory = event.getInventory(); // The inventory that was clicked in
    if (inventory.getName() == null) {
        return;
    }
    // The player that clicked the item
    Player player = (Player) event.getWhoClicked();
    if (!inventory.getTitle().equals(plugin.myLocale(player.getUniqueId()).topTenGuiTitle)) {
        return;
    }
    event.setCancelled(true);
    player.updateInventory();
    if(event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.SKULL_ITEM) && event.getCurrentItem().hasItemMeta()){
        Util.runCommand(player, "is warp " + ((SkullMeta)event.getCurrentItem().getItemMeta()).getOwner());
        player.closeInventory();
        return;
    }
    if (event.getSlotType().equals(SlotType.OUTSIDE)) {
        player.closeInventory();
        return;
    }
    if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
        player.closeInventory();
        return;
    }
}
项目:StarQuestCode    文件:SQSpace.java   
@EventHandler
public void onHelmetChange(final InventoryClickEvent event) {

    if (event.getSlotType().equals(SlotType.ARMOR) && (103 == event.getSlot())) {
        this.checkIfSuffocating((Player) event.getWhoClicked());
    }
}
项目:Cauldron    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:Cauldron    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:Cauldron    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Cauldron    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:BetonQuest    文件:CraftingObjective.java   
@EventHandler(priority=EventPriority.LOW)
public void onShiftCrafting(InventoryClickEvent event) {
    if (event.getSlotType() == SlotType.RESULT
            && event.getClick().equals(ClickType.SHIFT_LEFT)
            && event.getWhoClicked() instanceof Player) {
        Player player = (Player) event.getWhoClicked();
        String playerID = PlayerConverter.getID(player);
        if (containsPlayer(playerID)) {
            event.setCancelled(true);
        }
    }
}
项目:Almura-API    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    if (slot < 0) {
        this.clickedInventory = null;
    } else if (view.getTopInventory() != null && slot < view.getTopInventory().getSize()) {
        this.clickedInventory = view.getTopInventory();
    } else {
        this.clickedInventory = view.getBottomInventory();
    }
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Almura-API    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Almura-API    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:NucleusFramework    文件:MenuItemTest.java   
/**
 * Make sure the on-click callbacks are run when the menu item
 * is clicked..
 */
@Test
public void testOnClick() throws Exception {

    MenuItem menuItem = new MenuItemBuilder(Material.STONE)
            .title("test")
            .onClick(new Runnable() {
                @Override
                public void run() {
                    _isOnClickRun = true;
                }
            })
            .build(0);

    MockMenuView view = new MockMenuView(plugin, null);
    ViewSession session = ViewSession.get(player, null);

    // open a menu view
    session.next(view);
    BukkitTester.pause(5);

    // set the item in the menu view
    menuItem.setVisible(view, true);
    BukkitTester.pause(5);

    // click the menu item
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);
    BukkitTester.pause(5);

    // make sure the items on click runnables ran
    assertEquals(true, _isOnClickRun);
}
项目:NucleusFramework    文件:PaginatorViewTest.java   
/**
 * Make sure selecting a page works properly.
 */
@Test
public void testSelectPage() {

    ArrayListPaginator<String> paginator = new ArrayListPaginator<String>(PageStartIndex.ONE, 9);

    // add enough to produce 2 pages
    paginator.addAll(ArrayUtils.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"));

    PaginatorView view = new PaginatorView(plugin, paginator, null);

    // show the paginator to the player
    _session.next(view);
    BukkitTester.pause(5);

    // ensure that page 2 items are shown in the view
    assertTrue(view.getInventoryView().getItem(0) != null);
    assertTrue(view.getInventoryView().getItem(1) != null);
    assertTrue(view.getInventoryView().getItem(2) == null);

    // click on inventory slot index 1 (page 2)
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(5);

    // make sure the paginator reports that page 2 was selected.
    assertEquals(2, view.getSelectedPage());

    // make sure paginator closes itself when page is selected
    assertEquals(null, _session.getCurrent());
}
项目:Spigot-API    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    if (slot < 0) {
        this.clickedInventory = null;
    } else if (view.getTopInventory() != null && slot < view.getTopInventory().getSize()) {
        this.clickedInventory = view.getTopInventory();
    } else {
        this.clickedInventory = view.getBottomInventory();
    }
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Spigot-API    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Spigot-API    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:Bukkit-JavaDoc    文件:InventoryClickEvent.java   
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
项目:Bukkit-JavaDoc    文件:InventoryClickEvent.java   
/**
 * Gets the ItemStack currently in the clicked slot. Returns air for empty
 * slots and null for clicking outside the inventory.
 *
 * @return the item in the clicked slot
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
项目:Bukkit-JavaDoc    文件:InventoryClickEvent.java   
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
项目:Zephyrus    文件:ArmourEffect.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
    if (e.getSlotType() == SlotType.ARMOR
            && EffectHandler.hasEffect(e.getWhoClicked().getName(), EffectType.ARMOUR)) {
        e.setCancelled(true);
    }
}
项目:Uranium    文件:CraftInventoryView.java   
public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
            type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
项目:ExoticGarden    文件:FoodListener.java   
@EventHandler
public void onEquip(InventoryClickEvent e) {
    if (e.getSlotType() != SlotType.ARMOR) return;
    SlimefunItem item = SlimefunItem.getByItem(e.getCursor());
    if (item != null && (item instanceof EGPlant) && e.getCursor().getType() == Material.SKULL_ITEM) e.setCancelled(true);
}
项目:ThermosRebased    文件:CraftInventoryView.java   
public static SlotType getSlotType(InventoryView inventory, int slot) {
    SlotType type = SlotType.CONTAINER;
    if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
    if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
        switch(inventory.getType()) {
        case FURNACE:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else if(slot == 1) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BREWING:
            if (slot == 3) {
                type = SlotType.FUEL;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case ENCHANTING:
            type = SlotType.CRAFTING;
            break;
        case WORKBENCH:
        case CRAFTING:
            if (slot == 0) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case MERCHANT:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        case BEACON:
            type = SlotType.CRAFTING;
            break;
        case ANVIL:
            if (slot == 2) {
                type = SlotType.RESULT;
            } else {
                type = SlotType.CRAFTING;
            }
            break;
        default:
            // Nothing to do, it's a CONTAINER slot
        }
    } else {
        if (slot == -999) {
            type = SlotType.OUTSIDE;
        } else if (inventory.getType() == InventoryType.CRAFTING) {
            if (slot < 9) {
            type = SlotType.ARMOR;
            } else if (slot > 35) {
                type = SlotType.QUICKBAR;
            }
        } else if (slot >= (inventory.countSlots() - 9)) {
            type = SlotType.QUICKBAR;
        }
    }
    return type;
}
项目:Thermos-Bukkit    文件:InventoryClickEvent.java   
@Deprecated
public InventoryClickEvent(InventoryView view, SlotType type, int slot, boolean right, boolean shift) {
    this(view, type, slot, right ? (shift ? ClickType.SHIFT_RIGHT : ClickType.RIGHT) : (shift ? ClickType.SHIFT_LEFT : ClickType.LEFT), InventoryAction.SWAP_WITH_CURSOR);
}