Jump to content

Best Practices - Storing references of World


tomato3017

Recommended Posts

Hey all,

 

I need to store all the worlds that have my environment modifier running. I am using a main static class that stores all the references to each world where it is enabled(it should check this on world tick to see if the world is enabled before continuing).

 

My question is what is the best way to store a reference to a world? I don't want to keep a strong reference to the world object in case the world gets unloaded, or attempts to.

 

Ideas:

  • Store the dimension id and always use the DimensionManager to grab the WorldServer object
  • store the reference to the world in a WeakHashMap, so that the GC will collect it if needed.
  • use a standard reference, aka a HashMap and just hook into WorldLoad and Unload.

 

Opinions?

Edited by tomato3017
Added idea
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.