configurationsection parameters

Discussion in 'Plugin Development' started by i3ick, Apr 27, 2017.

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

    i3ick

    I need the inside/outside values. I can't figure what I'm doing wrong.

    Code:
    arenas:
      obby:
        joinX: 23.0
        joinY: 91.0
        joinZ: -1.0
        jYaw: 276.28424
        jP: 6.7499113
        spawnX: 49.0
        spawnY: 90.0
        spawnZ: 0.0
        sYaw: 267.28418
        sP: 1.3499091
        minPlayers: 1
        Areas:
          '86283':
            insideX: 65
            insideY: 97
            insideZ: -6
            insideYaw: 58.334045
            insideP: 59.549904
            outsideX: 32.0
            outsideY: 90.0
            outsideZ: 9.0
            outsideYaw: 234.13414
            outsideP: 22.349909
    Worlds:
      World: world
    Settings: {}
    

    Code:
        if(arenaData.getConfigurationSection("arenas." + arenaName + "."+"Areas") == null){
                    plugin.getLogger().info("There are no Areas!");
                    return;
                }
                for(String areaID: arenaData.getConfigurationSection("arenas." + arenaName + "."+"Areas").getKeys(false)){
                    String worldName = arenaData.getString("Worlds." + "World");
                 
    
    
                    String path = "Areas." + areaID + ".";
                    int inX = arenaData.getInt(path + "insideX");
                    int inY = arenaData.getInt(path + "insideY");
                    int inZ = arenaData.getInt(path + "insideZ");
                    float inYaw = (float)arenaData.getDouble(path + "insideYaw");
                    float inP = (float) arenaData.getDouble(path + "insideP");
                    Location startLocation = new Location(world, inX, inY, inZ, inYaw, inP);
    
                    int outX = arenaData.getInt(path + "outsideX");
                    int outY = arenaData.getInt(path + "outsideY");
                    int outZ = arenaData.getInt(path + "outsideZ");
                    float outYaw = (float) arenaData.getDouble(path + "outsideYaw");
                    float outP = (float) arenaData.getDouble(path + "outsideP");
                    Location endLocation = new Location(world, outX, outY, outZ, outYaw, outP);

    But locations are returning nulls.
     
  2. Offline

    Zombie_Striker

    @i3ick
    You may want to rethink what you are doing; You are looping through the keys at "arenas.X.Areas", and then using those values to get the areanas at "Areas.X". Why not just get the keys at "Areas"?

    Also, those values may be null because you do not have an "Areas.86283" path in that config.
     
  3. Offline

    i3ick

    @Zombie_Striker I loop through the areas in case there is more than one area.
    And as you see above, the area is in the config. But I think something is wrong with the path i'm using.
     
  4. Offline

    MrGeneralQ

    for(String areaID: arenaData.getConfigurationSection("arenas." + arenaName + "."+"Areas").getKeys(false)){

    I think you are looping trough everything but not trough all the different areas. So remove the red part and try again.

     
Thread Status:
Not open for further replies.

Share This Page