本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.isLeftClick方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.isLeftClick方法的具体用法?Java InventoryClickEvent.isLeftClick怎么用?Java InventoryClickEvent.isLeftClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.isLeftClick方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: click
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
* On a player click on an item call InventoryBase.
*
* @param e The bukkit event.
*/
private boolean click(InventoryClickEvent e) {
for (InventoryBase inv : InventoryBase.getInventories()) {
//Filter items
if (!inv.getItems().containsKey(e.getSlot()) || !inv.getItems().containsValue(e.getCurrentItem()))
continue;
//Setup methods
if (e.isLeftClick())
inv.onLeftClick((Player) e.getWhoClicked(), e.getCurrentItem());
else
inv.onRightClick((Player) e.getWhoClicked(), e.getCurrentItem());
return inv.isCancelled();
}
return false;
}
示例2: onInvClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInvClick(InventoryClickEvent e){
Inventory inv = e.getClickedInventory();
Player p = (Player) e.getWhoClicked();
if(inv == null) return;
if(e.getCurrentItem() == null) return;
Inventory tagGUI = getTagInventory(p);
if(inv.getHolder() == tagGUI.getHolder()){
if(inv.getTitle().equalsIgnoreCase(tagGUI.getTitle())){
e.setCancelled(true);
if(e.getCurrentItem().isSimilar(getRemoveItem(p))){
p.sendMessage(TagLang.CLEARED.get());
p.closeInventory();
StorageHandler.clearPlayerTag(p);
return;
}
if(e.getSlot() > DogTags.getTags().size()) return;
DogTag dt = DogTags.getTags().get(e.getSlot());
if(!hasPermission(p, dt)){
return;
}
if(e.isLeftClick() || e.isRightClick()) {
DTSelectEvent selectEvent = new DTSelectEvent(p, dt.getId());
Bukkit.getPluginManager().callEvent(selectEvent);
if(selectEvent.isCancelled()) return;
p.sendMessage(TagLang.SET.get().replace("%id%", dt.getId()).replace("%prefix%", dt.getPrefix()));
StorageHandler.setUser(p, dt.getId());
p.closeInventory();
}
}
}
}