本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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];
}
示例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();
}
示例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());
}
示例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;
}
示例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);
//
}
示例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);
}
}