當前位置: 首頁>>代碼示例>>Java>>正文


Java ClickType類代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.ClickType的典型用法代碼示例。如果您正苦於以下問題:Java ClickType類的具體用法?Java ClickType怎麽用?Java ClickType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClickType類屬於org.bukkit.event.inventory包,在下文中一共展示了ClickType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: __handleInvClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler
public final void __handleInvClick(InventoryClickEvent e) {
    Inventory clickedInventory = e.getClickedInventory();
    ClickType clickType = e.getClick();
    Player player = (Player) e.getWhoClicked();
    ItemStack clicked = e.getCurrentItem();

    if (clickedInventory == null)
        return;

    if (clickedInventory == inventory) {
        e.setCancelled(true);

        if (clicked != null) {
            BiConsumer<Player, ClickType> b;

            if ((b = clicks.get(e.getRawSlot())) != null) {
                b.accept(player, clickType);

                if (updateOnClick && ! destroyed)
                    update();
            }
        }
    }
}
 
開發者ID:shawlaf,項目名稱:Banmanager,代碼行數:26,代碼來源:UserInterface.java

示例2: onInteract

import org.bukkit.event.inventory.ClickType; //導入依賴的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

示例3: onInventoryClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack clicked = event.getCurrentItem();
    Inventory inventory = event.getInventory();

    if (inventory.getName().equals("Faction Management")) {

        if (clicked.getType() == Material.SKULL_ITEM) {
            if (event.getClick() == ClickType.LEFT) {
                Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.MIDDLE){
                Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.RIGHT) {
                Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:25,代碼來源:FactionManagerArgument.java

示例4: onInteract

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(final PlayerInteractEvent event) {
    if(cancelUnlessInteracting(event, event.getPlayer())) {
        // Allow the how-to book to be read
        if(event.getMaterial() == Material.WRITTEN_BOOK) {
            event.setUseItemInHand(Event.Result.ALLOW);
        } else {
            event.setUseItemInHand(Event.Result.DENY);
            event.setUseInteractedBlock(Event.Result.DENY);
        }

        MatchPlayer player = getMatch().getPlayer(event.getPlayer());
        if(player == null) return;

        if(!player.isSpawned()) {
            ClickType clickType = convertClick(event.getAction(), event.getPlayer());
            if(clickType == null) return;

            getMatch().callEvent(new ObserverInteractEvent(player, clickType, event.getClickedBlock(), null, event.getItem()));
        }

        // Right-clicking armor will put it on unless we do this
        event.getPlayer().updateInventory();
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:26,代碼來源:EventFilterMatchModule.java

示例5: rightClickIcon

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler
public void rightClickIcon(final ObserverInteractEvent event) {
    if(event.getClickType() != ClickType.RIGHT) return;

    MatchPlayer player = event.getPlayer();
    if(!canUse(player)) return;

    ItemStack hand = event.getClickedItem();
    if(ItemUtils.isNothing(hand)) return;

    String displayName = hand.getItemMeta().getDisplayName();
    if(displayName == null) return;

    if(hand.getType() == Button.JOIN.material) {
        event.setCancelled(true);
        if(canOpenWindow(player)) {
            showWindow(player);
        } else {
            // If there is nothing to pick, just join immediately
            jmm.requestJoin(player, JoinRequest.user());
        }
    } else if(hand.getType() == Button.LEAVE.material) {
        event.setCancelled(true);
        jmm.requestObserve(player);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:27,代碼來源:PickerMatchModule.java

示例6: showInventories

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void showInventories(final ObserverInteractEvent event) {
    if(event.getClickType() != ClickType.RIGHT) return;
    if(event.getPlayer().isDead()) return;

    if(event.getClickedParticipant() != null) {
        event.setCancelled(true);
        if(canPreviewInventory(event.getPlayer(), event.getClickedParticipant())) {
            this.previewPlayerInventory(event.getPlayer().getBukkit(), event.getClickedParticipant().getInventory());
        }
    } else if(event.getClickedEntity() instanceof InventoryHolder && !(event.getClickedEntity() instanceof Player)) {
        event.setCancelled(true);
        this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedEntity()).getInventory());
    } else if(event.getClickedBlockState() instanceof InventoryHolder) {
        event.setCancelled(true);
        this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedBlockState()).getInventory());
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:19,代碼來源:ViewInventoryMatchModule.java

示例7: onInteract

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInteract(PlayerInteractEvent event) {
    if(!event.hasItem()) return;

    final ClickType click;
    switch(event.getAction()) {
        case LEFT_CLICK_AIR:
        case LEFT_CLICK_BLOCK:
            click = ClickType.LEFT;
            break;

        case RIGHT_CLICK_AIR:
        case RIGHT_CLICK_BLOCK:
            click = ClickType.RIGHT;
            break;

        default:
            return;
    }

    if(onButtonClick(event.getItem(), event.getActor(), click, event)) {
        event.setUseItemInHand(Event.Result.DENY);
        event.setUseInteractedBlock(Event.Result.DENY);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:26,代碼來源:ButtonManager.java

示例8: onClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.equals("craft"))
    {
        if (SamaGamesAPI.get().getPlayerManager().getPlayerData(player.getUniqueId()).getPowders() >= 64)
        {
            this.hub.getGuiManager().openGui(player, new GuiWellCraft(this.hub, this.parent));
        }
        else
        {
            player.sendMessage(Well.TAG + ChatColor.RED + "Vous n'avez pas assez de poussières d'\u272F !");
        }
    }
    else if (action.equals("back"))
    {
        this.hub.getGuiManager().closeGui(player);
        this.parent.stop(player);
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:21,代碼來源:GuiWell.java

示例9: enableCosmetic

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void enableCosmetic(Player player, JukeboxDiskCosmetic cosmetic, ClickType clickType, boolean login)
{
    if (cosmetic.isOwned(player))
    {
        if (cosmetic.getAccessibility().canAccess(player))
        {
            this.play(cosmetic, player);

            AbstractGui gui = (AbstractGui) this.hub.getGuiManager().getPlayerGui(player);

            if (gui != null)
                gui.update(player);
        }
        else
        {
            player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.RED + "Vous n'avez pas le grade nécessaire pour utiliser cette cosmétique.");
        }
    }
    else
    {
        player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.RED + "Vous ne possédez pas ce cosmétique. Tentez de le débloquer auprès de Graou !");
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:25,代碼來源:JukeboxManager.java

示例10: enableCosmetic

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void enableCosmetic(Player player, ParticleCosmetic cosmetic, ClickType clickType, boolean login, NullType useless)
{
    try
    {
        Effect particleEffectObject = cosmetic.getParticleEffect().getConstructor(EffectManager.class).newInstance(this.effectManager);
        particleEffectObject.setEntity(player);
        particleEffectObject.infinite();
        particleEffectObject.start();

        this.playersParticleEffect.put(player.getUniqueId(), particleEffectObject);

        if (!login)
            player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.GREEN + "Vous voilà noyé sous les particules...");
    }
    catch (ReflectiveOperationException e)
    {
        this.hub.getCosmeticManager().log(Level.SEVERE, "Can't create EntityEffect object to " + player.getName() + "'s particle effect!");
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:21,代碼來源:ParticleManager.java

示例11: onClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.startsWith("cosmetic_"))
    {
        int cosmetic = Integer.parseInt(action.split("_")[1]);
        this.manager.enableCosmetic(player, this.manager.getRegistry().getElementByStorageId(cosmetic), clickType, false);
    }
    else if (action.equals("delete"))
    {
        this.manager.disableCosmetics(player, false, false);
    }
    else if (action.equals("back"))
    {
        this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:18,代碼來源:GuiCosmeticsCategory.java

示例12: onClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.startsWith("cosmetic_"))
    {
        int cosmetic = Integer.parseInt(action.split("_")[1]);
        this.hub.getCosmeticManager().getClothManager().enableCosmetic(player, this.hub.getCosmeticManager().getClothManager().getRegistry().getElementByStorageId(cosmetic), clickType, false);
    }
    else if (action.equals("delete"))
    {
        this.hub.getCosmeticManager().getClothManager().disableCosmetics(player, false, false);
    }
    else if (action.equals("back"))
    {
        this.hub.getGuiManager().openGui(player, new GuiClothingSets(this.hub));
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:18,代碼來源:GuiClothingSet.java

示例13: onClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.startsWith("set_"))
    {
        int setStorageId = Integer.parseInt(action.split("_")[1]);
        this.hub.getGuiManager().openGui(player, new GuiClothingSet(this.hub, ((ClothRegistry) this.hub.getCosmeticManager().getClothManager().getRegistry()).getClothingSetByStorageId(setStorageId)));
    }
    else if (action.equals("delete"))
    {
        this.hub.getCosmeticManager().getClothManager().disableCosmetics(player, false, false);
    }
    else if (action.equals("back"))
    {
        this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:18,代碼來源:GuiClothingSets.java

示例14: onClick

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.equals("back"))
    {
        if (this.before != null)
            this.hub.getGuiManager().openGui(player, this.before);
        else
            this.hub.getGuiManager().closeGui(player);
    }
    else if (!action.equals("none"))
    {
        String iconAction = action.split("_")[1];
        ShopIcon shopIcon = this.category.getIconByAction(iconAction);
        shopIcon.execute(player, clickType);
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:18,代碼來源:GuiShopCategory.java

示例15: GUICounter

import org.bukkit.event.inventory.ClickType; //導入依賴的package包/類
public GUICounter() {
    label = new GUILabel( "§a" + count, Material.REDSTONE );
    label.setPosition( position );
    label.setAmount( count );
    addEvent( new GUIEvent() {
        @Override
        public void onClick( ComponentClickEvent event ) {
            if ( event.getClick() == ClickType.LEFT ) {
                count += steps;
                if ( count < 64 ) {
                    label.setAmount( count );
                    label.setTitle( "§a" + GUICounter.this.count );
                    label.draw();
                }
            }
            else if ( event.getClick() == ClickType.RIGHT ) {
                count -= steps;
                if ( count > 0 ) {
                    label.setAmount( count );
                    label.setTitle( "§a" + GUICounter.this.count );
                    label.draw();
                }
            }
        }
    } );
}
 
開發者ID:LegendOnline,項目名稱:InventoryAPI,代碼行數:27,代碼來源:GUICounter.java


注:本文中的org.bukkit.event.inventory.ClickType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。