Solved How can i get these numbers?

Discussion in 'Plugin Development' started by sohardhun15, Jun 11, 2014.

Thread Status:
Not open for further replies.
  1. I tried like this:
    Code:java
    1. List<String> POS = (List<String>) cfg.getConfigurationSection("Chests");
    2. ArrayList<Integer> ids = new ArrayList<Integer>();
    3. for(String id : POS){
    4.  
    5. int Id = cfg.getInt("Chests." + id);
    6.  
    7. if(!(ids.contains(Id))){
    8. ids.add(Id);
    9. }
    10. }
    11.  
    but i get an error :
    Code:
    Caused by: java.lang.ClassCastException: org.bukkit.configuration.MemorySection cannot be cast to ja
    va.util.List
    Config:
    Code:
    Chests:
      world|556|4|-1734: 2
    
     
  2. do cft.getStringList() instead of cfg.getConfigurationSection(), also the auto complete cats of eclipse cannot be trusted always, as this example clearly says
     
  3. But it isn't a list.
    Code:java
    1. Chests:
    2. world|556|4|-1734: 1
    3. world|556|4|-1731: 2
    4.  
     
  4. If it isn't a list, why do you trying to get it as a list? You cannot get a list of keys as a list, only as a Set<String>.
    You may be looking for the following method: cfg.getConfigurationSection("Chests").getKeys(false)
     
    sohardhun15 likes this.

  5. Oh **** i forget it :D
    Code:java
    1. for (String id : cfg.getConfigurationSection("Chests").getKeys(false)) {
    2.  
    3. }
    It now works :d
     
  6. Offline

    ZodiacTheories

    sohardhun15

    If the problem is solved then please mark the thread as solved
     
Thread Status:
Not open for further replies.

Share This Page