use of fr.glowstoner.connectionsapi.network.ConnectionHandler in project FireAPI by FireBlade-Serv.
the class ExecuteCommand method execute.
@Override
public void execute(ConnectionHandler c, String command, String[] args) {
if (args.length == 0) {
c.sendMessageWithPrefix("Usage : /execute <spigot/bungeecord> cmd");
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("spigot")) {
c.sendMessageWithPrefix("Usage : /execute spigot cmd");
} else if (args[0].equalsIgnoreCase("bungeecord")) {
c.sendMessageWithPrefix("Usage : /execute bungeecord cmd");
} else {
c.sendMessageWithPrefix("Usage : /execute <spigot/bungeecord> cmd");
}
} else {
StringBuilder builder = new StringBuilder();
for (String arg : args) {
if (!arg.equals(args[0])) {
if (arg.equals(args[(args.length - 1)])) {
builder.append(arg);
} else {
builder.append(arg + " ");
}
}
}
try {
if (args[0].equalsIgnoreCase("spigot")) {
for (ConnectionHandler ch : this.gl.getServersConnections().get(VersionType.SPIGOT_VERSION)) {
c.sendMessageWithPrefix("Vous avez bien envoyé votre commande à " + ch.getName());
ch.sendPacket(new PacketExecute(builder.toString()));
}
} else if (args[0].equalsIgnoreCase("bungeecord")) {
for (ConnectionHandler ch : this.gl.getServersConnections().get(VersionType.BUNGEECORD_VERSION)) {
c.sendMessageWithPrefix("Vous avez bien envoyé votre commande à " + ch.getName());
ch.sendPacket(new PacketExecute(builder.toString()));
}
} else {
c.sendMessageWithPrefix("Usage : /execute <spigot/bungeecord> cmd");
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
use of fr.glowstoner.connectionsapi.network.ConnectionHandler in project FireAPI by FireBlade-Serv.
the class ListCommand method execute.
@Override
public void execute(ConnectionHandler c, String command, String[] args) {
c.sendMessageWithPrefix("Liste des connections :");
for (ConnectionHandler ch : this.gl.getConnected()) {
String name = (ch.getName().equals("default-name")) ? ch.getIP() : ch.getName();
c.sendMessageWithPrefix("- " + name + ", IP = " + ch.getIP());
}
}
use of fr.glowstoner.connectionsapi.network.ConnectionHandler in project FireAPI by FireBlade-Serv.
the class BigBrotherClient method connect.
public void connect() {
try {
Client c = new Client("62.4.31.183", 2566);
c.start();
ConnectionHandler ch = c;
while (true) {
@SuppressWarnings("deprecation") String line = this.in.readLine();
if (line.equalsIgnoreCase("stop")) {
break;
}
if (!this.logged) {
// login *key-pass
if (line.startsWith("login")) {
String sub = line.substring(6);
String[] args = sub.split("-");
String pass = null, key = null;
for (String arg : args) {
if (arg.startsWith("*")) {
key = arg.substring(1);
} else {
pass = arg;
}
}
ch.sendPacket(new PacketLogin(key, pass));
System.out.println("Envoi d'un login avec KEY=" + key + ", PASS=" + pass);
} else {
ch.sendPacket(new PacketCommand(line));
}
}
}
c.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations