How to make chain armor unbreakable...

Discussion in 'Plugin Development' started by Slash9211, Apr 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Slash9211

    I created a plugin to buff chain armor (It worked) yet it kills the durability. How could I make only chain armor unbreakable?
     
  2. Offline

    TheMcScavenger

    EntityDamageEvent, get if it's a player, get his armour contents, and per item check if it's chain, and repair it.
     
  3. Offline

    Cammeritz

    Code:
    package de.Cammeritz.DevHelp;
     
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.inventory.ItemStack;
     
    public class UnlimitedChain {
     
        @EventHandler
        public void onChain(EntityDamageEvent ev) {
            if(!(ev.getEntity() instanceof Player)) {
                return;
            }
           
            Player p = (Player) ev.getEntity();
           
            for(ItemStack i : p.getEquipment().getArmorContents()) {
                if(!( i.getType() == Material.CHAINMAIL_BOOTS || i.getType() == Material.CHAINMAIL_CHESTPLATE || i.getType() == Material.CHAINMAIL_HELMET || i.getType() == Material.CHAINMAIL_LEGGINGS )) {
                    continue;
                }
               
                short durability = 0;
               
                i.setDurability(durability);
               
            }
           
            return;
        }
       
    }
    
    I hope it helped u :)
     
Thread Status:
Not open for further replies.

Share This Page