NullReferenceException at UnloadFixed

I get this Errormessage from Oxide:

what does it mean?

(14:06:33) | Failed to call hook 'Unload' on plugin 'Backpacks v3.4.0' (NullReferenceException: Object reference not set to an instance of an object)at Oxide.Plugins.Backpacks.Unload () [0x00000] in <2bc1a2427fec4c1093784232d8ed6ce7>:0
at Oxide.Plugins.Backpacks.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x0005b] in <2bc1a2427fec4c1093784232d8ed6ce7>:0at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <80b90e8213db44b29ec2d4111764172c>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <ec05e0208c9149bba43236ca58fea105>:0at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <ec05e0208c9149bba43236ca58fea105>:0(14:06:33) | Unloaded plugin Backpacks v3.4.0 by LaserHydra(14:06:33) | Loaded plugin Backpacks v3.4.0 by LaserHydra

For reference, here is the code of the Unload() method where the error is being thrown.

private void Unload()
{
    _storedData.Save();

    foreach (var backpack in _backpacks.Values)
    {
        backpack.ForceCloseAllLooters();
        backpack.SaveData();
        backpack.KillContainer();
    }

    foreach (var player in BasePlayer.activePlayerList)
        DestroyGUI(player);
}​

The only possible places for a NullReferenceException would be _storedData.save() or backpack.*.

Possibility #1:_storedData is null

This code was introduced in the latest version, so I wonder if that could be it. This is possible for one of the following reasons.
  1. The plugin was unloaded before it loaded, which seems pretty unlikely. This could happen if you have another plugin unloading Backpacks on server boot for example. If that's the case, then the error probably isn't causing any problem, but we can fix the plugin to not throw this error.
  2. Oxide's Interface.Oxide.DataFileSystem.ReadObject<StoredData>() call returned null, which shouldn't be possible afaik.

To help test this hypothesis, please remove this line of code from the plugin and let me know if the issue persists. This should be safe to do. The only consequence is that players running the /backpackgui command won't have their preference saved so they will have to rerun it after the next time the plugin is reloaded.

Possibility #2: One of the backpack objects is null

This code isn't new, and an investigation of all the plugin code suggests this shouldn't be possible. However, another user was having a similar issue where the only explanation we could come up with was that one of the backpack objects must have been null.

https://umod.org/community/backpacks/30897-backpack-plugin-not-working-after-installing-plugin-entity-owner

We're still trying to figure out that issue, but the only hypothesis we have to explailn why a backpack could be null is because the DataFileSystem.ReadObject method returned null, same as with possibility #1.

I found the Problem, in the Data Folder of Oxide i found the Backpacksdata. In this data was written nullnullnullnullnull and so on. I delete this data and reload the plugin, the plugin has create the datafile new and the errormessage is no more. Thank you for helping me. ^^

Which data file was like that?

data/backpacks.json?

data/backpacks/[steamid].json?

Some more questions to help me understand what caused this.

  1. Did you recently install or update the plugin?
  2. How long have you been using the Backpacks plugin?
  3. Did you recently install or update another plugin?
  4. Did your server recently experience any crashes?

It was the Backpacks.json file which is found in oxide/data.
it was not with a steamid.
I have not reinstalled the plugin lately, only updated it as soon as an update was available.
I always check if an update for a plugin is available and update all plugins as soon as an update is available.
I use the plugin for 2 years
I installed 4 plugins yesterday, however these plugins had been installed before until I uninstalled them for a long time because they were not needed.
The only server crash was with the Rustupdate with the technology trees in the workbenches, but after minor updates from the developers, I haven't noticed any crashes anymore

I hope I could help you

Thanks for all these answers. This helps.

So it sounds like you updated the plugin over 2 weeks ago and had no issues until yesterday.

  1. Which plugins did you install yesterday?
  2. Was that before or after you encountered the error?
  3. Do you have the backpacks GUI button enabled? If so, for how long?

no, the problem has been there for a while, but I haven't found the time to take care of this bug until now.

I installed Viking Boats, Raft, SCatatpult and SBallista

The installation was done after the error occurred, so these 4 plugins were not to blame for the occurrence of the error.

Sorry but I don't understand the last question directly.
I myself bound the backpack.open command to a key and also explained and showed my players how to do that, because that way when needed we only need to exercise that keystroke and the backpack opens. In the settings I have set that everyone has the same size, the largest size that the plugin allows.

Merged post

and every month after the developer's update is released I delete the map's save files and sometimes create a new procedural map, I also delete all the backpack files that are in the folder with the steamids so that no player can illicitly take items and resources to the new map and immediately build a huge base. That all players have the same start. I know that you can set it with the backpack plugin that this happens automatically, but I want to do this myself to have better control over the files.

This error should no longer be possible as of Backpacks v3.5.0.

Locked automatically