Solved Check Empty (List)

Discussion in 'Spigot Plugin Development' started by DeadSilenceIV, Jun 10, 2017.

  1. How can i check if this list is emty?
    List<Integer> list = conf.getIntegerList("KitChest");
    Code (Text):
    KitChest:
      '1':
        ==: org.bukkit.Location
        world: world
        x: -285.0
        y: 69.0
        z: -426.0
        pitch: 0.0
        yaw: 0.0
    I try With list.isEmpty() but it does not work
     
  2. list.size() > 0
    try{
    //Your stuff here
    }catch(Exception e){
    System.out.println("m8 u think u can leave shit empty?");
    }
     
  3. Because in this case the list is not empty
    Also I recommend making a custom location serializerf
     
  4. not sure but I think it would be empty, as that would be a configurationsection not a list, but not sure, as lists start with "-" on each line... but im not sure as I have not experimented with this alot
     
  5. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    KitChests isn't a list. In your case, the path to the first value would be KitChest.1.[location].
    If you want to access objects like that as a list, use PluginConfiguration#getConfigurationSection on "KitChest", then loop through all its keys.
     
  6. And if I wanted to check if it is empty
     
  7. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    Check if the key set is empty.
     
    • Like Like x 1
    • Agree Agree x 1