Getting the world's name from a config..

Discussion in 'Plugin Development' started by EdenCampo, Oct 13, 2011.

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

    EdenCampo

    Hello,
    I'm trying to get a boolean from the configuration I made for worlds,like
    if in the file there is something like this:
    Code:
    MyWorld: false
    MyWorld_nether: false
    MyCreativeWorld: true
    
    It will set MyWorld and MyWorld_nether to survival,and MyCreativeWorld to creative.
    Here I made a loop that gets all the worlds in the server:
    Code:
    if (!world.exists()) {
                this.logMessage("Creating a Worlds file");
                try {
                    for(World w: this.getServer().getWorlds()){
                        String gw = w.getName();
                        Worlds.setProperty(gw, false);
                        Worlds.save();
                    }
                    world.createNewFile();
                    Worlds.setHeader("#False meens survival mode,True meens creative mode.");
                    Worlds.save();
                    this.logMessage("Worlds file created successfuly!");
    
                } catch (IOException ex) {
    
                    this.logMessage("Error while creating the worlds file!");
        }
            }
        }
    
    Here we see the String gw that gets the world's name,when I try to put this same string in my listener I get a error.
    My part of the Listener:
    Code:
    if(from.getWorld()!=to.getWorld()){
                if(plugin.Worlds.getBoolean(world.getName()).equals(true) ){
                player.setGameMode(GameMode.CREATIVE);
                plugin.hs.put(name, true);
                return;
                }
    
    But this gave me an error,any ideas ?
     
  2. Offline

    wwsean08

    Code:
    if(from.getWorld()!=to.getWorld()){
        if(plugin.Worlds.getBoolean(world.getName())){
             player.setGameMode(GameMode.CREATIVE);
             plugin.hs.put(name, true);
             return;
        }
    }
    
    There is no need to do the .equals(true), as it will only enter what is in the if statement if the yml returns that it is true

    If that doesn't fix your problem, could you please post the error.
     
  3. Offline

    EdenCampo

    @wwsean08
    Error:
    world can not be resolved.
     
  4. Offline

    wwsean08

    ok, so do you want that to be the to world or from world, or what? Just change it accordingly, is world a variable, if so what does it represent?
     
Thread Status:
Not open for further replies.

Share This Page