Search in sources :

Example 1 with LoginSuccessEvent

use of fr.glowstoner.fireapi.bungeecord.events.LoginSuccessEvent 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

LoginSuccessEvent (fr.glowstoner.fireapi.bungeecord.events.LoginSuccessEvent)1 FirePlayer (fr.glowstoner.fireapi.player.FirePlayer)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 BadPaddingException (javax.crypto.BadPaddingException)1 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)1 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1