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


Java ItemStack類代碼示例

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


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

示例1: mainMenu

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public static Inventory mainMenu() {
	Inventory i = Bukkit.createInventory(null, 54, Messager.color("&bMain Menu"));
	
	
	ItemStack pending = new ItemStack(Material.BARRIER);
	ItemMeta pendingMeta = pending.getItemMeta();
	pendingMeta.setDisplayName(Messager.color("&cCurrent Ban Requests"));
	pendingMeta.setLore(Arrays.asList(Messager.color("&7Pending: " + Main.getPendingRequests())));
	pending.setItemMeta(pendingMeta);
	
	i.setItem(20, pending);
	
	// Remove the archived ones for now.
	
	/**
	ItemStack archive = new ItemStack(Material.CHEST);
	ItemMeta archiveMeta = archive.getItemMeta();
	archiveMeta.setDisplayName(Messager.color("&7Archived Requests"));
	archive.setItemMeta(archiveMeta);
	
	i.setItem(24, archive);
	**/
	
	return i;
}
 
開發者ID:JustBru00,項目名稱:EpicBanRequests,代碼行數:26,代碼來源:GUIManager.java

示例2: playerCanTakeBackpack

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public static boolean playerCanTakeBackpack(Player player) {
    if (BACKPACK_LIMIT == 0) {
        return true;
    }

    // Check vanilla inventory
    Inventory inventory = player.getInventory();

    int count = 0;
    for (ItemStack item : inventory.getContents()) {
        if (isBackpack(item)) {
            count++;
        }
    }

    // Check RPGInventory slots
    inventory = InventoryManager.get(player).getInventory();
    Slot backpackSlot = SlotManager.instance().getBackpackSlot();
    if (BackpackManager.isBackpack(inventory.getItem(backpackSlot.getSlotId())) && !backpackSlot.isQuick()) {
        count++;
    }

    return count < BACKPACK_LIMIT;
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:25,代碼來源:BackpackManager.java

示例3: isApplicableFor

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
@Override
public boolean isApplicableFor(Player player) {
    ItemStack helmet = player.getInventory().getHelmet();
    if (helmet == null || helmet.getType() != Material.GOLD_HELMET)
        return false;

    ItemStack chestplate = player.getInventory().getChestplate();
    if (chestplate == null || chestplate.getType() != Material.GOLD_CHESTPLATE)
        return false;

    ItemStack leggings = player.getInventory().getLeggings();
    if (leggings == null || leggings.getType() != Material.GOLD_LEGGINGS)
        return false;

    ItemStack boots = player.getInventory().getBoots();
    return !(boots == null || boots.getType() != Material.GOLD_BOOTS);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:18,代碼來源:BardClass.java

示例4: hasEnoughRessource

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
private boolean hasEnoughRessource(Player player, VillagerTrade trade) {
	if (trade instanceof XPVillagerTrade) {
		return XPManager.hasEnoughXP(bedwars.getName(), player,
				((XPVillagerTrade) trade).getXP());
	} else {
		ItemStack item1 = trade.getItem1();
		ItemStack item2 = trade.getItem2();
		PlayerInventory inventory = player.getInventory();

		if (item2 != null) {
			if ((!inventory.contains(item1.getType(), item1.getAmount()))
					|| (!inventory.contains(item2.getType(),
							item2.getAmount()))) {
				return false;
			}
		} else if (!inventory.contains(item1.getType(), item1.getAmount())) {
			return false;
		}

		return true;
	}
}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:23,代碼來源:XPItemShop.java

示例5: parse

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public static KillRewardModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    ImmutableList.Builder<KillReward> rewards = ImmutableList.builder();
    final ItemParser itemParser = context.needModule(ItemParser.class);
    final Optional<ItemModifyModule> itemModifier = context.module(ItemModifyModule.class);

    // Must allow top-level children for legacy support
    for(Element elKillReward : XMLUtils.flattenElements(doc.getRootElement(), ImmutableSet.of("kill-rewards"), ImmutableSet.of("kill-reward", "killreward"), 0)) {
        ImmutableList.Builder<ItemStack> items = ImmutableList.builder();
        for(Element itemEl : elKillReward.getChildren("item")) {
            final ItemStack item = itemParser.parseItem(itemEl, false);
            itemModifier.ifPresent(imm -> imm.applyRules(item));
            items.add(item.immutableCopy());
        }
        Filter filter = context.needModule(FilterParser.class).property(elKillReward, "filter").optional(StaticFilter.ALLOW);
        Kit kit = context.needModule(KitParser.class).property(elKillReward, "kit").optional(KitNode.EMPTY);

        rewards.add(new KillReward(items.build(), filter, kit));
    }

    ImmutableList<KillReward> list = rewards.build();
    if(list.isEmpty()) {
        return null;
    } else {
        return new KillRewardModule(list);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:27,代碼來源:KillRewardModule.java

示例6: onGameStart

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
/**
 * Give 64 bones, 64 rotten flesh and 64 wolf eggs to all the players
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    ItemStack eggs = MojangShitUtils.getMonsterEgg(EntityType.WOLF);
    eggs.setAmount((int) this.moduleConfiguration.get("eggs"));

    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.getInventory().addItem(new ItemStack(Material.BONE, (int) this.moduleConfiguration.get("bones")));
        p.getInventory().addItem(new ItemStack(Material.ROTTEN_FLESH, (int) this.moduleConfiguration.get("rotten-flesh")));
        p.getInventory().addItem(eggs);
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:24,代碼來源:PuppyPowerModule.java

示例7: isGun

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
/**
 * Checks if the proferred item is a gun.
 * 
 * @param toCheck the item to check if this gun
 * @return true if gun, false otherwise
 */
@Override	
public boolean isGun(ItemStack toCheck) {
	if (!enabled || toCheck == null)
		return false;

	if (!gunExample.getType().equals(toCheck.getType()))
		return false;

	if (!toCheck.hasItemMeta())
		return false;

	ItemMeta meta = toCheck.getItemMeta();

	if (meta.hasLore() && meta.getLore().contains(tag))
		return true;

	return false;
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:25,代碼來源:StandardGun.java

示例8: onDeath

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() != PlayerStatus.PLAYING) {
        return;
    }

    player.spigot().respawn();

    IMatch match = profile.getCurrentMatch();
    match.handleDeath(player, player.getLocation(), ChatColor.RED + player.getName() + ChatColor.GRAY + " has been slain.");

    event.setDeathMessage(null);
    player.setHealth(20.0);

    for (ItemStack i : event.getDrops()) {
        i.setType(Material.AIR);
    }
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:22,代碼來源:MatchListener.java

示例9: get

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
@Nullable
@Override
protected Number[] get(Event e) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return null;
	}
	if (PotionUtils.isPotionItem(i)) {
		PotionMeta meta = (PotionMeta) i.getItemMeta();
		PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
		if (eff == null) {
			return null;
		}
		return new Number[]{eff.getAmplifier()};
	}
	return null;
}
 
開發者ID:Syst3ms,項目名稱:QuarSK,代碼行數:18,代碼來源:SExprItemEffectTypeAmplifier.java

示例10: loadContent

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public ItemStack[] loadContent() {
	TribeFile.createConfig(getName());
	if(TribeFile.getChest() != null) {
		List<?> list = TribeFile.getChest();
		ItemStack[] turinys = new ItemStack[list.size()];
			for (int i = 0; i < list.size(); i++) {
				Object o = list.get(i);
				if (o instanceof ItemStack) {
					turinys[i] = (ItemStack) o;
				} else {
					turinys[i] = new ItemStack(Material.AIR);
				}
			}
		return turinys;
	}
	return new ItemStack[0];
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:18,代碼來源:Tribe.java

示例11: syncInfoSlots

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public static void syncInfoSlots(PlayerWrapper playerWrapper) {
    final Player player = (Player) playerWrapper.getPlayer();
    for (Slot infoSlot : SlotManager.instance().getInfoSlots()) {
        ItemStack cup = infoSlot.getCup();
        ItemMeta meta = cup.getItemMeta();
        List<String> lore = meta.getLore();

        for (int i = 0; i < lore.size(); i++) {
            String line = lore.get(i);
            lore.set(i, StringUtils.setPlaceholders(player, line));
        }

        meta.setLore(lore);
        cup.setItemMeta(meta);
        playerWrapper.getInventory().setItem(infoSlot.getSlotId(), cup);
    }

    player.updateInventory();
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:20,代碼來源:InventoryManager.java

示例12: setLayout

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
private void setLayout(Inventory inv) {
    String title = getData().title();
    int size = getData().size();
    int lastLineFirstIndex = size - 9;
    ItemStack wall = new ItemBuilder(Material.STAINED_GLASS)
            .display("")
            .build();
    for (int i = 0; i < 9; i++) {
        inv.setItem(i, wall);
    }
    for (int i = lastLineFirstIndex; i < size; i++) {
        inv.setItem(i, wall);
    }

    inv.setItem(4, new ItemBuilder(Material.NETHER_STAR).display(title).build());
    inv.setItem(prevPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
    inv.setItem(nextPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:19,代碼來源:PageGUI.java

示例13: contains

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
@Override
public ArrayList<ItemStack> contains(){
    ArrayList<ItemStack> items = new ArrayList<>();

    switch (getCrateType()){
        case NORMAL:
            items.add(new ItemMaker(Material.APPLE).setDisplayName("An apple a day keeps the doctor away").setAmount(7).build());
            items.add(new ItemMaker(Material.BOAT).build());
            items.add(new ItemMaker(Material.IRON_BLOCK).build());
            break;
        case EPICA:

            break;
        case LEGENDARIA:

            break;
    }
    return items;
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:20,代碼來源:StaticCrate.java

示例14: LobbySelector

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
public LobbySelector(WCLobby instance){
    gameSelector = iu.createInventory(9, "&cServidores");

    ItemStack glass = ItemUtils.coloredBlock(DyeColor.ORANGE, "&cWorld&8Crafteros", ItemUtils.ColoredBlock.FLAT_GLASS);

    //Glass
    for (int x = 1; x < 8; x++){
        gameSelector = iu.setItem(gameSelector, x + 9, glass);
        gameSelector = iu.setItem(gameSelector, x + (9 * 4), glass);
    }
    gameSelector = iu.setItem(gameSelector, 18, glass);
    gameSelector = iu.setItem(gameSelector, 27, glass);
    gameSelector = iu.setItem(gameSelector, 26, glass);
    gameSelector = iu.setItem(gameSelector, 35, glass);
    //



}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:20,代碼來源:LobbySelector.java

示例15: on

import org.bukkit.inventory.ItemStack; //導入依賴的package包/類
@EventHandler
public void on(PlayerDropItemEvent event) {
    ItemStack item = event.getItemDrop().getItemStack();

    if (item == null) {
        return;
    }

    if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
        return;
    }

    String name = item.getItemMeta().getDisplayName();

    if (name.equals("§4§lBlocked Slot")) {
        event.setCancelled(true);
    }
}
 
開發者ID:LeonTG,項目名稱:NineSlots,代碼行數:19,代碼來源:ClickListener.java


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