Solved Getting a string in a config

Discussion in 'Plugin Development' started by legostarwarszach, Jun 9, 2013.

Thread Status:
Not open for further replies.
  1. How would I fix this?
    Code:
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent inter){
            Player p = inter.getPlayer();
            if(p.hasPermission(new Permissions().joingame)){
                if(inter.getAction() == Action.RIGHT_CLICK_BLOCK) {
                      if(inter.getClickedBlock().getType() == Material.SIGN || inter.getClickedBlock().getType() == Material.SIGN_POST || inter.getClickedBlock().getType() == Material.WALL_SIGN) {
                          Sign sign = (Sign) inter.getClickedBlock().getState();
                            if(sign.getLine(0).contains(plugin.getConfig().getString(sign.getLine(0)))) {
                            //    Location locatmin = plugin.getConfig().getString(sign.getLine(3) + "min");
                                Location locat = plugin.getConfig().getString((sign.getLine(3) + "min");)
                                p.teleport(arg0)
                      }
                   
                }
     
            }
        }
    It says: Syntax error on token(s), misplaced construct(s)
    Please help.

    Thanks,
    Zach
     
  2. Offline

    Rockon999

    Code:
    );)
    ^^^That doesn't look right :|
     
  3. Offline

    kreashenz

  4. kreashenz
    If a player clicks on a sign and they have the right permission, they will teleport to a location found in the config.yml
     
  5. Offline

    sebasju1234

    Can I see your YML File?
     
  6. Offline

    kreashenz

    legostarwarszach You shouldn't be getting strings for locations... It should be int/doubles and strings only for the world name.
     
  7. Offline

    Th3Br1x

    Code:
    Location locat = new Location(String world, double x, double y, double z);
    Thats the way, how you create a new Location.

    Saving it into the config:
    Code:
    plugin.getConfig().set("Your.path", locat);
    Getting the location from the config:
    Code:
    Location newLocationFromConfig = plugin.getConfig().get("Your.path");
     
  8. Offline

    Rockon999

    Yes...
    Code:
     @EventHandler
            public void onPlayerInteract(PlayerInteractEvent inter){
                Player p = inter.getPlayer();
                if(p.hasPermission(new Permissions().joingame)){
                    if(inter.getAction() == Action.RIGHT_CLICK_BLOCK) {
                          if(inter.getClickedBlock().getType() == Material.SIGN || inter.getClickedBlock().getType() == Material.SIGN_POST || inter.getClickedBlock().getType() == Material.WALL_SIGN) {
                              Sign sign = (Sign) inter.getClickedBlock().getState();
                                if(sign.getLine(0).contains(plugin.getConfig().getString(sign.getLine(0)))) {
                                //    Location locatmin = plugin.getConfig().getString(sign.getLine(3) + "min");
                                    Double x = plugin.getConfig().getDouble((sign.getLine(3) + ".x"));
                                    Double y = plugin.getConfig().getDouble((sign.getLine(3) + ".y"));
                                    Double z = plugin.getConfig().getDouble((sign.getLine(3) + ".z"));
                                    String worldname = plugin.getConfig().getString((sign.getLine(3) + ".world"));
                                    World world = Bukkit.getWorld(worldname);
                                    Location loc = new Location(world, x, y, z);
                                    p.teleport(loc);
                          }
                   
                    }
     
                }
            }
    
    This will work, if you have it save x, y, z, and the world name to the Key "sign.getLine(3)"
     
    legostarwarszach likes this.
  9. Can you give me an example?

    O thx Rockon999
     
  10. Offline

    kreashenz

Thread Status:
Not open for further replies.

Share This Page