Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void reparation(ItemStack i) {
- if ((i != null) && (i.getDurability() != 0) && (!i.getType().isBlock()) && (i.getType().getMaxDurability() >= 1)
- && i.getType() != Material.GOLD_PICKAXE) {
- if ((i.getType() == Material.DIAMOND_SWORD || i.getType() == Material.DIAMOND_AXE)
- && i.containsEnchantment(Enchantment.DAMAGE_ALL)
- && i.getEnchantmentLevel(Enchantment.DAMAGE_ALL) == 6) {
- ItemMeta meta = i.getItemMeta();
- String novoReparo = null;
- boolean b = false;
- if (meta.hasLore()) {
- List<String> l = meta.getLore();
- for (String s : l) {
- if (s.startsWith("§eReparos restantes:§6 ")) {
- String[] split = s.split(" ");
- int reparos = Integer.parseInt(split[2]);
- if (reparos == 0) {
- return;
- }
- reparos -= 1;
- novoReparo = "§eReparos restantes:§6 "
- + ((reparos == 0) ? 0 + " §c(Não Reparável)" : reparos);
- b = true;
- break;
- }
- }
- }
- if (b) {
- List<String> l = meta.getLore();
- l.remove((meta.getLore().size() - 1));
- l.add(novoReparo);
- meta.setLore(l);
- } else {
- if (meta.hasLore()) {
- meta.getLore().add("§eReparos restantes:§6 10");
- } else {
- List<String> s = new ArrayList<>();
- s.add("§eReparos restantes:§6 10");
- meta.setLore(s);
- }
- }
- i.setItemMeta(meta);
- } else if ((i.getType() == Material.DIAMOND_HELMET || i.getType() == Material.DIAMOND_CHESTPLATE
- || i.getType() == Material.DIAMOND_LEGGINGS || i.getType() == Material.DIAMOND_BOOTS)
- && i.containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL)
- && i.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 5) {
- ItemMeta meta = i.getItemMeta();
- String novoReparo = null;
- boolean b = false;
- if (meta.hasLore()) {
- List<String> l = meta.getLore();
- for (String s : l) {
- if (s.startsWith("§eReparos restantes:§6 ")) {
- String[] split = s.split(" ");
- int reparos = Integer.parseInt(split[2]);
- if (reparos == 0) {
- return;
- }
- reparos -= 1;
- novoReparo = "§eReparos restantes:§6 "
- + ((reparos == 0) ? 0 + " §c(Não Reparável)" : reparos);
- b = true;
- break;
- }
- }
- }
- if (b) {
- List<String> l = meta.getLore();
- l.remove((meta.getLore().size() - 1));
- l.add(novoReparo);
- meta.setLore(l);
- } else {
- if (meta.hasLore()) {
- meta.getLore().add("§eReparos restantes:§6 10");
- } else {
- List<String> s = new ArrayList<>();
- s.add("§eReparos restantes:§6 10");
- meta.setLore(s);
- }
- }
- i.setItemMeta(meta);
- } else if ((i.getType() == Material.DIAMOND_HELMET || i.getType() == Material.DIAMOND_CHESTPLATE
- || i.getType() == Material.DIAMOND_LEGGINGS || i.getType() == Material.DIAMOND_BOOTS)
- && i.containsEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL)
- && i.getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL) == 6) {
- ItemMeta meta = i.getItemMeta();
- String novoReparo = null;
- boolean b = false;
- if (meta.hasLore()) {
- List<String> l = meta.getLore();
- for (String s : l) {
- if (s.startsWith("§eReparos restantes:§6 ")) {
- String[] split = s.split(" ");
- int reparos = Integer.parseInt(split[2]);
- if (reparos == 0) {
- return;
- }
- reparos -= 1;
- novoReparo = "§eReparos restantes:§6 "
- + ((reparos == 0) ? 0 + " §c(Não Reparável)" : reparos);
- b = true;
- break;
- }
- }
- }
- if (b) {
- List<String> l = meta.getLore();
- l.remove((meta.getLore().size() - 1));
- l.add(novoReparo);
- meta.setLore(l);
- } else {
- if (meta.hasLore()) {
- meta.getLore().add("§eReparos restantes:§6 5");
- } else {
- List<String> s = new ArrayList<>();
- s.add("§eReparos restantes:§6 5");
- meta.setLore(s);
- }
- }
- i.setItemMeta(meta);
- }
- i.setDurability((short) 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement