Solved Location Teleports Player Into Void

Discussion in 'Plugin Development' started by BrickBoy55, Dec 17, 2014.

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

    BrickBoy55

    I'm defining a location in my configuration, but it always teleports the player into the void no matter what the Y coordinate is.

    My Class:
    Code:
    Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("skullhunter")) {
                if (args[0].equalsIgnoreCase("join")) {
                    World world = getServer().getWorld(getConfig().getString("arena.world").toString());
                    double x = getConfig().getDouble("arena.x");
                    double y = getConfig().getDouble("arena.y");
                    double z = getConfig().getDouble("arena.z");
                    if (x == 0 && y == 0 && z == 0) {
                        player.sendMessage(prefix + "The join location wasn't set! Contact an admin.");
                    } else {
                        Bukkit.broadcastMessage(prefix + player.getName() + " has joined the match!");
                        Location join = new Location(world, y, z, x);
                        player.teleport(join);
                        player.getInventory().clear();
                        player.openInventory(loadout);
                    }
                }
              
                else if (args[0].equalsIgnoreCase("setarena") && player.hasPermission("skullhunter.admin")) {
                    World world = player.getLocation().getWorld(); getConfig().set("arena.world", world.getName().toString());
                    double x = player.getLocation().getX();
                    getConfig().set("arena.x", x);
                    double y = player.getLocation().getY();
                    getConfig().set("arena.y", y);
                    double z = player.getLocation().getZ();
                    getConfig().set("arena.z", z);
                    saveConfig();
                    reloadConfig();
                    player.sendMessage(prefix + "Arena location set!");
                }
    
    My Config:
    Code:
    arena:
      world: world
      x: -10.863327368403063
      y: 79.0
      z: -33.546043608209075
    
     
  2. Offline

    Rocoty

    You've got the Location constructor wrong. Argument list is (world, x, y, z), not (world, y, z, x)
     
  3. Offline

    BrickBoy55

    You don't know how stupid I feel right now.

    Actually, it still isn't working... it still teleports me into the void.

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

    Rocoty

    Post your new code?
     
  5. Offline

    BrickBoy55

    Code:
    Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("skullhunter")) {
                if (args[0].equalsIgnoreCase("join")) {
                    World world = getServer().getWorld(getConfig().getString("arena.world").toString());
                    double x = getConfig().getDouble("arena.x");
                    double y = getConfig().getDouble("arena.y");
                    double z = getConfig().getDouble("arena.z");
                    if (x == 0 && y == 0 && z == 0) {
                        player.sendMessage(prefix + "The join location wasn't set! Contact an admin.");
                    } else {
                        Bukkit.broadcastMessage(prefix + player.getName() + " has joined the match!");
                        Location join = new Location(world, x, y, z);
                        player.teleport(join);
                        player.getInventory().clear();
                        player.openInventory(loadout);
                    }
                }
               
                else if (args[0].equalsIgnoreCase("setarena") && player.hasPermission("skullhunter.admin")) {
                    World world = player.getLocation().getWorld(); getConfig().set("arena.world", world.getName().toString());
                    double x = player.getLocation().getX(); getConfig().set("arena.x", x);
                    double y = player.getLocation().getY(); getConfig().set("arena.y", y);
                    double z = player.getLocation().getZ(); getConfig().set("arena.z", z);
                    saveConfig();
                    reloadConfig();
                    player.sendMessage(prefix + "Arena location set!");
                }
    
    Now in certain areas it is still teleporting me into the void, but in other areas it teleports me 30 blocks up.

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

    Rocoty

    @BrickBoy55 Have you tried making the plugin print out the different coordinates? Are you also making sure that the y value stays at a feasible value?
     
  7. Offline

    Webbeh

    getString().toString() ?

    This won't help your 30-blocks-up-or-teleporting-to-void issue but is clearly redundant.
     
    Skionz likes this.
  8. Offline

    BrickBoy55

    I added a message to tell me the coords but it isn't even sending me the message.

    I don't even know what I was thinking about the getString().toString();

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

    Rocoty

    Again...can't help you unless you post the code.
     
  10. Offline

    BrickBoy55

    Code:
    Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("skullhunter")) {
                if (args[0].equalsIgnoreCase("join")) {
                    World world = getServer().getWorld(getConfig().getString("arena.world"));
                    double x = getConfig().getDouble("arena.x");
                    double y = getConfig().getDouble("arena.y");
                    double z = getConfig().getDouble("arena.z");
                    if (x == 0 && y == 0 && z == 0) {
                        player.sendMessage(prefix + "The join location wasn't set! Contact an admin.");
                    } else {
                        player.sendMessage("World" + world + " X: " + x  + " Y: "+ y + " Z: "+ z);
                        Bukkit.broadcastMessage(prefix + player.getName() + " has joined the match!");
                        Location join = new Location(world, x, y, z);
                        player.teleport(join);
                        player.getInventory().clear();
                        player.openInventory(loadout);
                    }
                }
               
                else if (args[0].equalsIgnoreCase("setarena") && player.hasPermission("skullhunter.admin")) {
                    World world = player.getLocation().getWorld(); getConfig().set("arena.world", world.getName());
                    double x = player.getLocation().getX(); getConfig().set("arena.x", x);
                    double y = player.getLocation().getY(); getConfig().set("arena.y", y);
                    double z = player.getLocation().getZ(); getConfig().set("arena.z", z);
                    player.sendMessage("World" + world + " X: " + x  + " Y: "+ y + " Z: "+ z);
                    saveConfig();
                    reloadConfig();
                    player.sendMessage(prefix + "Arena location set!");
                }
    
    Also could it have anything to do with wherever I put the config.yml and plugin.yml it always says Jar Export Failed. (in eclipse)
     
  11. Offline

    Rocoty

    Oh...you tried to run a jar that didn't properly export and wonder why you had troubles?

    Can you elaborate on the error message please?
     
  12. Offline

    Webbeh

    If the jar export has failed, it means it didn't get generated, and the .jar that is present in your output folder is simply the last one who hasn't failed to generate, for example the one that existed before you added the sendMessage ;)
     
  13. Offline

    BrickBoy55

    Okay, now I feel stupid. Let me try this. If it works I'll tell you why. :p

    Okay thanks everyone. It worked.

    The reason I felt stupid is because it was open in a different program. For some reason I opened the jar with 7-zip.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2016
Thread Status:
Not open for further replies.

Share This Page