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


Java PrepareItemCraftEvent.getInventory方法代碼示例

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


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

示例1: onPrepareCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e)
{
	CraftingInventory inv = e.getInventory();
	ItemStack result = inv.getResult();
	if(result != null && result.getType() != Material.GLASS_BOTTLE)
	{
		List<ItemStack> bottles = Arrays.asList(inv.getMatrix());
		Iterator<ItemStack> it = bottles.iterator();
		
		while(it.hasNext())
		{
			ItemStack bottle = it.next();
			if(bottle == null) continue;
			if(bottle.getType().equals(Material.POTION))
			{
				if(!checkWaterBottle(bottle))
				{
					inv.setResult(null);
					return;
				}
			}
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:26,代碼來源:WaterBottleCrafting.java

示例2: onPrepareCrowbarCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPrepareCrowbarCraft(PrepareItemCraftEvent event) {
    CraftingInventory inventory = event.getInventory();
    if (event.isRepair() && event.getRecipe().getResult().getType() == Crowbar.CROWBAR_TYPE) {
        int endFrameUses = 0;
        int spawnerUses = 0;
        boolean changed = false;

        ItemStack[] matrix = inventory.getMatrix();
        for (ItemStack ingredient : matrix) {
            Optional<Crowbar> crowbarOptional = Crowbar.fromStack(ingredient);
            if (crowbarOptional.isPresent()) {
                Crowbar crowbar = crowbarOptional.get();
                spawnerUses += crowbar.getSpawnerUses();
                endFrameUses += crowbar.getEndFrameUses();
                changed = true;
            }
        }

        // Finally update the result.
        if (changed) {
            inventory.setResult(new Crowbar(spawnerUses, endFrameUses).getItemIfPresent());
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:26,代碼來源:CrowbarListener.java

示例3: onPrepareItemCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPrepareItemCraft(PrepareItemCraftEvent e) {
	if (e.getInventory() == null) return;

	ItemStack item = e.getInventory().getResult();
	if (item == null) return; // This should never ever ever ever run. If it does then you probably screwed something up.

	if (item.getType() == Material.GOLDEN_APPLE && item.getDurability() == (short) 1) {

		World world = e.getView().getPlayer().getWorld();

		if (isSettingEnabled("no-conflict-mode")) return;

		if (!isEnabled(world))
			e.getInventory().setResult(null);
		else if (isEnabled(world) && !isSettingEnabled("enchanted-golden-apple-crafting"))
			e.getInventory().setResult(null);
	}
}
 
開發者ID:gvlfm78,項目名稱:BukkitOldCombatMechanics,代碼行數:20,代碼來源:ModuleGoldenApple.java

示例4: onPrepareCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPrepareCraft(PrepareItemCraftEvent event) {
    if (event.getInventory().getHolder() instanceof Player) {
        CraftingInventory inventory = event.getInventory();
        Player player = (Player) inventory.getHolder();
        if (isBottledExperience(inventory.getResult())) {
            int exp = new ExperienceManager(player).getCurrentExp();
            inventory.setResult(exp > 0 ? createExpBottle(exp) : new ItemStack(Material.AIR, 1));
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:12,代碼來源:BottledExpListener.java

示例5: prepareCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler public void prepareCraft(final PrepareItemCraftEvent event) {
    Recipe recipe = event.getRecipe();
    if (event.isRepair() || recipe instanceof MerchantRecipe || recipe instanceof FurnaceRecipe) {
        return;
    }
    if (recipe.getResult() != null) {
        return;
    }
    CraftingInventory inventory = event.getInventory();
    ItemStack[] matrix = inventory.getMatrix();
    PlayerheadItemStack skull = null;
    int gold = 0, skulls = 0;
    for (ItemStack item : matrix) {
        if (item.getType() == Material.SKULL_ITEM) {
            if (item instanceof PlayerheadItemStack && ((SkullMeta) item.getItemMeta()).hasOwner()) {
                ++skulls;
                skull = (PlayerheadItemStack) item;
            }
        } else if (item.getType() == Material.GOLD_INGOT) {
            ++gold;
        }
    }
    if (skull == null || gold != 7 || skulls != 1) {
        return;
    }
    skull.setGolden(true);
    inventory.setResult(skull);
}
 
開發者ID:Project-Coalesce,項目名稱:UHC,代碼行數:29,代碼來源:CraftingHandler.java

示例6: onPrepareItemCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler (priority = EventPriority.HIGHEST)
public void onPrepareItemCraft (PrepareItemCraftEvent e) {
	if (e.getViewers().size() < 1) return;

	World world = e.getViewers().get(0).getWorld();
	if(!isEnabled(world)) return;

	CraftingInventory inv = e.getInventory();
	ItemStack result = inv.getResult();
	
	if(result != null && denied.contains(result.getType()))
		inv.setResult(null);
}
 
開發者ID:gvlfm78,項目名稱:BukkitOldCombatMechanics,代碼行數:14,代碼來源:ModuleDisableCrafting.java

示例7: onPrepare

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler
public void onPrepare(PrepareItemCraftEvent e) {
	CraftingInventory inv = e.getInventory();
	if(inv.getRecipe().getResult().hasItemMeta()) {
		if(inv.getRecipe().getResult().getItemMeta().hasDisplayName()) {
			if(inv.getRecipe().getResult().getItemMeta().getDisplayName().equalsIgnoreCase("crate")) {
				if(inv.getItem(5) != null) {
					if(inv.getItem(5).hasItemMeta()) {
						if(inv.getItem(5).getItemMeta().hasDisplayName()) {
							if(pl.isCrate(inv.getItem(5).getItemMeta().getDisplayName())) {
								Crate crate = pl.getCrate(inv.getItem(5).getItemMeta().getDisplayName());
								if(crate.needsKey()) {
									if(inv.getItem(5).getType() == (crate.getType() == CrateType.NORMAL ? Material.GOLD_INGOT : Material.DIAMOND)) {
										inv.setResult(crate.getKeyItem());
									} else {
										inv.setResult(null);
									}
								} else {
									inv.setResult(null);
								}
							} else {
								inv.setResult(null);
							}
						} else {
							inv.setResult(null);
						}
					} else {
						inv.setResult(null);
					}
				}
			}
		}
	}
}
 
開發者ID:xize,項目名稱:manco2,代碼行數:35,代碼來源:KeyCraftEvent.java

示例8: onPrepareItemCraft

import org.bukkit.event.inventory.PrepareItemCraftEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPrepareItemCraft(PrepareItemCraftEvent event) {
    boolean isUpgradeRecipe = RecipeUtil.areEqual(event.getRecipe(), ResurrectionScroll.getResurrectionScrollUpgradeRecipe());

    if (!isUpgradeRecipe) {
        return;
    }

    CraftingInventory inventory = event.getInventory();
    boolean resurrectionScrollFound = false;
    int tier = 0;

    for (ItemStack itemStack : inventory.getMatrix()) {
        if (itemStack == null) {
            continue;
        }

        if (ItemUtils.isResurrectionScroll(itemStack)) {
            resurrectionScrollFound = true;
            tier = Tier.getTier(itemStack).toNumerical();
        }
    }

    if (!resurrectionScrollFound || tier >= 3) {
        inventory.setResult(null);
        return;
    }

    inventory.setResult(ResurrectionScroll.getResurrectionScroll(1, tier + 1));
}
 
開發者ID:TfT-02,項目名稱:Ghosts,代碼行數:31,代碼來源:InventoryListener.java


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