MobInventory
Features
Any and every mob can now store items just like a chest. All you have to do is right click on the mob you want.
Commands
None
Configuration
None
Notes
Some errors are thrown upon startup/restart
I hope this plugin is helpful.
Possible upcoming features \ Changes
Admin only access to inventory's
limit what mobs can be accessed
Possible blocking of inv slots on certain mobs
Latest working version (not approved, use at your own risk)
https://github.com/themandalton/mob_inv/tree/working
This plugin can be very helpful for servers, one problem is that you could make your code a lot better since there's a lot of lines which are not necessary and it the plugin causes a lot of errors which could possibly make a huge lag in some servers and cause log files to be big.
In reply to MCGamer199:
@2008Choco
In the plugins current configuration inventory's are stored in HashMaps<UUID, Inventory> while the server is up. On server shutdown all item stacks are written to a .txt file in the same line as the mob's uuid. On server startup there is a read from file to import the exported inventory's into another HashMap<UUID, ArrayList<ItemStack>>.
In order to keep cpu usage to a minimum I chose to only read from file once instead of any time a mob is clicked on. Instead when a mob is clicked on an inventory is created from the ArrayList of itemstacks.
@CloudeLecaw Thanks for the support
@CloudeLecaw
You bring up some good points here. It would be a nice feature to mimic mobs holding items. (They don't de-spawn). ChunkUnloadEvent and ChunkLoadEvent would come in handy for this feature.
I would also suggest perhaps storing item contents of an entity's inventory in a inventories.yml file or something along the lines of that. If an inventory is closed, check if it's an inventory owned by the entity, loop through the contents of the inventory (inv.getContents()), and save them in a configuration file one by one under the entity's UUID (entity.getUniqueId()). Then, when an inventory is opened, grab the UUID of the clicked entity, and if it's in the inventories.yml file, grab the contents, and place them in the inventory. Otherwise, make a new inventory, and continue the process above.
The logic provided above keeps all the memory of an entity stored. Though be cautious because if you use the UUID, it has to be that one specific mob that you clicked.
Great work so far, but I'd work a lot more on it before doing another update. Resetting inventories on reload isn't very useful. Congratulations for getting this working though! I'm sure you can improve this a million times over! Keep up the great work, my friend