[API 5/6] ClearMob [ClearLag Port] [Vanilla/Modded]

MC Version 1.10.2

Able to define list of entities the plugin clears.

Has a passive mode that runs the clear in intervals (Asynchronously), which can be disabled or set to different intervals. Also has a customizable warning message that can be enabled to run a minute before passive mode clears entities.

Added Passive Group Killer. Checks if groups of animals are larger than 5 in a 20 block radius, leaving 5.

Crash Chunk Load Clearing (Disabled by default for obvious reasons)
New Feature added in 1.0.4. Used to help try and remove an entity causing the server to crash. Using the LoadChunkEvent, it will make a list of all entities in the chunk when it loads and clears them. This ignores the list altogether For modded Minecraft, this means it can clear Thaumcraft Auranodes and Botania Sparks (To name a few)
Should only be used when server is whitelisted as it will run for every chunk loaded.

Changelog:
1.3.1
-NPE Fix from version 1.3.0
Removed ListType (Will always remove whats on the list)
Added Info Command.
Added features to run command.
Fixed Colored messages.

  • Further Explanation on Command Reference.

1.2.0
Added Hostile Entity Limiter
Various Bug Fixes.

1.1.0
Huge rewrite. Split a lot of clearers into their own classes. Added more null checks.

1.0.6
Added Passive Group killing. (Removes Animals when groups)

1.0.5
Added Support for Tile Entities (Like torcherino)
Changed dump and run commands.
Updated passive mode for new change to run command. (Passive mode does not support tile entities)

1.0.4
Added Features:
clearmob tps command.
clearmob reload command
Restructure of config (Done automatically)
Added CrashChunkClear mode (Removes entities on chunk load, disabled by default)
Added Warning message for passive mode
Added Killallmobs and Killdrops options. (Higher priotity than defined list)

Planned:

  • An ā€˜addā€™ command, to add entities to the config without having to manually edit it.
  • Clear 80% of a group of neutral mobs, filter ones with nametags.

Source Code
Issue Tracker/Feature Requests
Config Explained
Commands

All Future Updates will be posted on Ore

1.3.1
1.2.0
1.1.0
1.0.6
1.0.5
1.0.4
1.0.3
1.0.0

4 Likes

Sponge API 5.0.0 is for MC 1.10.2.
Sponge API 4.1.0 is for MC 1.8.9.

build.gradle:

dependencies {
compile ā€˜org.slf4j:slf4j-api:1.7.13ā€™
testCompile ā€˜junit:junit:4.12ā€™
compile ā€˜org.spongepowered:spongeapi:4.1.0ā€™
}

Running it on both a test 1.10.2 Vanilla server and a public 1.10.2 Modded server.

OK, but itā€™s still built for 1.8.9. It runs on 1.10.2 simply because it doesnā€™t depend on anything that broke (yet).
Also, your projectā€™s a bit borked. Thereā€™s class files in the git repo, and none of the standard gradle paraphernalia is present.

Edit: Oh, I see. Youā€™ve added them to .gitignore, but youā€™re supposed to keep settings.gradle, gradlew, and gradlew.bat in your project - theyā€™re necessary for people to be able to build it locally. I just use Spongeā€™s gitignore myself.

Thereā€™s also a slightly borked gradle init - youā€™ve got a Library.java file in your source root, which is autogenerated by gradle and therefore pointless.

Should look a bit better now. Thanks for the tip.

A couple of notes on the project:

  • Youā€™re injecting the logger, but not actually using it. Donā€™t send stuff to the console, just log it.
  • Do different things at different times. For example: Config stuff is available at GamePreInitializationEvent.
  • For the above point, itā€™s important that you remember: In singleplayer, the server can stop and start multiple times, or not ever start, meaning that your commands and config and stuff might never get registered, or may get done multiple times. This is not a good idea. All things relating to loading should be done in events related to initialization, e.g. config in pre init, commands in init, etc.
  • You donā€™t need to initialize list_entities with an ArrayList if youā€™re just going to load it from the config at the earliest opportunity.
  • Your commands can be improved - this describes a better way of making your CommandSpec. You then make different classes for different executors, eliminating parsing entirely.
  • Absolutely none of the statics in Config need to be static.
  • Youā€™re injecting the configuration loader, and then not using it. This throws away Spongeā€™s custom configuration settings, such as being able to retrieve objects like Text directly from the config, as well as hardcoding where files go. Other things that you can load directly from the config include EntityTypes, which mean that you can use them directly instead of your strings.
  • In accordance with the above point, you should be injecting the default config for the path as well as the configuration loader, instead of the config dir - this lets Sponge decide where the configuration file goes.
  • Your code has some interesting quirks. For instance, why are you creating a new Object[] in your getNode calls, when itā€™s a vararg? Why are you using a numerical iterator over list_entities?
  • Just type args.checkPermission(src, ā€œclearmob.runā€) and itā€™ll do the permission checking for you.
  • Donā€™t return null in commands, ever. You should be throwing CommandException if the command failed.
  • CommandResults should be useful; why not do CommandResult.builder().queryResult(removedEntities).build()?
  • You have a lot of exception catchers that do nothing. At the very least you should print a stack trace.
  • Just a minor gripe, but Java conventions for variables are camelCase instead of under_score.
  • Instead of making your own reload command, listen for GameReloadEvent and do your logic there.
  • I am confused as to why you map the entity list to lower case, and proceed to ignore the case during your equality checking.
2 Likes

Checked everything pie mentioned and agree with all of it.

Also as a feature request, could you have a config option to change it from a whitelist to a blacklist?
When some new modpacks come out with 100+ entities itā€™ll be a pain to list all that I want gone, rather than add the ones I want to keep.

Iā€™m currently working on changing the source code to pieā€™s list. After Iā€™m through that, I can add a config option for white/black list rather easily.

@rojo8399 This version: 1.0.2a has a fully working Whitelist/blacklist in it. Sorry it took a bit XD I got stuck on something, which turned out to me being dumb.

I am getting this error using the latest versionā€¦ http://pastebin.com/WEEugBG0

Did you do this: When updating from 1.0.0 to 1.0.2, you need to add ListType=Whitelist to the end of your config.

Or more specifically, does your config contain this phraise:
ListType=Whitelist

I tried to add some code to automatically apply that lineā€¦ didnā€™t want to takeā€¦ maybe a future release will work properly lol

[Edit] Got that code working now, so any future config changes will be automatically done. Dunno why it didnā€™t work last time, I did the same thingā€¦

It was a fresh install and it doesnā€™t create a config file. :frowning:

Okay, I tried another test and I see what happenedā€¦ I should have a new version for tomorrowā€¦ I dont know how this got broke during the creation.

1 Like

@TreasureIsland Try this one: Here

I fixed the issue with the config, and tested it 5 times. It properly gens the folder and the config, sorry about that.

1 Like

This version also has a few things added such as Passive Mode. Which is now automatically added to any old version of the config. It adds 2 nodes
PassiveMode=true
Interval=60.

The PassiveMode node allows you to disable passive mode, while the Interval is how many seconds between it running the clear automatically.

All of this is done asynchronously.

1 Like

New Update: Adds several features including the Crash Chunk Load Entity Clear.

New Update: Addā€™s support for clearing Tile Entities.

item on ground not clear or delete automatic. How to config?
clearlag easy to use.

Config Explained

You could have added ā€œminecraft:itemā€ to the entitylist orā€¦ could have toggled KillDrops to trueā€¦

If another item in another mod.
Example item of immersive mod.