get all location from config and save it to map

Discussion in 'Spigot Plugin Development' started by marczin, Jul 14, 2018.

  1. Hello,
    I have n location saved in config and i want get them and save into HashMap i never do stuff like that
    Code (YAML):

    PointLoc
    :
          1
    :
               x
    : 0.0
               y
    : 124.0
               z
    : 0
               h
    : 20
           2
    :
              x
    : 1
              y
    : 2
              x
    : 2
              h
    : 40
           3
    :
              x
    : 5
              y
    : 6
              z
    : 7
              h
    : 80

     
    so there is actually 3 position but it will be much more, i want get all value for PointLoc, 1 is and object where x y z is a position and h is for health. and i want save it into hashmap.
    PLZ HELP MEEEEEE :c
     
  2. Benz56

    Junior Mod Supporter

    Get all section keys with:
    Code (Java):
    Config.getConfigurationSection(“PointLoc”).getKeys(false);
    Loop the keys and put the key and the location value into a map.

    Also I think you’re missing a world value for your points unless it is always the same world.
     
    • Like Like x 1
    • Agree Agree x 1
  3. Benz56

    Junior Mod Supporter

    Code (Java):
    double x = getConfig().getDouble(“PointLoc.” + key + “.x);
    The same for the other values.
     
    • Like Like x 1
  4. Thank you so much <3
     

Share This Page