Solved Loading Objects Into Array vs Retrieving from Config

Discussion in 'Plugin Development' started by Side8StarLite, Jan 16, 2017.

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

    Side8StarLite

    The title is probably too long...
    Anyways
    Hi there!
    It's a small thing really. I've seen plugins like HolographicDisplays and EasyWarp load their objects from a yml file, and then store it into an array. So whenever someone types in a command, they can just use the information retrieved from the array.
    What I don't understand is, why not retrieve it directly from the config? Why not skip all the trouble of updating the array every restart, reload, and shutdown, and just create a method to convert the yml contents to an object?
    I'm self taught, and I might be missing something important.
    Thank you for any help
     
  2. Offline

    Zombie_Striker

    @Side8StarLite
    Well, you're asking "Why are you loading all the objects from the yml to array when you can do exactly the same thing, but have it also take unnecessary data that no one needs as well." If you're suggesting to not take everything, but only the contents of the yaml, then that is exactly what is done when we load things into an array (which is not really an array, but either a map or arraylist).

    In short, you're either suggesting that they do the same thing they already are doing, or to load extra data that is not needed.
     
  3. Offline

    Side8StarLite

    So when for example, a player types in a command to get their kill stats and etc, it would be more efficient to load the player data beforehand, and just retrieve the data later, if it ever gets used? Why not load the data when the player types in the command instead?
    Sorry I don't fully understand what you're saying
     
  4. Offline

    Zombie_Striker

    @Side8StarLite
    Because loading the data when the player types the command create more operations, increasing the lag on the server. Also, because you do this every time they issue the command, there are more lag spikes more often than the one that happens when no one is even on the server.
     
  5. Offline

    Side8StarLite

    @Zombie_Striker
    Oh alright. I see your point now. Thanks for the clarification.
     
Thread Status:
Not open for further replies.

Share This Page