Solved Saving Sign Locations

Discussion in 'Plugin Development' started by SeniorCluckers, Jul 22, 2016.

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

    SeniorCluckers

    Hi everyone,
    So what I'm doing is looping through every sign that contains the word "Test", but how do I make it so it saves the location of all the signs with the word "Test", without overwriting the sign location with another sign location. I have tested the code below, but I'm stuck on the saving more than one sign.

    Code:
            World world = Bukkit.getServer().getWorlds().get(0);
            for (Chunk chunk : world.getLoadedChunks()) {
                for (BlockState blockState : chunk.getTileEntities()) {
                    if (blockState instanceof Sign) {
                        Sign sign = (Sign) blockState;
                      
                        if (sign.getLine(0).equalsIgnoreCase("Test")) {
                          
                            Main.getInstance().getConfig().set("Sign.x.", + sign.getLocation().getBlockX());
                            Main.getInstance().saveConfig();
                        }
                    }
                }
            }
    
        }
     
    Last edited: Jul 22, 2016
  2. Offline

    Zombie_Striker

    @SeniorCluckers
    There are two ways of doing it:
    1. Don't save an individual location to the config, but a list of locations.
    2. Every time a sign is added to the config, change the path somehow. An easy way of doing this would be to add a subpath that requires an int, and increase that integer every time a location is saved. (E.g. "path.to.place."+int )
     
  3. Offline

    SeniorCluckers

Thread Status:
Not open for further replies.

Share This Page