Developer API

The current API consists of a single event that allows to change which mobs are removed by the plugin. The relevant class is me.filoghost.farmlimiter.api.FarmLimitEvent.

Code example:

// Your listener class, don't forget to register it
public class MyListener implements Listener {

    @EventHandler
    public void onFarmLimit(FarmLimitEvent event) {
        Collection<LivingEntity> entitiesToRemove = event.getEntitiesToRemove();
        Iterator<LivingEntity> entityIterator = entitiesToRemove.iterator();

        while (entityIterator.hasNext()) {
            LivingEntity entityToRemove = entityIterator.next();

            if (entityToRemove.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) {
                // Prevent entities with resistance from being cleaned up by removing them from the event.
                entityIterator.remove();
            }
        }

    }
}