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


Java InventoryClickEvent类代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent类的具体用法?Java InventoryClickEvent怎么用?Java InventoryClickEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InventoryClickEvent类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryClickEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
protected void onClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    int rawSlot = event.getRawSlot();
    boolean isFrame = isFrame(rawSlot);
    if (isFrame) {
        event.setCancelled(true);
    }
    if (rawSlot == prevPageBtnIndex) {
        prevPage(player);
    } else if (rawSlot == nextPageBtnIndex) {
        nextPage(player);
    } else if (!isFrame) {
        InventoryClickEvent converted = convert(event);
        getHandlers().notify(converted);
        event.setCancelled(converted.isCancelled());
        return;
    }
    open(event.getWhoClicked());
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:21,代码来源:PageGUI.java

示例2: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e) {
    guiMap.getOptional(e.getWhoClicked()).ifPresent(gui -> {
        InventoryAction action = e.getAction();
        Inventory inv = e.getInventory();

        if (action == InventoryAction.COLLECT_TO_CURSOR) {
            for (ItemStack item : inv) {
                if (e.getCursor().isSimilar(item)) {
                    e.setCancelled(true);
                    break;
                }
            }
        }

        gui.getHandlers().notify(e);
    });
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:19,代码来源:GUI.java

示例3: onInventoryClick2

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
	Player player = (Player) event.getWhoClicked();
	ItemStack is = event.getCurrentItem();
	if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
		if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
			event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
            		player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
            		player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
            		player.playEffect(location, Effect.ENDER_SIGNAL, 1);
            		targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);	
                }
               }
           }
       }
   }
 
开发者ID:SlamTheHam,项目名称:UltraCore,代码行数:23,代码来源:Events.java

示例4: onInventoryClick1

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                    player.closeInventory();
                    player.teleport(targetPlayer);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
 
开发者ID:SlamTheHam,项目名称:UltraCore,代码行数:23,代码来源:Events.java

示例5: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
/**
 * Event fired when a player clicks in the team selection GUI
 *
 * @param event Event
 */
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
    {
        event.getHandlers().unregister(this);
    }
    else if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getView().getType() != InventoryType.PLAYER)
    {
        AbstractGui gui = this.playersGui.get(event.getWhoClicked().getUniqueId());

        if (gui != null)
        {
            String action = gui.getAction(event.getSlot());

            if (action != null)
                gui.onClick((Player) event.getWhoClicked(), event.getCurrentItem(), action, event.getClick());

            event.setCancelled(true);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:SurvivalTeamSelector.java

示例6: onInventoryMove

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryMove(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getWhoClicked();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() == PlayerStatus.EDITING_KITS || profile.getStatus() == PlayerStatus.PLAYING) {
        return;
    }

    if ((player.hasPermission("practice.admin") || player.isOp()) && player.getGameMode() == GameMode.CREATIVE) {
        return;
    }

    event.setCancelled(true);
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:20,代码来源:PlayerListener.java

示例7: call

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof InventoryClickEvent) {
		final InventoryClickEvent ice = (InventoryClickEvent) event;

		if (ice.getCurrentItem().getType() == Material.BOWL) {

			final int slot = ice.getSlot();

			if (!slotsChosen.containsKey(slot)) {
				slotsChosen.put(slot, 1);
			} else {
				slotsChosen.put(slot, slotsChosen.get(slot) + 1);
			}

			if (getStackChance() >= 100.0) {
				callback(true);
			}
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:22,代码来源:InventoryTweaksB.java

示例8: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
/**
 * Called when a player clicks on the inventory, the filters to check if the Player clicked on the GUi's inventory should be made outside of this method
 *
 * @param event the click event
 */
public void onClick(InventoryClickEvent event) {
    HumanEntity h = event.getWhoClicked();
    if (!(h instanceof Player))
        return;
    LinkedList<Gui> g = histories.get(h);
    if (g != null && !g.isEmpty()) {
        Gui gui = g.peek();
        GuiClickEvent e = new GuiClickEvent(event, (Player) h, gui);
        Bukkit.getPluginManager().callEvent(e);
        if (e.isCancelled())
            return;

        //Event cancelled BEFORE the method call to permit the un-cancelling
        event.setCancelled(true);
        gui.onClick(event);
        //Creative idiots could copy the links
        if (event.isShiftClick() && event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
            ((Player) event.getWhoClicked()).updateInventory();
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:26,代码来源:GuiManager.java

示例9: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void onClick(InventoryClickEvent event) {
    if (buffer == null)
        throw new IllegalStateException("Cannot click a non-existant inventory");
    int slot = event.getSlot();
    if (slot < 0)
        return;
    int footerStart = buffer.getSize() - footer.size() - 1;
    Icon clicked;
    if(slot > footerStart) {
        clicked = footer.get(slot - footerStart - 1);
    } else if(slot < buffer.getSize()) {
        clicked = icons.get(slot);
    } else return;

    if (clicked != null)
        clicked.getClick().run((Player) event.getWhoClicked());
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:19,代码来源:SimpleGui.java

示例10: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void onClick(InventoryClickEvent event) {
    int slot = event.getSlot();
    if(slot < 0)
        return;
    Player clicker = (Player) event.getWhoClicked();
    int page = pageRegistry.getOrDefault(clicker, 0);
    Icon clicked = getIcon(page, slot);
    if(clicked != null)
        clicked.getClick().run(clicker);
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:12,代码来源:MenuGui.java

示例11: 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

示例12: 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

示例13: 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;
}
 
开发者ID:AnanaGame,项目名称:pine-commons,代码行数:23,代码来源:InventoryListener.java

示例14: onInteract

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInteract(InventoryClickEvent e) {
	Player player = (Player) e.getWhoClicked();
	
	if(!ChatColor.stripColor(e.getClickedInventory().getTitle()).equalsIgnoreCase("HCRiots Donator Kits")) {
		return;
	}
	
	if(e.getInventory().getSize() != 45) {
		return;
	}
	
	if(e.getClick() != ClickType.LEFT) {
		return;
	}
	
	if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Titanium Kit")) {
		this.giveTitaniumKit(player);
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:KitsCommand.java

示例15: onMove

import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onMove(InventoryClickEvent e) {
    Player p = (Player) e.getWhoClicked();
    
    if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Disable")) {
		if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.World.All_World")) {
			if (WorldUtils.getWMoveItem().contains(p.getWorld().getName())) {
 			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
                 if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
                     e.setCancelled(true);
                 }
             } else {
                 e.setCancelled(true);
             }
			}
		} else {
			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
                if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
                    e.setCancelled(true);
                }
            } else {
                e.setCancelled(true);
            }
		}
    }
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:27,代码来源:BasicFeatures.java


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