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


Java ClickType.LEFT屬性代碼示例

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


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

示例1: onInteract

@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,代碼行數:25,代碼來源:ButtonManager.java

示例2: onInteract

@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,代碼行數:20,代碼來源:KitsCommand.java

示例3: onInventoryClick

@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,代碼行數:24,代碼來源:FactionManagerArgument.java

示例4: convertClick

@Nullable ClickType convertClick(Action action, Player player) {
    switch(action) {
        case LEFT_CLICK_BLOCK:
        case LEFT_CLICK_AIR:
            return ClickType.LEFT;

        case RIGHT_CLICK_BLOCK:
        case RIGHT_CLICK_AIR:
            return convertClick(ClickType.RIGHT, player);

        default:
            return null;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:14,代碼來源:EventFilterMatchModule.java

示例5: onClick

@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.startsWith("slot_"))
    {
        int slot = Integer.parseInt(action.split("_")[1]);

        if (clickType == ClickType.LEFT && this.getRemainingPowders() > 0)
        {
            this.numbers[slot]++;
        }
        else if (clickType == ClickType.RIGHT && this.numbers[slot] > 0)
        {
            this.numbers[slot]--;
        }

        this.update(player);
    }
    else if (action.equals("confirm"))
    {
        if (this.getRemainingPowders() == 0)
        {
            this.hub.getInteractionManager().getWellManager().startPearlCrafting(player, this.numbers);
            this.hub.getGuiManager().openGui(player, new GuiWell(this.hub, this.parent));
        }
        else
        {
            player.sendMessage(Well.TAG + ChatColor.RED + "Vous devez placer l'intégralité des poussières d'\u272F !");
        }
    }
    else if (action.equals("reset"))
    {
        System.arraycopy(new int[] {0, 0, 0, 0}, 0, this.numbers, 0, 4);
        this.update(player);
    }
    else if (action.equals("back"))
    {
        this.hub.getGuiManager().openGui(player, new GuiWell(this.hub, this.parent));
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:40,代碼來源:GuiWellCraft.java

示例6: onClick

@EventHandler
public void onClick(InventoryClickEvent e) {
    if (ChatColor.stripColor(e.getInventory().getTitle()).equals("장신구 장착")) {
        if (e.getSlotType() != InventoryType.SlotType.OUTSIDE) {
            if ((e.getClick() == ClickType.RIGHT) || (e.getClick() == ClickType.LEFT)) {
                if ((e.getRawSlot() == 20) || (e.getRawSlot() == 21) || (e.getRawSlot() == 22) || (e.getRawSlot() == 23) || (e.getRawSlot() == 24)) {

                } else if (e.getRawSlot() <= e.getInventory().getSize()) {
                    e.setCancelled(true);
                }

            } else e.setCancelled(true);
        }
    }
}
 
開發者ID:SkyLightQP,項目名稱:ArmorPlus,代碼行數:15,代碼來源:GUIEvent.java

示例7: onInventoryClick

@SuppressWarnings("deprecation")
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
	if(event.getInventory().getTitle() != Survival.Words.get("Firestriker"))
		return;
	
	final Player player = (Player) event.getWhoClicked();
	
	switch(event.getRawSlot())
	{
		case 1:
		event.setCancelled(true);
		player.closeInventory();
		break;
		
		case 2:
		event.setCancelled(true);
		if(event.getClick() == ClickType.LEFT)
		{
			if(event.getCursor() == null || event.getCursor().getType() == Material.AIR)
			{
				if(event.getInventory().getItem(2) == null || event.getInventory().getItem(2).getType() == Material.AIR)
				{
					if(event.getInventory().getItem(1) != null && event.getInventory().getItem(1).getType() == Material.WOOD_SPADE)
					{
						if(smeltCheck(event.getInventory(), event.getInventory().getItem(0)))
						{
							event.setCancelled(true);
							Random randBurn = new Random();
							player.getLocation().getWorld().playSound(player.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
							player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_BURN, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
							
							ItemStack i_smelt = event.getInventory().getItem(0);
							i_smelt.setAmount(i_smelt.getAmount() - 1);
							event.getInventory().setItem(0, i_smelt);
							
							ItemStack i_firecracker = event.getInventory().getItem(1);
							i_firecracker.setDurability((short)(i_firecracker.getDurability() + 7));
							if(i_firecracker.getDurability() >= 56)
							{
								Random rand = new Random();
								player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
								event.getInventory().setItem(1, null);
							}
						}
					}
				}
				else
				{
					event.setCursor(event.getInventory().getItem(2));
					event.getInventory().setItem(2, null);
				}
			}
			else
				event.setCancelled(true);
		}
		else
			event.setCancelled(true);
		Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, new Runnable()
	    {
	    	public void run()
	    	{
				player.updateInventory();
            }
	    }, 1L);
		break;
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:69,代碼來源:FirestrikerClick.java

示例8: onClick

@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
    if (action.equals("beta_vip") && SamaGamesAPI.get().getPermissionsManager().hasPermission(player, "hub.beta.vip"))
    {
        player.teleport(this.hub.getGameManager().getGameByIdentifier("beta_vip").getLobbySpawn());
    }
    else if (action.equals("switch_hub"))
    {
        this.hub.getGuiManager().openGui(player, new GuiSwitchHub(this.hub, 1));
    }
    else if (action.equals("spawn"))
    {
        player.teleport(this.hub.getPlayerManager().getSpawn());
    }
    else if (action.equals("parkour"))
    {
        player.teleport(this.hub.getParkourManager().getParkours().get(0).getFail());
    }
    else if (action.startsWith("game"))
    {
        String[] actions = action.split("_");
        AbstractGame game = this.hub.getGameManager().getGameByIdentifier(actions[1]);

        if (game.getState() == AbstractGame.State.LOCKED || game.getState() == AbstractGame.State.SOON)
        {
            player.sendMessage(ChatColor.RED + "Ce jeu n'est pas disponible.");
            return;
        }

        if (clickType == ClickType.LEFT)
        {
            player.teleport(game.getLobbySpawn());
        }
        else if (clickType == ClickType.RIGHT && game.getWebsiteDescriptionURL() != null)
        {
            this.hub.getGuiManager().closeGui(player);
            new FancyMessage(ChatColor.YELLOW + "Cliquez sur ").then("[Accéder]").color(ChatColor.GOLD).style(ChatColor.BOLD).link(game.getWebsiteDescriptionURL()).then(" pour accéder aux règles du jeu.").color(ChatColor.YELLOW).send(player);
        }
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:41,代碼來源:GuiMain.java


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