Package org.bukkit.inventory.meta

Examples of org.bukkit.inventory.meta.ItemMeta


    section.set("5.reward.items", ImmutableList.of(new ItemStack(Material.ARROW, 15), new ItemStack(Material.EGG)));
    section.set("5.reward.effect", Effect.GHAST_SHRIEK.name());
    ItemStack sword = new ItemStack(Material.WOOD_SWORD);
    sword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
    sword.addEnchantment(Enchantment.KNOCKBACK, 1);
    ItemMeta meta = sword.getItemMeta();
    meta.setDisplayName("The Breaker");
    meta.setLore(ImmutableList.of("Very slow speed"));
    sword.setItemMeta(meta);
    section.set("7.reward.items", ImmutableList.of(sword));
  }
View Full Code Here


        meta.setColor(clr);
        stack.setItemMeta(meta);
      }
      if (config.contains(prefix + "name")) {
        String itemName = config.getString(prefix + "name");
        ItemMeta meta = stack.getItemMeta();
        meta.setDisplayName(itemName);
        stack.setItemMeta(meta);
      }
      if (config.contains(prefix + "lore")) {
        List<String> itemLore = config.getStringList(prefix + "lore");
        ItemMeta meta = stack.getItemMeta();
        meta.setLore(itemLore);
        stack.setItemMeta(meta);
      }
      loadout.put(slot, stack);
    }
    String permission = config.getString(loadoutName + ".permission", "");
View Full Code Here

            };
        }

        private ItemStack makeTool(Material mat, String name, String left, String right) {
            ItemStack tool = new ItemStack(mat);
            ItemMeta meta = tool.getItemMeta();
            meta.setDisplayName(name);
            meta.setLore(Arrays.asList(
                    color("&9Left&r: &r" + left),
                    color("&cRight&r: &r" + right)
            ));
            tool.setItemMeta(meta);
            return tool;
View Full Code Here

        if (event.getFuel().getType()
            .equals(Material.matchMaterial(name))) {
          ItemStack fuel = event.getFuel();
          if (fuel == null)
            continue;
          ItemMeta meta;
          if (fuel.hasItemMeta())
            meta = fuel.getItemMeta();
          else
            meta = Bukkit.getItemFactory().getItemMeta(
                fuel.getType());
          if (meta.hasDisplayName()) {
            ItemMeta tismeta;
            if (tis.hasItemMeta())
              tismeta = tis.getItemMeta();
            else
              tismeta = plugin.getServer().getItemFactory()
                  .getItemMeta(tis.getType());
            if (tismeta.hasLore())
              for (String t : tismeta.getLore()) {
                if (t == null)
                  continue;
                if (!ChatColor.stripColor(t).equals("(Socket)"))
                  continue;
                if ((meta.getDisplayName().contains("Socket") || fuel
View Full Code Here

      return;
    ChatColor fuelColor = findColor(is.getItemMeta().getDisplayName());

    ItemStack tool = event.getResult();
    ItemStack oldtool = event.getSource();
    ItemMeta metaold;
    if (oldtool.hasItemMeta())
      metaold = oldtool.getItemMeta();
    else
      metaold = Bukkit.getItemFactory().getItemMeta(oldtool.getType());

    if (!metaold.hasLore()) {
      event.setCancelled(true);
      event.setResult(oldtool);
      return;
    }

    boolean namTest = false;
    for (String n : metaold.getLore())
      if (ChatColor.stripColor(n).equalsIgnoreCase("(Socket)")) {
        namTest = true;
      }
    if (!namTest) {
      event.setResult(event.getSource());
      return;
    }

    tool.addUnsafeEnchantments(oldtool.getEnchantments());

    ItemMeta meta = tool.getItemMeta();
    if (fuel.equals(Material.SKULL_ITEM)) {
      ChatColor color = ChatColor.WHITE;
      if (metaold.hasDisplayName())
        color = findColor(metaold.getDisplayName());
      SkullMeta skull = (SkullMeta) is.getItemMeta();
      String skullName = skull.getOwner();
      if ((skullName == null) || (skullName.trim().length() < 1)) {
        switch (is.getData().getData()) {
        // TODO: Fix
        case 4: {
          skullName = "Creeper";
          break;
        }
        case 3: {
          skullName = "Steve";
          break;
        }
        case 0: {
          skullName = "Skeleton";
          break;
        }
        case 1: {
          skullName = "Wither";
          break;
        }
        case 2: {
          skullName = "Zombie";
          break;
        }
        default: {
          skullName = "";
          break;
        }
        }
      }
      String old = null;
      if (metaold.hasDisplayName())
        old = metaold.getDisplayName();
      if (old != null) {
        if (old.contains("'")) {
          old = old.split("'")[1].substring(2);
        }
        metaold.setDisplayName(color + skullName + "'s "
            + ChatColor.stripColor(old));
      }
    }
    List<String> list = new ArrayList<String>();
    for (String s : metaold.getLore()) {
      list.add(s);
    }
    if (list.contains(fuelColor + "(Socket)")) {
      if (plugin.getItemAPI().isArmor(tool.getType())
          && plugin.defenselore.size() > 0) {
        list.remove(fuelColor + "(Socket)");
        String effect = plugin.defenselore.get(plugin.getSingleRandom()
            .nextInt(plugin.defenselore.size()));
        String effectToRemove = null;
        for (String s : list) {
          String[] split = s.split(" ");
          if (split.length <= 1)
            continue;
          String[] splitEffect = effect.split(" ");
          if (splitEffect.length <= 1)
            continue;
          if (ChatColor.stripColor(split[1]).equals(splitEffect[1])) {
            effectToRemove = s;
            int level = getInt(s, 0) + getInt(effect, 0);
            String levelString = (level > 0) ? "+"
                + String.valueOf(level) : String.valueOf(level);
            String newEffect = levelString;
            for (String s2 : splitEffect) {
              if (s2.equals(splitEffect[0]))
                continue;
              newEffect = newEffect + " " + s2;
            }
            effect = newEffect;
          }
        }
        if (effectToRemove != null)
          list.remove(effectToRemove);
        list.add(fuelColor + effect);
      } else if (plugin.getItemAPI().isTool(tool.getType())
          && plugin.offenselore.size() > 0) {
        list.remove(fuelColor + "(Socket)");
        String effect = plugin.offenselore.get(plugin.getSingleRandom()
            .nextInt(plugin.offenselore.size()));
        String effectToRemove = null;
        for (String s : list) {
          String[] split = s.split(" ");
          if (split.length <= 1)
            continue;
          String[] splitEffect = effect.split(" ");
          if (splitEffect.length <= 1)
            continue;
          if (ChatColor.stripColor(split[1]).equals(splitEffect[1])) {
            effectToRemove = s;
            int level = getInt(s, 0) + getInt(effect, 0);
            String levelString = (level > 0) ? "+"
                + String.valueOf(level) : String.valueOf(level);
            String newEffect = levelString;
            for (String s2 : splitEffect) {
              if (s2.equals(splitEffect[0]))
                continue;
              newEffect = newEffect + " " + s2;
            }
            effect = newEffect;
          }
        }
        if (effectToRemove != null)
          list.remove(effectToRemove);
        list.add(fuelColor + effect);
      }
    }
    SocketEnhancementEvent see = new SocketEnhancementEvent(
        event.getSource(), is, tool, ((Furnace) event.getBlock()
            .getState()));
    plugin.getServer().getPluginManager().callEvent(see);
    meta.setDisplayName(metaold.getDisplayName());
    meta.setLore(list);
    tool.setItemMeta(meta);
    tool.setDurability(oldtool.getDurability());
    event.setResult(tool);
    return;
  }
View Full Code Here

public class Drop extends ItemStack {

  public Drop(Material mat) {
    super(mat);
    ItemMeta meta;
    if (hasItemMeta())
      meta = this.getItemMeta();
    else
      meta = Bukkit.getItemFactory().getItemMeta(mat);
    this.setItemMeta(meta);
View Full Code Here

    this.setItemMeta(meta);
  }

  public Drop(Material mat, ChatColor color, String name) {
    super(mat);
    ItemMeta meta;
    if (hasItemMeta())
      meta = this.getItemMeta();
    else
      meta = Bukkit.getItemFactory().getItemMeta(mat);
    meta.setDisplayName(color + name + ChatColor.STRIKETHROUGH);
    this.setItemMeta(meta);
  }
View Full Code Here

    this.setItemMeta(meta);
  }

  public Drop(Material mat, ChatColor color, String name, short durability) {
    super(mat);
    ItemMeta meta;
    if (hasItemMeta())
      meta = this.getItemMeta();
    else
      meta = Bukkit.getItemFactory().getItemMeta(mat);
    meta.setDisplayName(color + name + ChatColor.STRIKETHROUGH);
    this.setItemMeta(meta);
    this.setDurability(durability);
  }
View Full Code Here

  }

  public Drop(Material mat, ChatColor color, String name, short durability,
      String... lore) {
    super(mat);
    ItemMeta meta;
    if (hasItemMeta())
      meta = this.getItemMeta();
    else
      meta = Bukkit.getItemFactory().getItemMeta(mat);
    meta.setDisplayName(color + name + ChatColor.STRIKETHROUGH);
    List<String> list = new ArrayList<String>();
    for (String e : lore) {
      list.add(e);
    }
    meta.setLore(list);
    this.setItemMeta(meta);
    this.setDurability(durability);
  }
View Full Code Here

    this.setDurability(durability);
  }

  public Drop(Material mat, ChatColor color, String name, String... lore) {
    super(mat);
    ItemMeta meta;
    if (hasItemMeta())
      meta = this.getItemMeta();
    else
      meta = Bukkit.getItemFactory().getItemMeta(mat);
    meta.setDisplayName(color + name + ChatColor.STRIKETHROUGH);
    List<String> list = new ArrayList<String>();
    for (String e : lore) {
      list.add(e);
    }
    meta.setLore(list);
    this.setItemMeta(meta);
  }
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.meta.ItemMeta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.