Storing config.yml information

Discussion in 'Plugin Development' started by Kees_T, Oct 8, 2017.

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

    Kees_T

    Well, I'm new to Bukkit, started making plugins a few months ago and some doubts have surged. So I was wondering myself how I would store all config.yml information. In some projects, I stored all in HashMaps, like HashMap<String(path), String(information)>,. But its boring to created too much hashmaps for them, If I have 5 different paths, I would need to store them all, excluding the ones with multiples path inside. So, its a good ideia to this to store all data?:

    Code:
        private ConfigurationSection confiG;
    
        confiG = getConfig.getConfigurationSection("Messages");
    
        player.sendMessage(confiG.getString("Msg1"));
    
    I know it isn't a good idea to acess the config all the time, thats why I'm here asking it. I've tested the code above and it worked, but I want to know If doing in this way is a good ideia. Sorry my bad english.
     
  2. Offline

    mine2012craft

    Temporary information like Team Scores, the amount of damage a player takes, and the entity that is following a player is good use for hashmaps. I recommend you store long-term information in the configuration, such as group members (Parties), Total amount of kills and deaths, KDR, Location Coordinates for team spawns, and other stuff is what I recommend you use for configurations.
     
  3. Offline

    Zombie_Striker

    @Kees_T
    Configs are already hashmap values. There is no need to create a second hashmap.

    If you only need to access some information only once or twice, then just access the config whenever you need it. If you need to access it in multiple places, store the information in a field.
     
Thread Status:
Not open for further replies.

Share This Page