Attributes to Living Entity's?

Discussion in 'Spigot Plugin Help' started by T3tr3x, Jun 30, 2018.

  1. Hello! So I've been trying to find the easiest way to store attributes / nbt data into mobs.

    This is about as much as I've come up with and I'm unsure how I should proceed, the general idea is to check config for an int value, and mobs under that type can only breed the specified amount. This is what I have so far, any help is appreciated. Thanks :)

    Code (Text):
    public class Main extends JavaPlugin {
       
        private FileControl fc;

        @Override
        public void onEnable() {
            Map<EntityType, Integer> maxBreed = new HashMap<EntityType, Integer>();
            this.saveDefaultConfig();
            this.getConfig();
            FileConfiguration config = this.getConfig();
            fc.getConfig().addDefault("Enabled", true );
            fc.getConfig().addDefault("AnimalCaps.Cow", 5);
            fc.getConfig().addDefault("AnimalCaps.Pig", 5);
            fc.getConfig().addDefault("AnimalCaps.Sheep", 5);
            fc.getConfig().setDefaults((Configuration) maxBreed);
            fc.save();
            if (fc.getConfig().getBoolean("Enabled", false)) {
                setEnabled(false);
            }
        }
           
        public void onBreed(EntityBreedEvent e) {
            AttributeModifier modifer;
            for (AttributeModifier modifierOnEntity: e.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_ARMOR).getModifiers())
            {
            if (modifierOnEntity.getUniqueId().equals(modifer)) {
                modifer=modifierOnEntity;
                break;
            }
            if (modifer!= null) {
                e.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_ARMOR).addModifier((AttributeModifier) getForType(e.getEntity().getType()));
            } else {
                int left=Integer.parseInt(modifer.getName());
                left--;
                if (left==0) {
                    e.setCancelled(true)e;
                    e.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_ARMOR).removeModifier(modifer);
            } else {
                e.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_ARMOR).addModifier(getFor(e.getEntity().getType(), left));
            }
               
            }
           
            }
          }
       
       
            private AttributeModifier getForType(EntityType type) {
            return null;
                }

            private AttributeModifier getFor(EntityType type, int left) {
                return null;
                }
    }