use of fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends 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.fireapi.bungeecord.friends.packets.PacketFriends in project FireAPI by FireBlade-Serv.
the class BigBrotherListener method onPacketReceive.
@Override
public void onPacketReceive(Packet packet) {
try {
ConnectionHandler server = packet.getConnection();
String name = (server.getName().equals("default-name")) ? server.getIP() : server.getName();
if (!(packet instanceof PacketPing)) {
if (!(packet instanceof PacketSpyAction)) {
System.out.println("[BigBrother] Packet reçu : " + name + " -> " + packet.getClass().getSimpleName());
} else {
System.out.println("[BigBrother] Packet reçu : " + name + " -> " + packet.getClass().getSimpleName() + " / " + ((PacketSpyAction) packet).getAction().name());
}
}
if (server.isLogged().equals(LoginResult.NOT_LOGGED)) {
if (packet instanceof PacketLogin) {
PacketLogin pl = (PacketLogin) packet;
try {
String cpass = pl.decryptPass(this.log.getKey());
System.out.println("[BigBrother] PacketLogin reçu, valeur du PASS (crypt) : " + pl.getCryptPassword());
System.out.println("[BigBrother] PacketLogin reçu, valeur du PASS (D_key) : " + cpass);
if (cpass.equals(this.log.getPassword())) {
server.sendPacket(new PacketText("[BigBrother] Connection réussie !"));
server.setLoginResult(LoginResult.LOGGED);
listeners.callOnConnectionSuccessfullServerListener(server);
} else {
server.sendMessage("[BigBrother] Mot de passe incorect !");
if (limit.containsKey(server)) {
limit.replace(server, limit.get(server) + 1);
if (limit.get(server) == 3) {
server.sendPacket(new PacketText("[BigBrother] Trop de tentatives ratées ! Déconnexion ..."));
server.close();
}
} else {
limit.put(server, 1);
}
}
} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | IOException e) {
return;
}
} else {
server.sendPacket(new PacketText("[BigBrother] Vous devez vous connecter !"));
return;
}
}
if (packet instanceof PacketCommand) {
this.listeners.callOnCommandServerListener((PacketCommand) packet);
} else if (packet instanceof PacketVersion) {
PacketVersion ver = (PacketVersion) packet;
if (!this.connectionstype.containsKey(VersionType.SPIGOT_VERSION)) {
if (ver.getType().equals(VersionType.SPIGOT_VERSION)) {
List<ConnectionHandler> list = new CopyOnWriteArrayList<>();
list.add(server);
this.connectionstype.put(VersionType.SPIGOT_VERSION, list);
}
} else {
if (ver.getType().equals(VersionType.SPIGOT_VERSION)) {
List<ConnectionHandler> list = this.connectionstype.get(VersionType.SPIGOT_VERSION);
list.add(server);
this.connectionstype.replace(VersionType.SPIGOT_VERSION, list);
}
}
if (!this.connectionstype.containsKey(VersionType.BUNGEECORD_VERSION)) {
if (ver.getType().equals(VersionType.BUNGEECORD_VERSION)) {
List<ConnectionHandler> list = new CopyOnWriteArrayList<>();
list.add(server);
this.connectionstype.put(VersionType.BUNGEECORD_VERSION, list);
}
} else {
if (ver.getType().equals(VersionType.BUNGEECORD_VERSION)) {
List<ConnectionHandler> list = this.connectionstype.get(VersionType.BUNGEECORD_VERSION);
list.add(server);
this.connectionstype.replace(VersionType.BUNGEECORD_VERSION, list);
}
}
} 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)) {
for (ConnectionHandler chs : this.connected) {
if (chs.getName().equals(fa.getServerDestination())) {
chs.sendPacket(packet);
}
}
}
}
} else if (packet instanceof PacketPlayerPing) {
PacketPlayerPing pp = (PacketPlayerPing) packet;
if (pp.getState().equals(PingState.INIT_SERVER)) {
pp.setState(PingState.BUNGEE_REQUEST);
try {
this.getServerConnectionByNameUnsafe(VersionType.BUNGEECORD_VERSION, "main-bungeecord").sendPacket(pp);
} catch (IOException e) {
e.printStackTrace();
}
}
} else if (packet instanceof PacketSpyAction) {
PacketSpyAction spy = (PacketSpyAction) packet;
Calendar cal = GregorianCalendar.getInstance();
cal.setTime(new Date());
if (this.gs.ifDataFileExists(spy.getPlayerName())) {
this.gs.updateDataFile(spy.getPlayerName(), BigBrotherSpyUtils.mergeHistory(this.gs.getHistory(spy.getPlayerName()), spy));
} else {
BigBrotherSpyHistory gh = new BigBrotherSpyHistory(spy.getPlayerName(), spy.getIP(), BigBrotherSpyUtils.toFireCalendar(cal));
gh.putMessage(BigBrotherSpyUtils.toFireCalendar(spy.getActionDate()), spy.getAction(), spy.getFormatedMsg(), spy.getRawMsg());
this.gs.createNewDataFile(spy.getPlayerName(), gh);
}
} else if (packet instanceof PacketSpyHistoryGetter) {
PacketSpyHistoryGetter get = (PacketSpyHistoryGetter) packet;
if (get.getState().equals(BigBrotherSpyHistoryGetterState.REQUEST)) {
get.setState(BigBrotherSpyHistoryGetterState.SEND);
get.setHistory(this.gs.getHistory(get.getPlayerName()));
server.sendPacket(get);
}
} else if (packet instanceof PacketBigBrotherAC) {
PacketBigBrotherAC gacp = (PacketBigBrotherAC) packet;
if (gacp.getType().equals(BigBrotherTypeAC.CHEAT_DETECTION)) {
if (gacp.getTODO().equals(BigBrotherActionAC.INFORM_STAFF)) {
this.getServerConnectionByNameUnsafe(VersionType.BUNGEECORD_VERSION, "main-bungeecord").sendPacket(gacp);
}
}
}
} catch (Exception e) {
return;
}
}
use of fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends in project FireAPI by FireBlade-Serv.
the class FriendsCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length == 0) {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
} else if (args.length == 1) {
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer pp = (ProxiedPlayer) sender;
if (args[0].equalsIgnoreCase("add")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis add <pseuso>"));
} else if (args[0].equalsIgnoreCase("remove")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis remove <pseudo>"));
} else if (args[0].equalsIgnoreCase("list")) {
try {
this.friends.sendGeneratedList(pp);
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("join")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis join <pseudo>"));
} else if (args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis accept <pseudo>"));
} else if (args[0].equalsIgnoreCase("gui")) {
List<String> names = new ArrayList<>();
for (ProxiedPlayer pps : this.api.getBungeePlugin().getProxy().getPlayers()) {
names.add(pps.getName());
}
try {
c.sendPacket(new PacketFriends(new FriendsActionTransmetterGUI(pp.getName(), pp.getServer().getInfo().getName().concat("-spigot"), this.friends.getAllFriends(pp.getName()), names)));
} catch (IOException e) {
e.printStackTrace();
}
} else {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
}
} else {
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, la console ne peut avoir d'amis :'(" + " (sauf Glowstoner mdr, sauf que c'est moi qui écrit ces lignes sur Eclipse," + " serais-je skyzophrène ?) C'est probable dit quelqu'un à l'horizon ... §oC'est le début d'une" + " longue histoire"));
}
}
if (args[0].equalsIgnoreCase("show")) {
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /amis show <pseudo>"));
} else {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'avez pas la permission d'utiliser cette fonctionnalité !"));
}
}
} else if (args.length == 2) {
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer pp = (ProxiedPlayer) sender;
ProxiedPlayer target = getPlayerByName(args[1]);
FirePlayer fp = new FirePlayer(pp, this.api);
if (args[0].equalsIgnoreCase("add")) {
if (target == null) {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, aucun joueur trouvé pour \"" + args[1] + "\" !"));
return;
}
if (target.equals(pp)) {
pp.sendMessage(new TextComponent(this.pre + "§cVous devriez pensez à soigner votre skyzophrènie"));
return;
}
try {
if (!this.friends.isAlreadyFriends(pp, target)) {
if (this.friends.canHaveMoreFriends(fp)) {
pp.sendMessage(new TextComponent(this.pre + "§aVous avez bien " + "envoyé votre demande à §2" + target.getName()));
this.friends.sendRequest(pp, target);
} else {
pp.sendMessage(new TextComponent(this.pre + "§cErreur vous avez ateint le nombre maximum d'amis pour votre grade !"));
}
} else {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, vous êtes déjà " + "ami avec " + target.getName() + " !"));
}
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("remove")) {
try {
this.friends.removeFriend(pp, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("join")) {
sender.sendMessage(new TextComponent(this.pre + "§5Indisponible pour le moment !"));
} else if (args[0].equalsIgnoreCase("accept")) {
if (target == null) {
pp.sendMessage(new TextComponent(this.pre + "§cErreur, aucun joueur trouvé pour \"" + args[1] + "\" !"));
return;
}
try {
this.friends.acceptRequest(pp, target);
} catch (IOException e) {
e.printStackTrace();
}
} else if (args[0].equalsIgnoreCase("show")) {
if (this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
try {
this.friends.sendGeneratedListOther(sender, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'avez pas la permission d'utiliser cette fonctionnalité !"));
}
} else {
if (sender instanceof ProxiedPlayer) {
sender.sendMessage(new TextComponent(this.pre + "/amis add <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis remove <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis list"));
sender.sendMessage(new TextComponent(this.pre + "/amis join <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis accept <pseudo>"));
sender.sendMessage(new TextComponent(this.pre + "/amis gui"));
}
if (sender.hasPermission("fireapi.friends.showother")) {
sender.sendMessage(new TextComponent(this.pre + "/amis show <pseudo>"));
}
}
} else {
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("accept")) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur, la console ne peut avoir d'amis :'(" + " (sauf Glowstoner mdr, sauf que c'est moi qui écrit ses lignes sur Eclipse," + " serais-je skyzophrène ?) C'est probable dit quelqu'un à l'horizon ... C'est le début d'une" + " longue histoire"));
} else {
try {
this.friends.sendGeneratedListOther(sender, args[1]);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
}
Aggregations