Search in sources :

Example 36 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method getOnlineFriends.

public List<ProxiedPlayer> getOnlineFriends(ProxiedPlayer pp) throws IOException {
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
    List<ProxiedPlayer> connected = new ArrayList<>();
    List<String> list = config.getStringList("data." + pp.getName());
    for (String names : list) {
        try {
            ProxiedPlayer player = this.instance.getProxy().getPlayer(names);
            if (player != null) {
                connected.add(player);
            }
        } catch (Exception e) {
            continue;
        }
    }
    return connected;
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) ArrayList(java.util.ArrayList) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) IOException(java.io.IOException)

Example 37 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method sendGeneratedList.

public void sendGeneratedList(ProxiedPlayer pp) throws IOException {
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
    if (hasFriends(pp)) {
        if (getOnlineFriends(pp).size() == 0) {
            pp.sendMessage(new TextComponent(this.pre + "Vous n'avez §caucun§r ami connecté sur le serveur"));
        } else if (getOnlineFriends(pp).size() == 1) {
            pp.sendMessage(new TextComponent(this.pre + "Vous avez §eun§r ami connecté sur le serveur"));
        } else {
            pp.sendMessage(new TextComponent(this.pre + "Vous avez §e" + getOnlineFriends(pp).size() + "§r amis connectés sur le serveur"));
        }
    } else {
        pp.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas d'amis :("));
        return;
    }
    List<String> list = config.getStringList("data." + pp.getName());
    for (ProxiedPlayer connected : getOnlineFriends(pp)) {
        pp.sendMessage(new TextComponent(this.pre + "§a" + connected.getName() + "§r est actuellement sur le §e" + connected.getServer().getInfo().getName()));
        list.remove(connected.getName());
    }
    for (String names : list) {
        pp.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 38 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer 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();
                }
            }
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) FirePlayer(fr.glowstoner.fireapi.player.FirePlayer) FriendsActionTransmetterGUI(fr.glowstoner.fireapi.bungeecord.friends.packets.action.FriendsActionTransmetterGUI) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PacketFriends(fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends)

Example 39 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class RegisterCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
        ProxiedPlayer pp = (ProxiedPlayer) sender;
        FirePlayer fp = new FirePlayer(pp, this.instance);
        if (pp.getServer().getInfo().equals(this.instance.getProxy().getServerInfo("login"))) {
            if (this.sql.getCryptPassword(pp.getName()).equals("§default-not-set")) {
                if (args.length == 0) {
                    pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register <mot-de-passe> <même-mot-de-passe>"));
                } else if (args.length == 1) {
                    pp.sendMessage(new TextComponent(this.pre + "§cVeuillez confirmer votre mot de passe !"));
                    pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register <mot-de-passe> <même-mot-de-passe>"));
                } else if (args.length == 2) {
                    if (args[0].equals(args[1])) {
                        try {
                            auth.registerPassword(pp.getName(), args[0]);
                            pp.sendMessage(new TextComponent(this.pre + "§aVous vous êtes inscrit avec succès ! Bon jeu " + pp.getName() + " !"));
                            // register good
                            this.instance.getProxy().getPluginManager().callEvent(new LoginSuccessEvent(pp, LoginSourceType.REGISTRATION_SUCCESSFULL));
                        } catch (InvalidKeyException | UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException e) {
                            pp.disconnect(new TextComponent("§cUne erreur à été détectée !\n§cVeuillez réssayer plus tard !"));
                            e.printStackTrace();
                        }
                    } else {
                        pp.sendMessage(new TextComponent(this.pre + "§cErreur les deux entrées ne sont pas identiques !"));
                    }
                }
            } else {
                // registered
                pp.sendMessage(new TextComponent(this.pre + "§cVous êtes déjà inscrit utilisez " + "/login <mot-de-passe> §cpour vous connecter"));
            }
        } else {
            if (fp.hasRankAndSup(Rank.MANAGER_IG)) {
                if (args.length == 0) {
                    pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register unregister <pseudo>"));
                } else if (args.length == 1) {
                    pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register unregister <pseudo>"));
                } else if (args.length == 2) {
                    if (args[0].equalsIgnoreCase("unregister")) {
                        if (this.instance.getSQL().hasFireAccount(args[1])) {
                            if (args[1].equalsIgnoreCase("CONSOLE")) {
                                pp.sendMessage(new TextComponent(this.pre + "§cErreur, vous ne pouvez pas désinscrire la console !"));
                                return;
                            }
                            this.instance.getSQL().setCryptPassword(args[1], "§default-not-set");
                            pp.sendMessage(new TextComponent(this.pre + "§aLe joueur \"" + args[1] + "\" est maintenant plus inscrit !"));
                        } else {
                            pp.sendMessage(new TextComponent(this.pre + "§cErreur, le joueur spécifié ne s'est jamais connecté"));
                        }
                    } else {
                        pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register unregister <pseudo>"));
                    }
                } else {
                    pp.sendMessage(new TextComponent(this.pre + "§cUsage : /register unregister <pseudo>"));
                }
            }
        }
    } else {
        sender.sendMessage(new TextComponent(this.pre + "§cErreur, vous êtes la console c'est triste," + " vous ne pouvez executer cette commande, mais bon c'est la vie."));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) FirePlayer(fr.glowstoner.fireapi.player.FirePlayer) LoginSuccessEvent(fr.glowstoner.fireapi.bungeecord.events.LoginSuccessEvent) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchPaddingException(javax.crypto.NoSuchPaddingException) IllegalBlockSizeException(javax.crypto.IllegalBlockSizeException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) BadPaddingException(javax.crypto.BadPaddingException) InvalidKeyException(java.security.InvalidKeyException)

Example 40 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class StaffChatCommand method execute.

// ! = all en jeu
// : = staff chat
// @ = party chat
@Override
public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
        ProxiedPlayer pp = (ProxiedPlayer) sender;
        if (this.api.getRankSystem().hasRankAndSup(pp.getName(), Rank.GUIDE)) {
            if (this.players.containsKey(pp)) {
                pp.sendMessage(new TextComponent(this.pre + "§aBien, vous n'entendez plus les discutions du staff !"));
                this.players.remove(pp);
            } else {
                pp.sendMessage(new TextComponent(this.pre + "§aBien, vous entendez maintenant les discussions du staff !"));
                pp.sendMessage(new TextComponent(this.pre + "§oRappel : Utilisez ':' devant vos messages pour parler au reste du staff !"));
                this.players.put(pp, true);
            }
        } else {
            pp.sendMessage(new TextComponent(this.pre + "§cErreur vous n'avez pas la permission d'utiliser cette commande !"));
        }
    } else {
        if (this.consoleListen) {
            sender.sendMessage(new TextComponent(this.pre + "§aBien, vous n'entendez plus les discutions du staff !"));
            this.consoleListen = false;
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§aBien, vous entendez maintenant les discussions du staff !"));
            this.consoleListen = true;
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer)

Aggregations

ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)50 EventHandler (net.md_5.bungee.event.EventHandler)20 TextComponent (net.md_5.bungee.api.chat.TextComponent)17 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 UserPreference (com.github.games647.changeskin.core.model.UserPreference)5 Message (at.pcgamingfreaks.Bungee.Message.Message)4 User (me.lucko.luckperms.common.model.User)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 Test (org.junit.Test)4 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)3 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)3 PacketSpyAction (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction)3 Tristate (me.lucko.luckperms.api.Tristate)3 Chat (net.md_5.bungee.protocol.packet.Chat)3 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 FirePlayer (fr.glowstoner.fireapi.player.FirePlayer)2 Message (io.github.lxgaming.discordbot.entries.Message)2