Solved Getting cordinates from config is messing up..

Discussion in 'Plugin Development' started by PlayFriik, Dec 28, 2014.

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

    PlayFriik

    Basically, I am trying to teleport player(s) to certain location when game starts.. But it doesn't seem to work..
    I have trying to fix this ~1 hour and I am so tired. :/
    Teams system: http://bukkit.org/threads/tutorial-teams-with-names-armor-colors.292535/


    Some things from main class:
    Code:
        public Set<String> mapsSection = this.getConfig().getConfigurationSection("Maps").getKeys(false);
        public List<String> lobbyName1 = new ArrayList<String>();
        public List<String> gameName1 = new ArrayList<String>();
    Getting cords from config....
    Code:
                if (Team.getTeam(player).getName().equals("Green")) {
                    plugin.gameName1.addAll(plugin.mapsSection);
                    String gameName2 = plugin.gameName1.get(1);
                    double X = plugin.getConfig().getInt("Maps." + gameName2 + ".GreenTeam.spawn.X" + 0.5);
                    double Y = plugin.getConfig().getInt("Maps." + gameName2 + ".GreenTeam.spawn.Y");
                    double Z = plugin.getConfig().getInt("Maps." + gameName2 + ".GreenTeam.spawn.Z" + 0.5);
                    World w = Bukkit.getWorld(gameName2);
                    Location loc = new Location(w, X, Y, Z);
                    e.setRespawnLocation(loc);
                }
                if (Team.getTeam(player).getName().equals("Red")) {
                    plugin.gameName1.addAll(plugin.mapsSection);
                    String gameName2 = plugin.gameName1.get(1);
                    double X = plugin.getConfig().getInt("Maps." + gameName2 + ".RedTeam.spawn.X" + 0.5);
                    double Y = plugin.getConfig().getInt("Maps." + gameName2 + ".RedTeam.spawn.Y");
                    double Z = plugin.getConfig().getInt("Maps." + gameName2 + ".RedTeam.spawn.Z" + 0.5);
                    World w = Bukkit.getWorld(gameName2);
                    Location loc = new Location(w, X, Y, Z);
                    e.setRespawnLocation(loc);
                }
    Code:
    # --------------------------------------------------
    start-time: 15
    restart-time: 15
    needed-to-start: 2
    # --------------------------------------------------
    red-team-score: 50
    green-team-score: 50
    build-limit: 90
    # --------------------------------------------------
    Maps:
      Lobby:
        spawn:
          X: 0
          Y: 100
          Z: 0
      World:
        RedTeam:
          spawn:
            X: 10
            Y: 0
            Z: 0
        GreenTeam:
          spawn:
            X: 0
            Y: 100
            Z: 10
    # --------------------------------------------------
    Problem: It doesn't seem to find cord after X, Y or Z.. :/
     
    Last edited: Dec 28, 2014
  2. Offline

    Mysticate

    Please use debug messages to check whether or not there is actually data in your storages.
     
  3. Offline

    PlayFriik

    @Mysticate

    I debugged these cords and all of them was 0, but I have set X: 10, Y:0 and Z: 0.. (As you can see from the config what I posted.
     
  4. Offline

    TGRHavoc

    Have you printed the variable "gameName2" to make sure that it equals "World" (It needs to be exact)

    Also, + 0.5 is adding to the string so the config is trying to find "spawn.X0.5".
     
    PlayFriik likes this.
  5. Offline

    PlayFriik

    @TGRHavoc
    Yep, I have tried the gameName2, and it is World.

    Oh my god, THANKS ALOT! These 0.5 messed up yeah.. :p
     
  6. Offline

    TGRHavoc

    No problem, glad I could help. Don't forget to mark this thread as "Solved" :)
     
Thread Status:
Not open for further replies.

Share This Page