Solved How to check atLeast in a .yml file?

Discussion in 'Plugin Development' started by jusjus112, Mar 24, 2016.

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

    jusjus112

    Hey guys,

    Im stuck with a very hard thing. At least, for me it is hard ;)

    But, im gonne tell you.
    I have a .yml file. With some Objects, and some other locations and a stringList. I'm trying to loop trough the stringList and check if all the String's in the StringList is null. So, if atLeast 1 location in the config, return true. If all the String's in the conifg, doenst have a location. Return null.
    I dont know how i must do it, i have figure it out for like 3 days, and without result. I hope you guys can help me out ;)

    This, is my code now:
    Code:
        @SuppressWarnings("unchecked")
        public String chooseRandomArena() {   
            //System.out.print(checkAllArenasIfitHasASpawn());
            ArrayList<String> list = (ArrayList<String>) Main.newConfigz.getList("totalArenas");
            for (int i = 0; i < list.size(); i ++) {
                System.out.print(list.size());
                if (Main.newConfigz.contains("arenas." + list.get(i) + ".first")) {
                    System.out.print("arenas." + list.get(i) + ".first");
            if (list.isEmpty()) {
                return null;
            }
                Random r = new Random();
                int s = r.nextInt(list.size());
                //System.out.print(list.get(s));
                if (!Arena.isStarted(list.get(s))&&isArenaLocationSet(1,list.get(s))&&isArenaLocationSet(1, list.get(s))&&isArenaLocationSet(2, list.get(s))&&isArenaLocationSet(3, list.get(s))) {
                    String a = list.get(s);
                    //System.out.print(list.get(s));
                    return a;
                }else {
                    //System.out.print(a);
                    chooseRandomArena();
                }         
            }
            }
            return null;
        }
    The problem is, when it gets a String, it returns null, because the StringLocation is null. That is right, but there is another String in the config thats not null. So, how do i check, if atLeast 1 or more in the config has a location?

    Btw, this is my config, for the people that wanted it ;)
    Saves.YML (open)

    Code:
    arenas:
      jusjus:
        maxPlayers: 2
        isStarted: false
        first:
          World: world
          X: -259.37252752185555
          Y: 70.0
          Z: 313.2091373014552
          Pitch: 8.083455
          Yaw: 2.7444556
        second:
          World: world
          X: -259.28686895126776
          Y: 70.0
          Z: 340.67001821899845
          Pitch: 22.933455
          Yaw: 177.79448
        end:
          World: world
          X: -296.039831207993
          Y: 69.0
          Z: 324.4038723316471
          Pitch: 8.383454
          Yaw: 288.04443
      test:
        maxPlayers: 2
        isStarted: false
    totalArenas:
    - jusjus
    - test
    
     
Thread Status:
Not open for further replies.

Share This Page