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


Java CraftItemEvent.isCancelled方法代碼示例

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


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

示例1: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onCraftItem(CraftItemEvent event)
{
    if (!event.isCancelled())
    {
        ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, (short) 1);
        if (event.getRecipe().getResult() == gapple)
        {
            if (event.getWhoClicked() instanceof Player)
            {
                plugin.getCoreErrors().cantCraftGoldenApples((Player) event.getWhoClicked());
            }
            event.setCancelled(true);
        }
    }
}
 
開發者ID:Vanillacraft,項目名稱:vanillacraft,代碼行數:17,代碼來源:WorldNerf.java

示例2: onCrafting

import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR)
public void onCrafting(CraftItemEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (event.getWhoClicked() instanceof Player) {
		Player player = (Player) event.getWhoClicked();
		String playerID = PlayerConverter.getID(player);
		CraftData playerData = (CraftData) dataMap.get(playerID);
		if (containsPlayer(playerID) && item.compare(event.getRecipe().getResult()) && checkConditions(playerID)) {
			playerData.subtract(event.getRecipe().getResult().getAmount());
			if (playerData.isZero()) {
				completeObjective(playerID);
			}
		}
	}
}
 
開發者ID:Co0sh,項目名稱:BetonQuest,代碼行數:18,代碼來源:CraftingObjective.java

示例3: stopVanillaCraft

import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler
public void stopVanillaCraft(CraftItemEvent e) {
    if (!(e.getWhoClicked() instanceof Player)) return;
    Player p = (Player) e.getWhoClicked();
    if (!RUtils.isInInfectedWorld(p)) return;
    Recipe rr = e.getRecipe();
    ItemStack result = rr.getResult();
    if (rr instanceof ShapedRecipe) {
        ShapedRecipe srr = (ShapedRecipe) rr;
        if (result.getType() == Material.BOW && !shapedRecipesMatch(srr, plugin.bowRecipe)) e.setCancelled(true);
        if (Config.harderTorches && result.getType() == Material.TORCH && !srr.getIngredientMap().values().equals(plugin.torchRecipe.getIngredientList()))
            e.setCancelled(true);
        if (result.getType() == Material.ARROW && !srr.getIngredientMap().values().containsAll(plugin.arrowRecipe.getIngredientList()))
            e.setCancelled(true);
    }
    if (e.isCancelled()) e.setResult(Event.Result.DENY);
}
 
開發者ID:RoyalDev,項目名稱:RoyalSurvivors,代碼行數:18,代碼來源:SurvivorsListener.java

示例4: onCraftItem

import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onCraftItem(CraftItemEvent event) {
    if (event.isCancelled()) return;
    final Player p = (Player) event.getWhoClicked();
    CraftingInventory inventory = event.getInventory();
    for(ItemStack is : inventory.getContents()) {
        if(ArmorStandTool.isTool(is)) {
            event.setCancelled(true);
            //noinspection deprecation
            p.updateInventory();
            return;
        }
    }
}
 
開發者ID:St3venAU,項目名稱:ArmorStandTools,代碼行數:15,代碼來源:MainListener.java

示例5: getCraftAmount

import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
/**
 * Get the amount of items the player had just crafted. This method will
 * take into consideration shift clicking & the amount of inventory space
 * the player has left.
 * 
 * @param CraftItemEvent
 * @return int: actual crafted item amount
 */
public static int getCraftAmount(CraftItemEvent e)
{

	if (e.isCancelled())
	{
		return 0;
	}

	Player p = (Player) e.getWhoClicked();

	if (e.isShiftClick())
	{
		int itemsChecked = 0;
		int possibleCreations = 1;

		int amountCanBeMade = 0;

		for (ItemStack item : e.getInventory().getMatrix())
		{
			if (item != null && item.getType() != Material.AIR)
			{
				if (itemsChecked == 0)
				{
					possibleCreations = item.getAmount();
					itemsChecked++;
				} else
				{
					possibleCreations = Math.min(possibleCreations, item.getAmount());
				}
			}
		}

		int amountOfItems = e.getRecipe().getResult().getAmount() * possibleCreations;

		ItemStack i = e.getRecipe().getResult();

		for (int s = 0; s <= 35; s++)
		{
			ItemStack test = p.getInventory().getItem(s);
			if (test == null || test.getType() == Material.AIR)
			{
				amountCanBeMade += i.getMaxStackSize();
				continue;
			}
			if (test.isSimilar(i))
			{
				amountCanBeMade += i.getMaxStackSize() - test.getAmount();
			}
		}

		return amountOfItems > amountCanBeMade ? amountCanBeMade : amountOfItems;
	} else
	{
		return e.getRecipe().getResult().getAmount();
	}
}
 
開發者ID:Lyon1-Asterix,項目名稱:Minetrace,代碼行數:65,代碼來源:Utils.java


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