Esempio n. 1
0
  /**
   * Build item stack.
   *
   * @return the item stack
   */
  @Override
  public ItemStack build() {

    setStack(new ItemStack(getMaterial(), getAmount()));

    if ((Short) getDurability() != null) {
      getStack().setDurability(getDurability());
    }

    if (getDisplayName() != null)
      meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getDisplayName()));

    if (getLore() != null) meta.setLore(getLore());

    if (getEnchantments() != null) {
      for (Enchant enchant : getEnchantments()) {

        meta.addEnchant(enchant.enchantment(), enchant.level(), enchant.force());
      }
    }

    if (isUnbreaking()) {

      meta.spigot().setUnbreakable(true);
    }

    getStack().setItemMeta(meta);

    return getStack();
  }
Esempio n. 2
0
File: Shop.java Progetto: Elicis/LoM
 public void createMainPage() {
   Inventory inv1 = Bukkit.createInventory(null, 54, "LoM Shop");
   ItemMeta meta;
   // Redstoneblock
   ItemStack health = new ItemStack(Material.REDSTONE_BLOCK);
   meta = health.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Health");
   health.setItemMeta(meta);
   inv1.setItem(10, health);
   // Ironarmor
   ItemStack armor = new ItemStack(Material.IRON_CHESTPLATE);
   meta = armor.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Armor");
   armor.setItemMeta(meta);
   inv1.setItem(12, armor);
   // Leather tunic (blue)
   ItemStack magicresist = new ItemStack(Material.LEATHER_CHESTPLATE);
   LeatherArmorMeta meta2 = (LeatherArmorMeta) magicresist.getItemMeta();
   meta2.setDisplayName(ChatColor.GOLD + "Magigresistance");
   meta2.setColor(Color.BLUE);
   magicresist.setItemMeta(meta2);
   inv1.setItem(14, magicresist);
   // Iron Sword
   ItemStack damage = new ItemStack(Material.IRON_SWORD);
   meta = damage.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Damage");
   damage.setItemMeta(meta);
   inv1.setItem(29, damage);
   // Diamond hoe
   ItemStack ability = new ItemStack(Material.DIAMOND_HOE);
   meta = ability.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Abilitypower");
   ability.setItemMeta(meta);
   inv1.setItem(33, ability);
   // Lapisblock
   ItemStack mana = new ItemStack(Material.LAPIS_BLOCK);
   meta = mana.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Mana");
   mana.setItemMeta(meta);
   inv1.setItem(16, mana);
   // Health potion
   ItemStack consume = new ItemStack(Material.POTION, 1, (short) 8261);
   meta = consume.getItemMeta();
   meta.setDisplayName(ChatColor.GOLD + "Consume");
   consume.setItemMeta(meta);
   inv1.setItem(31, consume);
   sites.add(inv1);
 }
  public void loadLobbyInventory(Game game) {
    ItemMeta im = null;

    // choose team only when autobalance is disabled
    if (!game.isAutobalanceEnabled()) {
      // Choose team (Wool)
      ItemStack teamSelection = new ItemStack(Material.BED, 1);
      im = teamSelection.getItemMeta();
      im.setDisplayName(Main._l("lobby.chooseteam"));
      teamSelection.setItemMeta(im);
      this.player.getInventory().addItem(teamSelection);
    }

    // Leave Game (Slimeball)
    ItemStack leaveGame = new ItemStack(Material.SLIME_BALL, 1);
    im = leaveGame.getItemMeta();
    im.setDisplayName(Main._l("lobby.leavegame"));
    leaveGame.setItemMeta(im);
    this.player.getInventory().setItem(8, leaveGame);

    Team team = game.getPlayerTeam(this.player);
    if (team != null) {
      ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
      LeatherArmorMeta meta = (LeatherArmorMeta) chestplate.getItemMeta();
      meta.setDisplayName(team.getChatColor() + team.getDisplayName());
      meta.setColor(team.getColor().getColor());
      chestplate.setItemMeta(meta);
      this.player.getInventory().setItem(7, chestplate);
      team.equipPlayerWithLeather(this.player);
    }

    if (this.player.hasPermission("bw.setup")
        || this.player.isOp()
        || this.player.hasPermission("bw.vip.forcestart")) {
      // Force start game (Diamond)
      ItemStack startGame = new ItemStack(Material.DIAMOND, 1);
      im = startGame.getItemMeta();
      im.setDisplayName(Main._l("lobby.startgame"));
      startGame.setItemMeta(im);
      this.player.getInventory().addItem(startGame);
    }

    this.player.updateInventory();
  }