How to reload my plugin or how to design it in a better way?

Discussion in 'Plugin Development' started by silthus, Nov 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    silthus

    I am having a little bit of trouble figuring out how to cleanly reload my configs in my plugin. The problem is that I use three diffrent static managers that each manage some immutable objects. Almost each object contains a refrence to all the other objects.

    The source is here: http://redmine.raid-craft.de/projects/skills/repository
    And here is an example:

    If you look at the main package (where the three managers are: PlayerManager, LevelManager and SkillManager).

    The PlayerManager holds refrences to the RCPlayer Object (represents the player on the server).
    The RCPlayer Object holds refrences to loaded RCSkill Objects the player bought(loaded from skills.yml) and single refrences to a RCPath, RCLevel and RCRank Object.
    RCSkill Objects hold no refrence in them but are managed by the SkillManager.
    The SkillManager holds all loaded RCSkill Objects.
    Leaving the LevelManager that holds refrences to all loaded RCPath, RCLevel and RCRank objects. They are all immutable.
    The RCPath Object holds refrence to all RCLevel objects that are within this path (defined in the paths.yml config).

    Now my question is or I should say my questions are:

    Is there any way I can design this in a better way so that it is easier to update all the refrences between the objects.

    How should I go on reloading the config for this? If I null the HashMaps there will be NPE all over the place because of dead refrences in the RCPlayer and RCPath object. If I simply call the same method as I did on server startup it overwrites some objects and there are some NPEs and the objects removed from config.

    Any ideas on this?

    Thanks in advance!
     
  2. Offline

    ItsHarry

    Eh.. I didn't have a clear look at the source code, but maybe you could make new instances?

    HashMap hashMap = new HashMap();

    //Reload configs.
    hashMap = new HashMap();
     
  3. Offline

    silthus

    That's what jumped to my mind too, the first time I looked at it, but this will cause a huge memory leak and also mess up all the RCPlayer refrences of the players that are online or cached.
     
Thread Status:
Not open for further replies.

Share This Page