use of fr.glowstoner.connectionsapi.network.client.Client in project FireAPI by FireBlade-Serv.
the class BungeeMain method onEnable.
@Override
public void onEnable() {
super.getLogger().info("FireAPI actif !");
this.sql.connection();
this.sql.startSqlRefreshScheduler(1800L);
this.sql.putConsole();
this.rank = new FireRank(this.sql);
super.getProxy().registerChannel("fireapi");
this.log = new BigBrotherLoginGetter();
try {
this.log.load();
} catch (Exception e1) {
e1.printStackTrace();
}
try {
ConnectionsAPI.init();
Client c = new Client("62.4.31.183", 2566);
c.start();
this.c = c;
ConnectionHandler ch = c;
ch.eval();
ch.sendPacket(new PacketLogin(this.log.getKey(), log.getPassword()));
ch.sendPacket(new PacketVersion(VersionType.BUNGEECORD_VERSION));
ch.sendPacket(new PacketCommand("name main-bungeecord"));
BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.GLOBAL_CHECK, BigBrotherConnectionInfos.builder().id("main-bungeecord").key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.BUNGEECORD_VERSION).build());
check.startChecks();
this.setChecker(check);
} catch (Exception ex) {
BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.ERROR_CHECK, BigBrotherConnectionInfos.builder().id("main-bungeecord").key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.BUNGEECORD_VERSION).build());
check.startChecks();
}
ConnectionsAPI.getListeners().registerClientListener(new ClientListener() {
@Override
public void onPacketReceive(Packet packet) {
if (packet instanceof PacketExecute) {
BungeeMain.super.getLogger().info("(BigBrother) Execution de la commande : " + ((PacketExecute) packet).getServerCommand() + ".");
BungeeMain.super.getProxy().getPluginManager().dispatchCommand(BungeeMain.super.getProxy().getConsole(), ((PacketExecute) packet).getServerCommand());
} else if (packet instanceof PacketPlayerPing) {
PacketPlayerPing pp = (PacketPlayerPing) packet;
BungeeMain.super.getProxy().getPlayer(pp.getName()).sendMessage(new TextComponent("§6[§ePing§6]§r Ton ping §eproxy§r est de §e" + BungeeMain.super.getProxy().getPlayer(pp.getName()).getPing() + " ms§r !"));
} else if (packet instanceof PacketBigBrotherAC) {
PacketBigBrotherAC gacp = (PacketBigBrotherAC) packet;
if (gacp.getType().equals(BigBrotherTypeAC.CHEAT_DETECTION)) {
if (gacp.getTODO().equals(BigBrotherActionAC.INFORM_STAFF)) {
for (ProxiedPlayer ps : getProxy().getPlayers()) {
if (api.getRankSystem().hasRankAndSup(ps.getName(), Rank.ASSISTANT)) {
ps.sendMessage(new TextComponent("§c[BigBrother] [Cheat] §4" + gacp.getPlayerName() + " §r~ " + gacp.getMessage() + " §c" + gacp.getPing() + "ms"));
}
}
}
}
}
}
});
this.friends = new FireFriends(this);
this.friends.initFolder();
try {
this.friends.loadConfiguration();
} catch (IOException e) {
e.printStackTrace();
}
this.auth = new FireAuth(this);
try {
this.auth.loadConfiguration();
} catch (IOException e) {
e.printStackTrace();
}
this.chat = new FireChat(this);
this.wl = new FireWL(this);
this.wl.loadConfiguration();
super.getLogger().info("Clé de sécurité utilisée : " + this.auth.getSecurityKey());
PluginManager man = super.getProxy().getPluginManager();
man.registerCommand(this, new CoinsCheckerCommand(this, "coins"));
man.registerCommand(this, new Website("site"));
man.registerCommand(this, new Discord("discord"));
man.registerCommand(this, new FriendsCommand(this, "amis"));
man.registerCommand(this, new FireRankCommand(this, "firerank"));
man.registerCommand(this, new RegisterCommand(this, "register"));
man.registerCommand(this, new LoginCommand(this, "login"));
man.registerCommand(this, new FireWhiteListCommand("firewl", this));
StaffChatCommand scc = new StaffChatCommand(this, "firestaffchat");
man.registerCommand(this, scc);
Events events = new Events(this, scc);
man.registerListener(this, events);
this.check.registerListener(events);
api = this;
}
use of fr.glowstoner.connectionsapi.network.client.Client in project FireAPI by FireBlade-Serv.
the class BukkitMain method onEnable.
@Override
public void onEnable() {
super.getLogger().info("FireAPI actif !");
sql = new FireSQL();
this.sql.connection();
this.sql.startSqlRefreshScheduler(1800L);
this.sql.putConsole();
rank = new FireRank(this.sql);
this.chat = new FireChat(this);
this.tag = new FireTag(this);
this.tag.registerRanks();
FireBukkitID id = new FireBukkitID(this);
try {
id.loadConfiguration();
} catch (IOException | InvalidConfigurationException e1) {
e1.printStackTrace();
}
this.id = id.getID();
this.log = new BigBrotherLoginGetter();
try {
this.log.load();
} catch (Exception e1) {
e1.printStackTrace();
}
super.getLogger().info("ID serveur utilisé : " + this.id);
this.injector = new FireInjector();
this.ac = new BigBrotherAC(this);
this.ac.init();
this.ac.startKillAuraChecks((long) (30 * 20));
try {
ConnectionsAPI.init();
Client c = new Client("62.4.31.183", 2566);
c.start();
this.c = c;
ConnectionHandler ch = c;
ch.eval();
ch.sendPacket(new PacketLogin(this.log.getKey(), this.log.getPassword()));
ch.sendPacket(new PacketVersion(VersionType.SPIGOT_VERSION));
ch.sendPacket(new PacketCommand("name " + this.id));
BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.GLOBAL_CHECK, BigBrotherConnectionInfos.builder().id(this.id).key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.SPIGOT_VERSION).build());
check.startChecks();
this.setChecker(check);
} catch (Exception ex) {
BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.ERROR_CHECK, BigBrotherConnectionInfos.builder().id(this.id).key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.SPIGOT_VERSION).build());
check.startChecks();
}
ConnectionsAPI.getListeners().registerClientListener(new ClientListener() {
@Override
public void onPacketReceive(Packet packet) {
if (packet instanceof PacketExecute) {
BukkitMain.super.getServer().dispatchCommand(BukkitMain.super.getServer().getConsoleSender(), ((PacketExecute) packet).getServerCommand());
} else if (packet instanceof PacketFriends) {
PacketFriends pf = (PacketFriends) packet;
if (pf.getAction() instanceof FriendsActionTransmetterGUI) {
FriendsActionTransmetterGUI fa = (FriendsActionTransmetterGUI) pf.getAction();
if (fa.to().equals(VersionType.SPIGOT_VERSION)) {
FriendsActionInventoryGUI faig = new FriendsActionInventoryGUI(fa.getName(), fa.getFriends(), fa.getConnected());
faig.initPlayer(BukkitMain.this);
faig.generateInventory();
faig.openInventory();
}
}
}
}
});
Events events = new Events(this);
super.getServer().getPluginManager().registerEvents(events, this);
super.getServer().getPluginManager().registerEvents(new EventsAT(this), this);
this.check.registerListener(events);
super.getCommand("ping").setExecutor(new PingCommand(this));
super.getCommand("at").setExecutor(new AdminToolsCmd(this));
api = this;
}
use of fr.glowstoner.connectionsapi.network.client.Client in project FireAPI by FireBlade-Serv.
the class BigBrotherConnectionCheck method connectionCheck.
public void connectionCheck() throws BigBrotherNotConnectedException {
try {
System.out.println("[FireAPI] Reconnection avec IP=" + this.client.getIP() + " et PORT=" + this.client.getPort());
this.client = new Client(this.client.getIP(), this.client.getPort());
this.client.start();
ConnectionHandler ch = (ConnectionHandler) this.client;
ch.sendPacket(new PacketLogin(this.infos.getKey(), this.infos.getPassword()));
ch.sendPacket(new PacketVersion(this.infos.getVersionType()));
ch.sendPacket(new PacketCommand("name " + this.infos.getId()));
this.api.setClient((Client) ch);
this.api.setChecker(this);
this.callListener(ch);
} catch (Exception ex) {
throw new BigBrotherNotConnectedException("Erreur sur l'envoi d'un packet (connection protocol) " + "ErreurClass = " + ex.getClass().getSimpleName() + ", " + ex.getMessage());
}
}
use of fr.glowstoner.connectionsapi.network.client.Client 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