本文整理匯總了Java中org.bukkit.event.inventory.InventoryAction.COLLECT_TO_CURSOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java InventoryAction.COLLECT_TO_CURSOR屬性的具體用法?Java InventoryAction.COLLECT_TO_CURSOR怎麽用?Java InventoryAction.COLLECT_TO_CURSOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.inventory.InventoryAction
的用法示例。
在下文中一共展示了InventoryAction.COLLECT_TO_CURSOR屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectToCursor
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void collectToCursor(InventoryClickEvent event) {
// If this hasn't been cancelled yet, cancel it so our implementation can take over
if(event.getAction() == InventoryAction.COLLECT_TO_CURSOR) {
event.setCancelled(true);
this.collectToCursor = true;
}
}
示例2: onInventoryClick
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if(!inventories.containsKey(p))
return;
if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR ||
e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
e.setCancelled(true);
return;
}
if(e.getClickedInventory() == p.getOpenInventory().getTopInventory()) {
e.setCancelled(true);
int row = e.getSlot() / 9;
int column = e.getSlot() % 9;
if(row < 0 || column < 0)
return;
SmartInventory inv = inventories.get(p);
if(row >= inv.getRows() || column >= inv.getColumns())
return;
inv.getListeners().stream()
.filter(listener -> listener.getType() == InventoryClickEvent.class)
.forEach(listener -> ((InventoryListener<InventoryClickEvent>) listener).accept(e));
contents.get(p).get(row, column).ifPresent(item -> item.run(e));
}
}
示例3: onStoringFilter
/**
* See if a store/unstore event is possible through items being moved into an inventory. Then
* Storing the value in a array list while the inventory is open.
*
* @param evt The InventoryClickEvent used to check item movement
*/
@EventHandler
public void onStoringFilter(InventoryClickEvent evt) {
if (evt.getAction() == InventoryAction.SWAP_WITH_CURSOR
|| evt.getAction() == InventoryAction.COLLECT_TO_CURSOR
|| evt.getAction() == InventoryAction.PICKUP_SOME
|| evt.getAction() == InventoryAction.PICKUP_HALF
|| evt.getAction() == InventoryAction.PICKUP_ALL
|| evt.getAction() == InventoryAction.PICKUP_ONE) {
if (evt.getClickedInventory().getType() != null
&& evt.getView().getBottomInventory().getType() == InventoryType.PLAYER
&& (evt.getView().getTopInventory().getType() == InventoryType.CHEST
|| evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST
|| evt.getView().getTopInventory().getType() == InventoryType.HOPPER
|| evt.getView().getTopInventory().getType() == InventoryType.DISPENSER
|| evt.getView().getTopInventory().getType() == InventoryType.DROPPER)
&& evt.getClickedInventory().getType() == InventoryType.PLAYER
&& (!(storePossible.contains(evt.getWhoClicked())))) {
storePossible.add((Player) evt.getWhoClicked());
if (unstorePossible.contains(evt.getWhoClicked())) {
unstorePossible.remove(evt.getWhoClicked());
}
}
if (evt.getClickedInventory().getType() != null
&& evt.getView().getBottomInventory().getType() == InventoryType.PLAYER
&& (evt.getView().getTopInventory().getType() == InventoryType.CHEST
|| evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST
|| evt.getView().getTopInventory().getType() == InventoryType.HOPPER
|| evt.getView().getTopInventory().getType() == InventoryType.DISPENSER
|| evt.getView().getTopInventory().getType() == InventoryType.DROPPER)
&& (evt.getClickedInventory().getType() == InventoryType.CHEST
|| evt.getClickedInventory().getType() == InventoryType.ENDER_CHEST
|| evt.getClickedInventory().getType() == InventoryType.HOPPER
|| evt.getClickedInventory().getType() == InventoryType.DISPENSER
|| evt.getClickedInventory().getType() == InventoryType.DROPPER)
&& (!(unstorePossible.contains(evt.getWhoClicked())))) {
unstorePossible.add((Player) evt.getWhoClicked());
if (storePossible.contains(evt.getWhoClicked())) {
storePossible.remove(evt.getWhoClicked());
}
}
}
}