BungeeCord send a player to a other server

Discussion in 'Plugin Development' started by PlayWolfYT, Feb 7, 2019.

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

    PlayWolfYT

    So basically I want to send a player to a server via a command ("/send player server"). The command itself works totally fine, exept when you want to send a player to a server with onlinemode=true.

    So I want to check in the command if the server is in onlinemode true or false...
    Here's my current command:

    Code:
    package de.wolfarmy.network.commands;
    
    import de.wolfarmy.network.Main;
    import net.md_5.bungee.api.CommandSender;
    import net.md_5.bungee.api.ProxyServer;
    import net.md_5.bungee.api.chat.TextComponent;
    import net.md_5.bungee.api.config.ServerInfo;
    import net.md_5.bungee.api.connection.ProxiedPlayer;
    import net.md_5.bungee.api.plugin.Command;
    
    public class SendCMD extends Command {
        public SendCMD(String name) {
            super(name);
        }
    
        @Override
        public void execute(CommandSender commandSender, String[] args) {
            if (commandSender.hasPermission("wolfarmy.send") || commandSender.hasPermission("wolfarmy.*")) {
                if (args.length == 2) {
                    ProxiedPlayer player = ProxyServer.getInstance().getPlayer(args[0]);
                    if (player != null) {
                        ServerInfo server = ProxyServer.getInstance().getServerInfo(args[1]);
                        if (server != null) {
                                player.connect(server);
                                commandSender.sendMessage(new TextComponent(Main.PREFIX + "§a" + player.getName() + " §7was moved to §a" + server.getName() + " §8."));
                        } else {
                            commandSender.sendMessage(new TextComponent(Main.PREFIX + "§c" + args[1] + " §7isn't a valid server§8. (/serverlist)"));
                        }
                    } else {
                        commandSender.sendMessage(new TextComponent(Main.PREFIX + "§c" + args[0] + " §7isn't online§8."));
                    }
                } else {
                    commandSender.sendMessage(new TextComponent(Main.PREFIX + "§7Please use /§asend <Player> <Server>§8."));
                }
            } else {
                commandSender.sendMessage(Main.NO_PERMISSIONS);
            }
        }
    }
    
     
  2. Offline

    timtower Ninja on the waves Moderator

    Locked
    Bungeecord requires offline mode.
    Offline mode is not supported by Bukkit
     
Thread Status:
Not open for further replies.

Share This Page