Solved Config Teleporting Issue

Discussion in 'Plugin Development' started by Jason Malouin, Jun 10, 2015.

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

    Jason Malouin

    So I have variables that store Integers to the config to teleport a player to a location. The problem being whenever It teleports. Its not to the number In the config.. Its always to 0 , 0 ,0. Why ?

               this.getConfig().addDefault("X1", "51");
               this.getConfig().addDefault("Y1", "70");
               this.getConfig().addDefault("Z1", "2098");

    Now The Teleport Code

                 int x1 = getConfig().getInt("X1" + 1);
                                int y1 = getConfig().getInt("Y1" + 1);
                                int z1 = getConfig().getInt("Z1" + 1);
                           final Location teleportLocation1 = new Location(player.getWorld(), x1, y1, z1);

    I need this fixed ASAP thanks !

    Pleasee ? Its the last thing to make my Unique plugin complete

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 12, 2016
  2. You have your + 1 inside the search term. So you are searching for an integer with value "X11". You need to change it like so.

    int x1 = getConfig().getInt("X1") + 1;

    And so on.
  3. Offline

    Jason Malouin

                            double x1 = getConfig().getDouble("X1") + 1;
                               double y1 = getConfig().getDouble("Y1") + 1;
                               double z1 = getConfig().getDouble("Z1") + 1;
    Nope. That still Didnt Fix It... all it did was add 1 to my coords making it 1, 1 ,1
  4. Offline

    Jason Malouin

    [*]       this.getConfig().addDefault("X1", "51");
    [*]           this.getConfig().addDefault("Y1", "70");
    [*]           this.getConfig().addDefault("Z1", "2098");
    Should my Coordinates be in quotes ?

    Does anyone else have any ideas. I beleive My setup is correct since it is working for strings

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 12, 2016
  5. Offline


    Instead of addDefeault use the getConfig().set()...
    Also did you saveConfig() after you added the defaults?
  6. Offline

    Jason Malouin

    Why use that and Yes... yes I did.

               this.getConfig().addDefault("X6", "0.0");
               this.getConfig().addDefault("Y6", "10.0");
               this.getConfig().addDefault("Z6", "0.0");
  7. Offline


  8. Offline

    Jason Malouin

    OMG, I just fixed it...

     this.getConfig().addDefault("Z6", + 15);
    VG.Developments likes this.
  9. Offline


    Where you not saving numbers as a String and then trying to retrieve it as a double or int. If you just getConfig().addDefault("Z6", 15); instead of getConfig().addDefault("Z6", "15"); it would work.
  10. Offline

    Jason Malouin

    If you readwhat I saidabove , you would see that Ive come up with this solution
  11. Offline


    I did, but you see other people who encounter the same problem will most likely need an explanation on why this occurred rather than just an "I fixed it."
Thread Status:
Not open for further replies.

Share This Page