当前位置: 首页>>代码示例>>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;未经允许,请勿转载。