Search in sources :

Example 6 with ConnectionHandler

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();
        }
    }
}
Also used : ConnectionHandler(fr.glowstoner.connectionsapi.network.ConnectionHandler) PacketExecute(fr.glowstoner.fireapi.bigbrother.console.packets.PacketExecute) IOException(java.io.IOException)

Example 7 with ConnectionHandler

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());
    }
}
Also used : ConnectionHandler(fr.glowstoner.connectionsapi.network.ConnectionHandler)

Example 8 with ConnectionHandler

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();
    }
}
Also used : ConnectionHandler(fr.glowstoner.connectionsapi.network.ConnectionHandler) PacketCommand(fr.glowstoner.connectionsapi.network.packets.command.PacketCommand) PacketLogin(fr.glowstoner.connectionsapi.network.packets.login.PacketLogin) Client(fr.glowstoner.connectionsapi.network.client.Client)

Aggregations

ConnectionHandler (fr.glowstoner.connectionsapi.network.ConnectionHandler)8 PacketCommand (fr.glowstoner.connectionsapi.network.packets.command.PacketCommand)5 PacketLogin (fr.glowstoner.connectionsapi.network.packets.login.PacketLogin)5 Client (fr.glowstoner.connectionsapi.network.client.Client)4 PacketVersion (fr.glowstoner.fireapi.bigbrother.console.packets.PacketVersion)4 IOException (java.io.IOException)4 PacketExecute (fr.glowstoner.fireapi.bigbrother.console.packets.PacketExecute)3 ClientListener (fr.glowstoner.connectionsapi.network.events.ClientListener)2 Packet (fr.glowstoner.connectionsapi.network.packets.Packet)2 PacketBigBrotherAC (fr.glowstoner.fireapi.bigbrother.ac.packet.PacketBigBrotherAC)2 BigBrotherConnectionCheck (fr.glowstoner.fireapi.bigbrother.console.check.BigBrotherConnectionCheck)2 BigBrotherLoginGetter (fr.glowstoner.fireapi.bigbrother.console.login.BigBrotherLoginGetter)2 PacketPlayerPing (fr.glowstoner.fireapi.bigbrother.console.packets.ping.PacketPlayerPing)2 PacketFriends (fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends)2 FriendsActionTransmetterGUI (fr.glowstoner.fireapi.bungeecord.friends.packets.action.FriendsActionTransmetterGUI)2 FireChat (fr.glowstoner.fireapi.chat.FireChat)2 FireRank (fr.glowstoner.fireapi.rank.FireRank)2 AdminToolsCmd (be.goldocelot.admintools.AdminToolsCmd)1 EventsAT (be.goldocelot.admintools.EventsAT)1 PacketPing (fr.glowstoner.connectionsapi.network.packets.PacketPing)1