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.

Maven

<repository>
    <id>codemc-repo</id>
    <url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<dependency>
    <groupId>me.filoghost.farmlimiter</groupId>
    <artifactId>farmlimiter-api</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

Code example

// Your listener class, remember 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();
            }
        }

    }
}