Search in sources :

Example 36 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.

the class FireFriends method removeFriend.

public void removeFriend(ProxiedPlayer p1, String p2) throws IOException {
    if (this.enable) {
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        if (config.contains("data." + p1.getName()) && config.contains("data." + p2)) {
            List<String> list = config.getStringList("data." + p1.getName());
            if (list.contains(p2)) {
                list.remove(p2);
            }
            if (list.size() == 0) {
                config.set("data." + p1.getName(), null);
            } else {
                config.set("data." + p1.getName(), list);
            }
            List<String> list2 = config.getStringList("data." + p2);
            if (list2.contains(p1.getName())) {
                list2.remove(p1.getName());
            }
            if (list2.size() == 0) {
                config.set("data." + p2, null);
            } else {
                config.set("data." + p2, list2);
            }
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
            p1.sendMessage(new TextComponent(this.pre + "§aVous n'êtes plus ami avec " + p2));
        } else {
            p1.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'êtes pas ami avec " + p2));
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 37 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent 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 TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.

the class FireAuth method getLoginTitle.

public Title getLoginTitle() {
    Title title = this.main.getProxy().createTitle();
    title.title(new TextComponent("§cVous devez vous connecter !"));
    title.subTitle(new TextComponent("§c/login <motdepasse>"));
    return title;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Title(net.md_5.bungee.api.Title)

Example 39 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent 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 40 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent 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

TextComponent (net.md_5.bungee.api.chat.TextComponent)50 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)12 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)12 Player (org.bukkit.entity.Player)12 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)11 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)11 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)9 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)9 IOException (java.io.IOException)6 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)5 ArrayList (java.util.ArrayList)5 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)4 DecimalFormat (java.text.DecimalFormat)4 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)3 SoliniaActiveSpell (com.solinia.solinia.Models.SoliniaActiveSpell)3 File (java.io.File)3 EventHandler (net.md_5.bungee.event.EventHandler)3