Package org.bukkit.inventory.meta

Examples of org.bukkit.inventory.meta.Repairable


  // -------------------------------------------- //

  public static void transferRepaircost(ItemMeta meta, JsonObject json, boolean meta2json)
  {
    if (!(meta instanceof Repairable)) return;
    Repairable repairable = (Repairable) meta;

    if (meta2json)
    {
      if (!repairable.hasRepairCost()) return;
      json.addProperty(REPAIRCOST, repairable.getRepairCost());
    }
    else
    {
      JsonElement element = json.get(REPAIRCOST);
      if (element == null) return;

      repairable.setRepairCost(element.getAsInt());
    }
  }
View Full Code Here


                }
            }
            if(ismeta instanceof Repairable) {
                data = itemdata.get("R");
                if(data != null) {
                    Repairable rmeta = (Repairable) ismeta;
                    rmeta.setRepairCost(Integer.parseInt(data));
                }
            }
        }else {
            //Old item meta here
            int repairableindex = 2;
            if(msplit.length > 1) {
                if(!msplit[0].equals("")) {
                    ismeta.setDisplayName(base64Decode(msplit[0]));
                }
                if(!msplit[1].equals("")) {
                    ismeta.setLore(decodeLore(msplit[1]));
                }
                if(ismeta instanceof SkullMeta) {
                    if(!msplit[2].isEmpty()) {
                        ((SkullMeta) ismeta).setOwner(msplit[2]);
                    }
                    repairableindex = 3;
                } else if(ismeta instanceof LeatherArmorMeta) {
                    if(!msplit[2].equals("")) {
                        int color = Integer.parseInt(msplit[2]);
                        ((LeatherArmorMeta) ismeta).setColor(Color.fromRGB(color));
                    }
                    repairableindex = 3;
                } else if(ismeta instanceof PotionMeta) {
                    if(msplit.length > repairableindex) {
                        boolean ispotion = true;
                        if(msplit[repairableindex].contains("+")) {
                            PotionMeta pmeta = (PotionMeta) ismeta;
                            for(; repairableindex < msplit.length && ispotion; repairableindex++) {
                                if(msplit[repairableindex].contains("+")) {
                                    String[] potion = msplit[repairableindex].split("\\+");
                                    PotionEffectType type = PotionEffectType.getByName(potion[0]);
                                    int amplifier = Integer.parseInt(potion[1]);
                                    int duration = Integer.parseInt(potion[2]);
                                    PotionEffect pe = new PotionEffect(type, duration, amplifier);
                                    pmeta.addCustomEffect(pe, true);
                                } else {
                                    ispotion = false;
                                    repairableindex--;
                                }
                            }
                        }
                    }
                }
                if(ismeta instanceof Repairable) {
                    if(msplit.length > repairableindex) {
                        Repairable rmeta = (Repairable) ismeta;
                        rmeta.setRepairCost(Integer.parseInt(msplit[repairableindex]));
                    }
                }
            }
        }
        is.setItemMeta(ismeta);
View Full Code Here

                smeta.append("F" + effect.getType().name() + "+" + colorstring.toString() + "+" + fadecolorstring.toString() + "+" +
                        effect.hasFlicker() + "+" + effect.hasTrail() + "#");
            }
        }
        if(meta instanceof Repairable) {
            Repairable rmeta = (Repairable) meta;
            smeta.append("R" + rmeta.getRepairCost());
        }
        return smeta.toString();
    }
View Full Code Here

TOP

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

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.