Solved Custom config saves wont work until reload

Discussion in 'Spigot Plugin Development' started by Videosambo, Oct 21, 2018.

Thread Status:
Not open for further replies.
  1. So my plugin stores coordinates to custom config file and then saves it. I can see coordinates right after save so it saves, there is no problem. But when I try to use for loop to search string from it, it wont work
    Code (Text):

    for (String portal : portals) {
                if (portalcoords.equals(portal)) {
                    int px = p.getLocation().getBlockX();
                    int py = p.getLocation().getBlockY();
                    int pz = p.getLocation().getBlockZ();
                    p.teleport(Bukkit.getWorld(plugin.getConfig().getString("destworld")).getBlockAt(px - 1, py - 1, pz).getLocation());
                    return;
                }
            }
     
    So, when I my plugin saves coords, it look like this :
    Code (Text):

    portals:
    - 39_83_-35__42_87_-35
     
    And my portal detect code shows same coords so It can find portal coords that should match but that for loop look like it wont find it before reload. What would help?
     
  2. Did you save the config after setting the values?
     
  3. How are you adding the string list in the configuration file to the ArrayList?
     
  4. Yes
     
  5. In the class where I save coords, I use ArrayList but in the class where the loop is, I use normal List, should I use ArrayList instead and how because I tried that first before normal List and it didn't work.
     
  6. ArrayList#addAll()
     
  7. Oh I found the problem, I defined the List from config outside PlayerMovementEvent so it wont update until reload
     
Thread Status:
Not open for further replies.