Description
Farm Limiter prevents players from making abnormal mob farms, limiting groups of near entities of the same type. This is a common issue on survival servers. Farm Limiter is able to limit mob farms, e.g.:
- Friendly mob farms, counting hundreds of entities pushed into a very tight space.
- One block wide automatic chicken farms, which generate a lot of lag.
- Mob grinders with spawners, counting dozens of monsters when the players do not harvest them.
- The plugin will search occasionally mob farms that are too big for the rules and remove exceeding mobs.
- The plugin will give priority to entities with certain characteristics (taming, custom names, saddle, etc.).
- Option to completely ignore tamed entities.
- You are able to customize the rules, the check interval, as well as the broadcast message.
- You can still remove all the rules and use the "/farms search" command to list the biggest entity groups periodically, and eventually remove them.
How Farm Limiter sees groups of entities, each color represents a different type (view from the top):
Installation
- Stop the server
- Move FarmLimiter.jar to the plugins folder
- Start the server (to generate the configuration)
- Stop the server
- Edit the configuration in /plugins/FarmLimiter/config.yml (read below)
- Start your server
You can find everything in the config.yml. The first time you open it, it will look like this:
Code:
# Plugin created by filoghost. All rights reserved.
# Redistribution of this product is forbidden.
check-interval: 180
broadcast:
enable: true
message: '&6[FarmLimiter]&e Removed {amount} entities.'
minimum: 1
rules:
# A global rule active on all the worlds, for groups with 50+ near entities.
- entities: all
worlds: all
distance: 3
max-amount: 50
# A rule to avoid friendly mob farms, limit the mob amount to 25.
- entities: pig, cow, sheep, chicken
worlds: all
distance: 5
max-amount: 25
# A rule for spawner grinders, max of 10 mobs of the same type in the same block.
- entities: zombie, skeleton, spider, cave spider
worlds: all
distance: 0.5
max-amount: 10
extra:
# The rate of mobs that will successfully spawn from a nether portal.
# Setting to 0% disables mobs spawning from portals.
portal-spawn-rate: '100%'
# Whether to exclude tamed entities or not
exclude-tamed: true
check-interval: the amount of seconds between each check.
broadcast > enable: if you want to enable the broadcast message
broadcast > message: configure the broadcasted message. {amount} is the number of mobs despawned after the check.
broadcast > minimum: if the number of mobs despawned is below the minimum, the message will not be broadcasted.
rules: a list of rules, each one made of four parts. To make a new rule, it's highly recommanded to copy and paste from another one (don't forget to include the dash and the spacing!).
A single rule is made of the following nodes:
Code:
- entities: ...
worlds: ...
distance: ...
max-amount: ...
entities: a list of entity types affected by the rule, separated by a comma. "ALL" means all the types.
Please note that the plugin will not detect a group of different entities, but instead it will apply the rule for each type separately.
worlds: list of worlds where the rule is active, separated by a comma. "ALL" means all the worlds.
distance: the max distance between the entities to be considered part of the same group.
max-amount: the max amount of entities allowed for this rule. If a bigger group is found, the plugin will attempt to remove the entities in this order:
- Oldest entities without a name tag
- Newest entities without a name tag
- Entities with a name tag
Commands & Permissions
The permission for all the commands is farmlimiter.admin
/farms reload
Reloads the plugin.
/farms check
Forces the plugin to check for mob farms. It tells the executor the amount of entities removed (even if it's not broadcasted).
/farms entities [world = current] [minTypeAmount = 10]
Lists all the entities grouped by type (including non-living ones) and sorted by amount in a single world.
[world] is world to check, yours by default.
[minTypeAmount] is the minimum amount of entities of a type to show up in the output.
/farms search <entityTypes> [distance = 5] [worlds = all]
Manually search for the biggest groups of the specified entity types.
<entityTypes> are the entity types to check, separated by a comma. Don't use spaces in between!
[distance] is the max distance between the entities, 5 by default.
[worlds] are the worlds to check, separated by a comma, all by default. Don't use spaces in between!
Developer API
The current API is pretty small: you can change which mobs are removed by the plugin, when the task is being run. The event is FarmLimitEvent.
Code:
// 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> iterator = entitiesToRemove.iterator();
while (iterator.hasNext()) {
LivingEntity current = iterator.next();
if (current.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) {
iterator.remove(); // Prevent entities with resistance from being cleaned up by removing them from the event.
}
}
}
}