Search in sources :

Example 6 with FirePlayer

use of fr.glowstoner.fireapi.player.FirePlayer 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 7 with FirePlayer

use of fr.glowstoner.fireapi.player.FirePlayer 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)

Aggregations

FirePlayer (fr.glowstoner.fireapi.player.FirePlayer)7 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 ItemMeta (org.bukkit.inventory.meta.ItemMeta)2 FireTitle (fr.glowstoner.fireapi.bukkit.nms.title.FireTitle)1 LoginSuccessEvent (fr.glowstoner.fireapi.bungeecord.events.LoginSuccessEvent)1 PacketFriends (fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends)1 FriendsActionTransmetterGUI (fr.glowstoner.fireapi.bungeecord.friends.packets.action.FriendsActionTransmetterGUI)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 BadPaddingException (javax.crypto.BadPaddingException)1 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)1 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)1