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 ?

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

    Now The Teleport Code

    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);
                            player.teleport(teleportLocation1);
    

    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. Offline

    Adamki11s

    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

    Code:
                            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

    Adamki11s

  5. Offline

    Jason Malouin

    Code:
    [LIST=1]
    [*]       this.getConfig().addDefault("X1", "51");
    [*]           this.getConfig().addDefault("Y1", "70");
    [*]           this.getConfig().addDefault("Z1", "2098");
    [/LIST]
    
    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
  6. Offline

    VG.Developments

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

    Jason Malouin

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

    Code:
               this.getConfig().addDefault("X6", "0.0");
               this.getConfig().addDefault("Y6", "10.0");
               this.getConfig().addDefault("Z6", "0.0");
               this.getConfig().options().copyDefaults(true);
               this.saveConfig();
    
     
  8. Offline

    SuperOriginal

    saveDefaultConfig()
     
  9. Offline

    Jason Malouin

    OMG, I just fixed it...

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

    87pen

    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.
     
  11. Offline

    Jason Malouin

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

    87pen

    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