Aquerr / ChestRefill

A plugin for refilling/restocking chests on a Minecraft Server that uses SpongeForge.
MIT License
4 stars 4 forks source link

Error occured while executing command: null #11

Closed robbelouwet closed 4 years ago

robbelouwet commented 5 years ago

Environment

What happens?

When I type /cr list I get a java.lang.NullPointerException.

I am using this plugin on a 1.12.2 hunger games-like server, and currently have 147 refillable chests (yes, it took me a couple of hours :s). The error occured when I created the 120th refillable chest, maybe it's some sort of index out of bouds issue? Is the memory for storing these chests dynamically allocated? Just throwing out thoughts...

Expected result

A list of all the refillable containers in the chat.

More information

Error log from the terminal: (pastebin, easier to read) [19:56:20] [Server thread/INFO] [minecraft/DedicatedServer]: Error occurred while executing command: null [19:56:20] [Server thread/ERROR] [Sponge]: Error occurred while executing command 'cr l' for source DedicatedServer: null java.lang.NullPointerException: null at io.github.aquerr.chestrefill.commands.ListCommand.execute(ListCommand.java:64) ~[ListCommand.class:?] at org.spongepowered.api.command.args.ChildCommandElementExecutor.execute(ChildCommandElementExecutor.java:255) ~[ChildCommandElementExecutor.class:1.12.2-2825-7.1.6] at org.spongepowered.api.command.spec.CommandSpec.process(CommandSpec.java:388) ~[CommandSpec.class:1.12.2-2825-7.1.6] at org.spongepowered.api.command.dispatcher.SimpleDispatcher.process(SimpleDispatcher.java:340) ~[SimpleDispatcher.class:1.12.2-2825-7.1.6] at org.spongepowered.common.command.SpongeCommandManager.process(SpongeCommandManager.java:337) [SpongeCommandManager.class:1.12.2-2825-7.1.6] at net.minecraft.command.ServerCommandManager.func_71556_a(SourceFile:1156) [dh.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71333_ah(DedicatedServer.java:433) [nz.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:398) [nz.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_221] I should maybe point out that my containers.json file has about 50.000 lines... (Got a big kit assigned to 147 chests :s)

Is it a memory problem? Can it be fixed?

Suggestion: my kits.json has 500 lines (it's just 1 kit). Maybe don't copy every item from the kit to the chest items-attribute in container.json, this results in 500 extra line per chest registry in containers.json, maybe this leads to memory corruption while loading it when playing live? (50.000 lines!) Maybe try creating a pointer to the kit (in "items") in containers.json for every chest instead of copying all the items from the kit.

/cr list is the only command that doesn't work, everything else works fine.

Aquerr commented 5 years ago

You are absolutely right about kits. 😃 It is dumb that items are imported to the chest. There must be a reason I left it like this but I simply don’t remember why. I will try to fix this this week probably. I will notify you in this issue when it will be done.

When it comes to that error you are getting. I need to look at this tomorrow. Will message you if I find something. 😃

robbelouwet commented 5 years ago

Ok let me know...

Some other suggestions, maybe have a minimum and maximum amount of items a kit can spawn, otherwise chests might spawn empty :/ (if the items from the kit have a low chance of spawning) . You could also make the items spawn in random slots in the chests in-game, not just listing the items starting from the first slot. Just a suggestion :D

robbelouwet commented 5 years ago

I just noticed, when I try to open the 50.000 lines chests.json file in IntelliJ, it creates 2 'xxxxxxxxxxxxcontainers.json.temp' files in my config/chestrefill folder in my forge server folder (xxx... being a random big number, windows :s), maybe here lies the problem?

Aquerr commented 5 years ago

@robbelouwet It should not be a problem. Plugin reads contents of the file called containers.json. Other names are simply ignored.

I just pushed an DEV update where some things have been fixed. Kit items will no longer be copied into containers.json. Update Command has been fixed because... it was not working correctly. And Tab completion has been added to AssignKitCommand.

You can grab the new version from this link. I recommend you to copy your old containers.json file somewhere, just in case something goes wrong.

Note: The new version should delete all items from chests in your containers.json which are using a kit.

Let me know if that version fix your problems.

robbelouwet commented 5 years ago

Hi,

Sorry for the late response. I downloaded the updated 1.5.0 version, but it didn't delete the items from containers.json...

I started the server, did /cr refill but it still lists all the items in containers.json. I read the changes in the source code, and if I'm correct, this change only applies to newly created chests? Not also to already existing chests?

Aquerr commented 5 years ago

@robbelouwet If the plugin notices that a container (chest) has a kit assigned to it, then it should wipe out entire items section in it. It should work for new containers and for existing ones as well. If it did not then hmmm... Could you somehow send me your chestrefill directory?