Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static boolean SetDurability(ItemStack wrench,Player p) {
- ItemMeta im = wrench.getItemMeta();
- if(!im.hasLore()){
- // SCUtils scutils = new SCUtils();
- SCUtils.NotifyOwner(p, "hat einen veralteten Schraubenschlüssel verwendet und verliert keine Durability.");
- }
- List lore = im.getLore();
- String[] dur = lore.get(1).toString().split(" / ");
- int halt = Integer.parseInt(dur[0]);
- halt--;
- if(halt != 0){
- ArrayList<String> list = new ArrayList<>();
- list.add("Durability");
- list.add(halt + " / 1561");
- im.setLore(list);
- wrench.setItemMeta(im);
- ActionBarAPI.sendActionBar(p, "§6Schraubenschlüssel Durability: §5" + halt + " / 1561");
- int maxdur = wrench.getType().getMaxDurability();
- int teiler = halt / 62;
- int s = maxdur - teiler;
- Damageable schaden = (Damageable) im;
- schaden.setDamage(--s);
- wrench.setItemMeta((ItemMeta) schaden);
- } else {
- ItemStack air = new ItemStack(Material.AIR, 1);
- PlayerInventory pinv = p.getInventory();
- pinv.setItemInOffHand(air);
- p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 2.0F);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement