当前位置: 首页>>代码示例>>Java>>正文


Java InventoryClickEvent.getClickedInventory方法代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:ijoeleoli,项目名称:ServerCommons,代码行数:20,代码来源:DankMenuListeners.java

示例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;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:21,代码来源:InventoryEvent.java

示例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());
        }
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:24,代码来源:GuiListener.java

示例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);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:26,代码来源:SaturationMenu.java

示例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);
        }
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:24,代码来源:PopulationMenu.java

示例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);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:20,代码来源:DemandMenu.java

示例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);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:19,代码来源:EconomyMenu.java

示例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);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:18,代码来源:TradeMenu.java

示例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();
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:25,代码来源:ResourceMenu.java

示例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);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:23,代码来源:GuiListener.java

示例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;
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:RiskyRetrievalModule.java

示例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;
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:16,代码来源:MilitaryMenu.java

示例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);
    }
}
 
开发者ID:Personinblack,项目名称:black,代码行数:8,代码来源:InventoryActionsListener.java

示例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);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:16,代码来源:MenuManager.java

示例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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:12,代码来源:NineSlotsModule.java


注:本文中的org.bukkit.event.inventory.InventoryClickEvent.getClickedInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。