EntityGuard
Overview
EntityGuard allows you to take control of most entities in your server. It controls and limits the entity count for XP farms, iron farms, animal farms...etc. Every entity uses a small amount of ram in your server, so limiting and controlling the entities are very important. EntityGuard can remove entities that are over the limit you set and it's done fully automatically.
Features
- Very lightweight.
- Reduce entities.
- Reduce memory usage.
- Increase server performance.
- Trim mobs that are over the limit.
- Prevent players from stacking mobs.
- Check every entity's info around you.
- Work fully automatically.
- Everything is configurable.
How does this plugin work?
EntityGuard will automatically check the entity count for players every certain amount of time. If it finds out that the entity count is over the allowance, it will then remove/ de-spawn mobs. It can remove/ de-spawn hostile mobs, passive mobs, iron golem, tamed pets...etc.
Commands
- /entityguard run -> Kill entities that are over the limit.
- /entityguard check [Player] [Radius] -> Check entities around a player.
- /entityguard reload -> Reload configuration file.
(Note: /entityguard or /eg)
Permissions
- entityguard.admin - Allow to use all the EntityGuard commands.
- entityguard.bypass - EntityGuard will not check and remove entities for players with this permission.
Configuration
#Config Version. Do not change this. version: 2 # What to do if mob count is over the limit? #Set to: 1 = Remove the exceeding mobs and warn players; 2 = Remove the exceeding mobs and kick players. action: 1 # Run the action every x minutes. auto_run_delay: 10 mob_control: # Should EntityGuard auto-runs for you? Otherwise you can manually do "/eg run". auto_run: true # EntityGuard doesn't count and check the mobs from loaded chunks, it counts and checks them from the boundary of the player. # If you set the radius to 32, the boundary would be 32 blocks from each direction centered by the player but the checking height is from y = 0 to y = 255. check_radius: 50 # You can only choose one method: 1: Limit_for_all_mobs, 2: Limit_individually limit_method: 1 method: # Method 1: Limit for all mobs (Recommended method!) # If you set the allowed_amount to 100, it means there will only be 100 mobs that survive within the boundary of a player after the auto-run . # EntityGuard will randomly de-spawn mobs that are over the limit. # Note that this limit is per player only. method_01: allowed_amount: 100 # Method 2: Limit mobs individually (This method will use a bit more cpu resources as the process is more complex) # Set limit per individual mob type. # Note that these limit is also per player only. For example: If you set pig to 20 and total online player is 10, the limit for pig will be 20*10=200 pigs. method_02: #passive_mob Pig: 10 Sheep: 10 Chicken: 10 Mooshroom: 10 Cow: 10 Tamed_Wolf: 10 Tamed_Ocelot: 10 Wild_Ocelot: 10 Tamed_Horse: 10 Wild_Horse: 10 Snow_Golem: 10 Villager: 24 Pet_Iron_Golem: 5 Squid: 5 Bat: 5 #neutral_mob Cave_Spider: 50 Enderman: 50 Spider: 50 Wild_Wolf: 10 Zombie_Pigman: 50 #hostile_mob Wild_Iron_Golem: 10 Skeleton: 50 Zombie: 50 Blaze: 50 Silverfish: 50 Ghast: 10 Slime: 50 Magma_Cube: 10 Creeper: 20 Witch: 20 Ender_Dragon: 2 Wither: 2 Giant: 2 # Warn Message warn_message: 'You have stacked too many mobs that may lag the server! Please kill some of the mobs!' # Kick Message kick_message: 'You are kicked because you have stacked too many mobs.' # Maximum radius allowed to check for command /eg check. allow_check_radius: 200 # Show auto-run message in console. console_msg: true
To-do-list
- Control non-living entities like (Boats, arrows...etc)
- Control massive auto-cactus farm.
McStats
This plugin utilises Hidendra's plugin metrics system, which means that the following information is collected and sent to mcstats.org:
- A unique identifier
- The server's version of Java
- Whether the server is in offline or online mode
- The plugin's version
- The server's version
- The OS version/name and architecture
- The core count for the CPU
- The number of players online
- The Metrics version
Report bugs
Reporting bugs or requesting for specific features is welcome!
Mooshroom needed to be MushroomCow in my config for Method2
@herweg
I can confirm the auto run check is not working for 1.79, although apparently players are getting a message informing them they have too many mobs. Manually running the /eg run command will remove the excess mobs.
This plugin works properly (without error messages in the console). However, as anfereon said before, the "auto run check" is not working properly (it does not work). Please AoceTW, update your plugin for us. :) For the people interested in using this plugin as it is (in a useful and working way), in this 1.1 version, just do the following: In the config you select method_02 (I put around 10 as the number for most mobs/animals); at the end of the config file you put all messages as empty (like this, with both the ' signals without any message: kick_message: ''). And, finally, you can use your prefered plugin to execute automated actions (a plugin to run a command, as if it was in the console. I used AutoSaveWorld (very good), but many others can do it too. I selected the "/eg run" command to be executed (to run) every 20 minutes. It means that at every 20 minutes the mobs and animals which are more than the choosen number (for example, more than 10 pigs around a player) are removed. Well, that's it. I hope this info can help. Just sharing some info (my 2 cents). By the way, tested in a server with Minecraft 1.7.5 (spigot, dev version 1387). AoceTW, thank you for your plugin. :)
This plugin does not work. It doesnt auto run checks. And when I run it manually it uses both methods for checking, not just one, so I can't even set some other plugin to run this command. Completely useless plugin.
I think the Author isn't answering us or doesn't have time too. But please add mob area support!
No answer to previous question? Does it cull all entities or just mobs? It does count them, and I'm scared to try.
Very nice plugin.
Question: Since it counts non-mob entities into the Other category, does it actually count and cull those (or culling mobs instead due to being included in count) or how does that work?
We have areas with many entities but not mobs that I don't wanna get ruined.
Idea: It might be nice to have a "whitelist" option of mobs and/or entities to not touch in culling with a true/false to include them in counting or not.
@stgram
To question one, yes you get to choice one of the two methods for limiting mobs. And I only know java and don't konw about pseudo code. About the checking range, I will make Y configurable in next release. So yeah, this is the method for now, if i come up with a better way of calculating and coding, I will update my plugin. Also, I find that you make more sense, would you interested and volunteering to be the documentor of this plugin? Documenting for config comments and plugin page. If you are please contact me via pm, I will add you to the plugin page as "Documenter".
@AoceTW
Nice! So, Method 1 is the old random method, and Method 2 is the limit-per-mob algorithm? I believe a final touch would be to use your per-mob setup and make it dinamic via the formula I came up with, which is just a simple calculation using already found values, please share your opinion on that. I could even write you a pseudo code that would be cpp/php like, since I dont know java. Also, I would suggest modifying the check to not be vertical from top to bottom, spigot automatically disables mobs outside a set player radius so they are not really a threat, and you cant blame a player for the 30 bats in the grounds beneath him. :)
@stgram
Never mind the below comment. I managed to finish the plugin with features you requested while keeping my codes as simple as possible! Entity Guard v 1.1 is now awaiting for approval. If you have any suggestions on this plugin, feel free to request for it. Cheers!
@stgram
I have been busy developing a rpg plugin. :) No one was offended. Anyways, I tried to add the features that you requested. But i ended up with hundreds of lines of codes in order to have trim mobs to the limits. It will require more checkings and so I just gave it up. So I think you either use creaturesapwnevent to disable mobs from spawning when reaching the spawn limit or use my plugin to auto-run trims the mobs every 10 or 20 minutes. So yeah, do you agree?
@AoceTW
Hey, you still there? Hope I didn't offend you somehow by getting too deep inside your work. I have a few more suggestions, if you'd like to hear them. :)
@AoceTW
I would not suggest going that hard-coded about it. Simply, when there are animals over the count, kill an equal percentage of all of them. Lets say you count mobs around me - you build an array with all the animals' data, and count 5 zombies, 60 cows, 40 chickens, 8 sheep, 80 pigs, 2 horses. Limit is 100, zombies dont count here.
Count the median, in this case 190/5 = 38. You have 3 over the median, so you cut the cow crowd by 60/(190-8-2)*(190-100)=30. Pigs are going down by 80/(190-8-2)*(190-100)=20. 20 chicks get sacrificed. Total mob count after = 100. Horses are intact. (my precious)
25 minutes later: I did a Google Spreadsheet on the idea. Request edit access if you want.
Yeah, I am an algorithm maniac. Run.
Idea2: Why dont you simply include a warning threshold. Above 80, warn, above 100, delete and notify.
Idea3: Time the check task and display the ms needed for execution, just for information and future possible debugging. Also, is it performed in the main thread?
Interesting. I'll keep an eye on this plugin for next release. Could clear up a lot of resources!
@stgram
1. Thanks for being the first server implementing my plugin. And you are welcome.
2. Every suggestion matters because I do consider it. I can make it not -random kill mobs as another option. Will add this feature in the future releases. In your config will be like: Pig_allowed: 10, Cow_allowed: 5...etc.
3. It does not, but I could make the warning as a individual setting like: enable_warn: true/false
Lastly, stay tuned for the next release :)
@AoceTW
So far, so good, on 40 players rush hour it worked instantly. Thank you for providing this piece of code that I consider essential to any resource-limited server.
I would still suggest thinking about not-random mob crowd trimming, for the sake of symmetry. If a player has 100 cows and 100 chickens, we dont want to rob him of his precious milk and BigMacs, he would just understand that stacking mobs is not going to work. But then again, it is just a suggestion. :)
Does setting the action to 1 include the 0 - warn as well?
@stgram
Spawn limit is per group of course. And it trims the mobs literally randomly until the mob count is equal to the mob limit(I could make it trim mobs by percentage, but I dont think its that necessary).
When EntityGuard auto-runs, it check and trim mobs around each player one by one. Code is like this:
for(each online player){ if(mob count > limit){ kill mobs that are over the limit } }
@AoceTW
Yeah, you do prove a point.
These spawn limits are per group, not per mob type, right? If I have 80 chickens and 80 cows, do you have logic to trim all mob types by 30 entitites (perhaps even percentage), or is it random (oldest mobs etc.) and I could be left with 80 chickens and 20 cows?
On the other side, your plugin will have to check all players at once every 10 minutes, and call out for many many mobs in one action. Is your cleanup task asynchronous?
@stgram
What my plugin does is that it checks for each online player every x minutes. And if the mob count is more than the limit(you set in config) around a player in a radius of x blocks(you set in config). Then the plugin will kill the mobs that are over the limits. Also there is no Eventlistener used in my plugin cos i think that if you use "CreatureSpawnEvent" its more cpu tensive. Imagine if you have 200 mobs spawning every minute. Bukkit is going to call the event for 200 times.
I love you. (please dont run away.) I've been looking for a mob-controlling plugin for quite a while to fight my 4000 entities. I'll keep a close eye on your creation, and will provide timings/examines if necessary.
By the way, what kinds of control do you introduce? Only this regular check every X minutes, or do you hook to the spawn/breeding events?