Plugin Dev

Discussion in 'Plugin Development' started by Daniyil, Jun 5, 2020.

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

    Daniyil

    Hello
    I'm just start coding Java and i need help.

    I try to make command /lobby that will teleport you. But it's don't work.

    I have problem that it teleport on coordinates, but not in the world "Lobby". If you know please help!
    Code:
     public String com1 = "lobby";
        @Override
        public boolean onCommand(CommandSender sender,Command cmd,String label,String[] args) {
            if(sender instanceof Player) {
                if(cmd.getName().equalsIgnoreCase(com1)) {
                    if(sender.hasPermission("lobby.use")) {
                        Player p = (Player) sender;
                        sender.sendMessage(ChatColor.BLUE + "You teleported in lobby!");
                        Location loc = p.getLocation();
                        World lobby = loc.getWorld();
                        loc.setWorld(loc.setWorld("Lobby");
                        loc.setX(24.9966);
                        loc.setY(136.0);
                        loc.setZ(-15.0075);
                        loc.setYaw(0);
                        loc.setPitch(0);
                        p.teleport(loc);
                      
                        return true;
                    } else {
                        sender.sendMessage(ChatColor.RED + "You don't have permission to use that command!");
                    }
                }
            } else {
                sender.sendMessage(ChatColor.RED + "Just players can use this command!");
            }
            return false;
        }
     
    Last edited by a moderator: Jun 5, 2020
  2. Offline

    timtower Administrator Administrator Moderator

    @Daniyil
    loc.setWorld(loc.setWorld("Lobby");
    Why do you have a double call?
    And why not do new Location(world,x,y,z) ?
     
Thread Status:
Not open for further replies.

Share This Page