本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.getClickedInventory方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.getClickedInventory方法的具体用法?Java InventoryClickEvent.getClickedInventory怎么用?Java InventoryClickEvent.getClickedInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.getClickedInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
DankMenu menu = DankMenu.getByPlayer(player);
if (menu == null) {
return;
}
event.setCancelled(true);
if (event.getClickedInventory() != null && event.getClickedInventory().getTitle().equals(menu.getInventory().getTitle())) {
menu.onClickItem(event.getCurrentItem(), event.isRightClick());
if (menu.getPlayer() != null && menu.getInventory() != null) {
menu.updateInventory();
}
}
}
示例2: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
WCUser user = new WCUser(p.getUniqueId());
Inventory inv = e.getClickedInventory();
ItemStack i = e.getCurrentItem();
switch (ChatColor.stripColor(inv.getName())){
case "Servidores":
switch (e.getSlot()){
case 21:
user.sendToServer("survival");
break;
default:
break;
}
break;
}
}
示例3: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getWhoClicked() instanceof Player)
{
Player player = (Player) event.getWhoClicked();
AbstractGui gui = (AbstractGui) this.hub.getGuiManager().getPlayerGui(player);
if (event.getClickedInventory() instanceof PlayerInventory)
{
this.hub.getPlayerManager().getStaticInventory().doInteraction(player, event.getCurrentItem());
return;
}
if (gui != null)
{
String action = gui.getAction(event.getSlot());
if (action != null)
gui.onClick(player, event.getCurrentItem(), action, event.getClick());
}
}
}
示例4: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = inventory.getItem(event.getSlot());
if (button == null) {
return;
}
Resource resource = getResource(gui);
int current = faction.getConsumableResources().get(resource);
if (button.equals(GUIButton.BACK)) {
faction.getPopulationMenu().openDemands(player);
return;
} else if (button.equals(DENY_BUTTON)) {
faction.getConsumableResources().put(resource, current - 1);
} else if (button.equals(GRANT_BUTTON)) {
faction.getConsumableResources().put(resource, current + 1);
}
update(resource);
}
示例5: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
Inventory inventory = event.getClickedInventory();
HumanEntity player = event.getWhoClicked();
if (inventory == null || !main.getTitle().equals(inventory.getTitle()) & !demands.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = event.getCurrentItem();
if (GUIButton.BACK.equals(button)) {
openMain(player);
} else if (DEMANDS.equals(button)) {
openDemands(player);
} else if (MILITARY.equals(button)) {
military.open(player);
} else {
ResourceSubcategory category = ResourceSubcategory.getByIcon(button);
if (category != null) {
demandResources.open(player, category);
}
}
}
示例6: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || gui == null || !gui.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = event.getCurrentItem();
if (BACK.equals(button)) {
faction.getPopulationMenu().openDemands(player);
return;
}
Resource resource = Resource.getByIcon(button);
if (resource != null && faction.isPrivileged(player)) {
saturationMenu.open(player, resource);
}
}
示例7: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = event.getCurrentItem();
if (INCOME_MANAGEMENT.equals(button)) {
faction.getTradeMenu().open(player);
} else if (TRADE_OFFER.equals(button)) {
plugin.getCommandCache().tradeOffer.onExecute(new String[]{"tradeOffer", faction.getName()}, player);
} else if (STORAGE.equals(button)) {
plugin.getCommandCache().storage.onExecute(new String[]{"storage", faction.getName()}, player);
}
}
示例8: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || !gui.getTitle().equals(inventory.getTitle()) || event.getSlot() >= 45) {
return;
}
ItemStack button = inventory.getItem(event.getSlot());
if (button == null || button.equals(DISABLED)) {
return;
}
if (!faction.isPrivileged(event.getWhoClicked())) {
return;
}
Resource resource = Resource.getByIcon(button);
openResourceMenu(player, resource);
}
示例9: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = inventory.getItem(event.getSlot());
if (button == null) {
return;
}
int current = faction.getImportValue(resource);
if (button.equals(BACK)) {
faction.getTradeMenu().open(player);
return;
} else if (button.equals(exportButton)) {
faction.getGroceryList().put(resource, current - 1);
} else if (button.equals(importButton)) {
faction.getGroceryList().put(resource, current + 1);
}
update();
}
示例10: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getWhoClicked() instanceof Player)
{
Player player = (Player) event.getWhoClicked();
AbstractGui gui = manager.getPlayerGui(player);
if (gui != null)
{
if (event.getClickedInventory() instanceof PlayerInventory)
return;
String action = gui.getAction(event.getSlot());
if (action != null)
gui.onClick(player, event.getCurrentItem(), action, event.getClick());
event.setCancelled(true);
}
}
}
示例11: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
* Disable putting items in inventory
*
* @param event Click event instance
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().equals(this.inventory))
return;
switch (event.getAction())
{
case PICKUP_ALL:
case PICKUP_HALF:
case PICKUP_ONE:
case PICKUP_SOME:
event.setCancelled(false);
break;
default:
event.setCancelled(true);
break;
}
}
示例12: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if (inventory == null || gui == null || !gui.getTitle().equals(inventory.getTitle())) {
return;
}
event.setCancelled(true);
PageGUI.playSound(event);
ItemStack button = event.getCurrentItem();
if (BACK.equals(button)) {
faction.getPopulationMenu().openMain(player);
return;
}
}
示例13: clickListener
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void clickListener(InventoryClickEvent event) {
if (event.getInventory().getHolder() instanceof Page
&& !(event.getClickedInventory() instanceof PlayerInventory)) {
((Page) event.getInventory().getHolder()).accept(event);
}
}
示例14: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent e) {
Inventory inventory = e.getClickedInventory();
Player p = (Player) e.getWhoClicked();
if (e.getClickedInventory() == null) return;
if (e.getCurrentItem() == null) return;
if (!this.menuHashMap.containsKey(p.getName())) return;
if (inventory.getTitle().equals("") || inventory.getTitle().isEmpty()) return;
Menu menu = getMenu(p);
if (menu == null) return;
if (menu.getElement(e.getRawSlot()) == null) return;
menu.getElement(e.getRawSlot()).click(e);
}
示例15: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
* Disable barrier taking in the players inventories
*
* @param event Event
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getClickedInventory() != null && event.getClickedInventory().getType() == InventoryType.PLAYER && event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.BARRIER)
event.setCancelled(true);
}