44 lines
1021 B
Java
44 lines
1021 B
Java
package eu.univento.core.api.server;
|
|
|
|
import eu.univento.core.Core;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.DataOutputStream;
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* sends player to other bungeecord servers
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Servers {
|
|
|
|
|
|
/**
|
|
* sends player to server
|
|
* @param p player
|
|
* @param server name of server
|
|
*/
|
|
public static void connectServer(Player p, String server) {
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
|
DataOutputStream out = new DataOutputStream(b);
|
|
try {
|
|
out.writeUTF("Connect");
|
|
out.writeUTF(server);
|
|
} catch (IOException el) {
|
|
el.printStackTrace();
|
|
}
|
|
p.sendPluginMessage(Core.getInstance(), "BungeeCord", b.toByteArray());
|
|
}
|
|
|
|
/**
|
|
* connects all player to server
|
|
* @param server name of server
|
|
*/
|
|
public static void connectAllToServer(String server) {
|
|
for (Player all : Bukkit.getOnlinePlayers())
|
|
connectServer(all, server);
|
|
}
|
|
} |