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


Java InventoryClickEvent.isShiftClick方法代码示例

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


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

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

示例2: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
@SuppressWarnings("unused")
public void onInventoryClick(InventoryClickEvent e) {
    if(!e.isRightClick() && !e.isShiftClick() && e.getWhoClicked() instanceof Player) {
        Player player = (Player) e.getWhoClicked();
        DynamicAC.getManager().getBackend().checkInventoryClicks(player);
        player.getInventory().clear();
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:10,代码来源:PlayerListener.java

示例3: handleCategoryInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void handleCategoryInventoryClick(InventoryClickEvent ice,
		Game game, Player player) {
	int catSize = getCategoriesSize(player);
	int sizeCategories = getInventorySize(catSize) + 9;
	int rawSlot = ice.getRawSlot();

	if ((rawSlot >= getInventorySize(catSize))
			&& (rawSlot < sizeCategories)) {
		ice.setCancelled(true);

		if (ice.getCurrentItem().getType() == Material.BUCKET) {
			game.getPlayerSettings(player).setOneStackPerShift(false);
			player.playSound(player.getLocation(),
					SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
					1.0F);
			openCategoryInventory(player);
			return;
		}
		if (ice.getCurrentItem().getType() == Material.LAVA_BUCKET) {
			game.getPlayerSettings(player).setOneStackPerShift(true);
			player.playSound(player.getLocation(),
					SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F,
					1.0F);
			openCategoryInventory(player);
			return;
		}

	}

	if (rawSlot >= sizeCategories) {
		if (ice.isShiftClick()) {
			ice.setCancelled(true);
			return;
		}

		ice.setCancelled(false);
		return;
	}

	MerchantCategory clickedCategory = getCategoryByMaterial(ice
			.getCurrentItem().getType());
	if (clickedCategory == null) {
		if (ice.isShiftClick()) {
			ice.setCancelled(true);
			return;
		}

		ice.setCancelled(false);
		return;
	}

	openBuyInventory(clickedCategory, player, game);
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:54,代码来源:XPItemShop.java

示例4: handleBuyInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void handleBuyInventoryClick(InventoryClickEvent ice, Game game,
		Player player) {
	int sizeCategories = getCategoriesSize(player);
	ArrayList<VillagerTrade> offers = this.currentCategory.getOffers();
	int sizeItems = offers.size();
	int totalSize = getBuyInventorySize(sizeCategories, sizeItems);

	ItemStack item = ice.getCurrentItem();
	boolean cancel = false;
	int bought = 0;
	boolean oneStackPerShift = game.getPlayerSettings(player)
			.oneStackPerShift();

	if (this.currentCategory == null) {
		player.closeInventory();
		return;
	}

	if (ice.getRawSlot() < sizeCategories) {
		ice.setCancelled(true);

		if (item == null) {
			return;
		}
		if (item.getType().equals(this.currentCategory.getMaterial())) {
			this.currentCategory = null;
			openCategoryInventory(player);
		} else {
			handleCategoryInventoryClick(ice, game, player);
		}
	} else if (ice.getRawSlot() < totalSize) {
		ice.setCancelled(true);

		if ((item == null) || (item.getType() == Material.AIR)) {
			return;
		}

		MerchantCategory category = this.currentCategory;
		VillagerTrade trade = getTradingItem(category, item, game, player);

		if (trade == null) {
			return;
		}

		player.playSound(player.getLocation(),
				SoundMachine.get("ITEM_PICKUP", "ENTITY_ITEM_PICKUP"),
				10.0F, 1.0F);

		if (!hasEnoughRessource(player, trade)) {
			player.sendMessage(ChatWriter.pluginMessage(ChatColor.RED
					+ Main._l("errors.notenoughress")));
			return;
		}

		if (ice.isShiftClick()) {
			while ((hasEnoughRessource(player, trade)) && (!cancel)) {
				cancel = !buyItem(trade, ice.getCurrentItem(), player);
				if ((!cancel) && (oneStackPerShift)) {
					bought += item.getAmount();
					cancel = bought + item.getAmount() > 64;
				}
			}

			bought = 0;
		} else {
			buyItem(trade, ice.getCurrentItem(), player);
		}
	} else {
		if (ice.isShiftClick())
			ice.setCancelled(true);
		else {
			ice.setCancelled(false);
		}

		return;
	}
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:78,代码来源:XPItemShop.java

示例5: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
 * Handle a player click.
 * @param evt
 */
public void onClick(InventoryClickEvent evt) {
    InventoryAction action = evt.getAction();
    if (IGNORE.contains(action)) {
        evt.setCancelled(true);
        return; // Don't allow these clicks.
    }

    Inventory top = evt.getView().getTopInventory();
    boolean isTop = top.equals(evt.getClickedInventory());
    boolean isBottom = evt.getView().getBottomInventory().equals(evt.getClickedInventory());
    ItemStack add = null;
    int slot = evt.getRawSlot();

    if (slot >= 0 && isTop) {
        GUIItem item = getItem(slot);
        if (item != null) {
            evt.setCancelled(true);
            item.onClick(evt);
        } else {
            if (!isAllowStorage()) {
                evt.setCancelled(true); // Don't allow depositing / withdrawing items.
                return;
            }

            if (action == InventoryAction.HOTBAR_MOVE_AND_READD || action == InventoryAction.HOTBAR_SWAP) {
                // Hotbar swap.
                if (item != null || !isAllowStorage()) // Either they're not allowed or they're swapping with a DisplayItem.
                    add = evt.getWhoClicked().getInventory().getItem(evt.getHotbarButton());
            } else if (action == InventoryAction.PLACE_ALL || action == InventoryAction.PLACE_ONE) { //PLACE_SOME adds to an existing stack, we only want to fire when a new item is added.
                add = evt.getCursor().clone();
                if (action == InventoryAction.PLACE_ONE)
                    add.setAmount(1); // They're right clicking an item in.
            }
        }
    } else if (isBottom && evt.isShiftClick()) { // They're trying to shift click an item in.
        if (isAllowStorage() && top.firstEmpty() > -1) {
            add = evt.getCurrentItem();
        } else {
            evt.setCancelled(true);
        }
    }

    if (add != null) {
        // We're depositing an item.
        if (canDeposit(slot, add)) {
            deposit(add);
        } else {
            evt.setCancelled(true);
        }
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:56,代码来源:GUI.java


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