Search in sources :

Example 16 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project SkinsRestorerX by DoNotSpamPls.

the class PlayerCommands method execute.

public void execute(CommandSender sender, final String[] args) {
    if (!(sender instanceof ProxiedPlayer)) {
        sender.sendMessage(new TextComponent(Locale.NOT_PLAYER));
        return;
    }
    final ProxiedPlayer p = (ProxiedPlayer) sender;
    // Skin Help
    if (args.length == 0 || args.length > 2) {
        if (!Config.SKINWITHOUTPERM) {
            if (p.hasPermission("skinsrestorer.playercmds")) {
                help(p);
            } else {
                p.sendMessage(new TextComponent(Locale.PLAYER_HAS_NO_PERMISSION));
            }
        } else {
            help(p);
        }
    }
    // Skin Clear and Skin (name)
    if (args.length == 1) {
        if (args[0].equalsIgnoreCase("clear")) {
            CooldownStorage.resetCooldown(p.getName());
            CooldownStorage.setCooldown(p.getName(), Config.SKIN_CHANGE_COOLDOWN, TimeUnit.SECONDS);
            ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
                SkinStorage.removePlayerSkin(p.getName());
                SkinStorage.setPlayerSkin(p.getName(), p.getName());
                SkinApplier.applySkin(p);
                p.sendMessage(new TextComponent(Locale.SKIN_CLEAR_SUCCESS));
            });
        } else {
            // skin <skin>
            final String skin = args[0];
            if (Config.DISABLED_SKINS_ENABLED)
                if (!p.hasPermission("skinsrestorer.bypassdisabled")) {
                    for (String dskin : Config.DISABLED_SKINS) if (skin.equalsIgnoreCase(dskin)) {
                        p.sendMessage(new TextComponent(Locale.SKIN_DISABLED));
                        return;
                    }
                }
            if (!p.hasPermission("skinsrestorer.bypasscooldown") && CooldownStorage.hasCooldown(p.getName())) {
                p.sendMessage(new TextComponent(Locale.SKIN_COOLDOWN_NEW.replace("%s", "" + CooldownStorage.getCooldown(p.getName()))));
                return;
            }
            CooldownStorage.resetCooldown(p.getName());
            CooldownStorage.setCooldown(p.getName(), Config.SKIN_CHANGE_COOLDOWN, TimeUnit.SECONDS);
            ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
                try {
                    MojangAPI.getUUID(skin);
                    SkinStorage.setPlayerSkin(p.getName(), skin);
                    SkinApplier.applySkin(p);
                    p.sendMessage(new TextComponent(Locale.SKIN_CHANGE_SUCCESS));
                } catch (SkinRequestException e) {
                    p.sendMessage(new TextComponent(e.getReason()));
                }
            });
            return;
        }
    }
    // skin set
    if (args.length == 2) {
        if (args[0].equalsIgnoreCase("set")) {
            final String skin = args[1];
            if (Config.DISABLED_SKINS_ENABLED)
                if (!p.hasPermission("skinsrestorer.bypassdisabled")) {
                    for (String dskin : Config.DISABLED_SKINS) if (skin.equalsIgnoreCase(dskin)) {
                        p.sendMessage(new TextComponent(Locale.SKIN_DISABLED));
                        return;
                    }
                }
            if (!p.hasPermission("skinsrestorer.bypasscooldown") && CooldownStorage.hasCooldown(p.getName())) {
                p.sendMessage(new TextComponent(Locale.SKIN_COOLDOWN_NEW.replace("%s", "" + CooldownStorage.getCooldown(p.getName()))));
                return;
            }
            CooldownStorage.resetCooldown(p.getName());
            CooldownStorage.setCooldown(p.getName(), Config.SKIN_CHANGE_COOLDOWN, TimeUnit.SECONDS);
            ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
                try {
                    MojangAPI.getUUID(skin);
                    SkinStorage.setPlayerSkin(p.getName(), skin);
                    SkinApplier.applySkin(p);
                    p.sendMessage(new TextComponent(Locale.SKIN_CHANGE_SUCCESS));
                } catch (SkinRequestException e) {
                    p.sendMessage(new TextComponent(e.getReason()));
                }
            });
        } else {
            help(p);
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) SkinRequestException(skinsrestorer.shared.utils.MojangAPI.SkinRequestException)

Example 17 with TextComponent

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

the class BungeeMain method onEnable.

@Override
public void onEnable() {
    super.getLogger().info("FireAPI actif !");
    this.sql.connection();
    this.sql.startSqlRefreshScheduler(1800L);
    this.sql.putConsole();
    this.rank = new FireRank(this.sql);
    super.getProxy().registerChannel("fireapi");
    this.log = new BigBrotherLoginGetter();
    try {
        this.log.load();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    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(), log.getPassword()));
        ch.sendPacket(new PacketVersion(VersionType.BUNGEECORD_VERSION));
        ch.sendPacket(new PacketCommand("name main-bungeecord"));
        BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.GLOBAL_CHECK, BigBrotherConnectionInfos.builder().id("main-bungeecord").key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.BUNGEECORD_VERSION).build());
        check.startChecks();
        this.setChecker(check);
    } catch (Exception ex) {
        BigBrotherConnectionCheck check = new BigBrotherConnectionCheck(this, BigBrotherConnectionCheckType.ERROR_CHECK, BigBrotherConnectionInfos.builder().id("main-bungeecord").key(this.log.getKey()).password(this.log.getPassword()).versionType(VersionType.BUNGEECORD_VERSION).build());
        check.startChecks();
    }
    ConnectionsAPI.getListeners().registerClientListener(new ClientListener() {

        @Override
        public void onPacketReceive(Packet packet) {
            if (packet instanceof PacketExecute) {
                BungeeMain.super.getLogger().info("(BigBrother) Execution de la commande : " + ((PacketExecute) packet).getServerCommand() + ".");
                BungeeMain.super.getProxy().getPluginManager().dispatchCommand(BungeeMain.super.getProxy().getConsole(), ((PacketExecute) packet).getServerCommand());
            } else if (packet instanceof PacketPlayerPing) {
                PacketPlayerPing pp = (PacketPlayerPing) packet;
                BungeeMain.super.getProxy().getPlayer(pp.getName()).sendMessage(new TextComponent("§6[§ePing§6]§r Ton ping §eproxy§r est de §e" + BungeeMain.super.getProxy().getPlayer(pp.getName()).getPing() + " ms§r !"));
            } else if (packet instanceof PacketBigBrotherAC) {
                PacketBigBrotherAC gacp = (PacketBigBrotherAC) packet;
                if (gacp.getType().equals(BigBrotherTypeAC.CHEAT_DETECTION)) {
                    if (gacp.getTODO().equals(BigBrotherActionAC.INFORM_STAFF)) {
                        for (ProxiedPlayer ps : getProxy().getPlayers()) {
                            if (api.getRankSystem().hasRankAndSup(ps.getName(), Rank.ASSISTANT)) {
                                ps.sendMessage(new TextComponent("§c[BigBrother] [Cheat] §4" + gacp.getPlayerName() + " §r~ " + gacp.getMessage() + " §c" + gacp.getPing() + "ms"));
                            }
                        }
                    }
                }
            }
        }
    });
    this.friends = new FireFriends(this);
    this.friends.initFolder();
    try {
        this.friends.loadConfiguration();
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.auth = new FireAuth(this);
    try {
        this.auth.loadConfiguration();
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.chat = new FireChat(this);
    this.wl = new FireWL(this);
    this.wl.loadConfiguration();
    super.getLogger().info("Clé de sécurité utilisée : " + this.auth.getSecurityKey());
    PluginManager man = super.getProxy().getPluginManager();
    man.registerCommand(this, new CoinsCheckerCommand(this, "coins"));
    man.registerCommand(this, new Website("site"));
    man.registerCommand(this, new Discord("discord"));
    man.registerCommand(this, new FriendsCommand(this, "amis"));
    man.registerCommand(this, new FireRankCommand(this, "firerank"));
    man.registerCommand(this, new RegisterCommand(this, "register"));
    man.registerCommand(this, new LoginCommand(this, "login"));
    man.registerCommand(this, new FireWhiteListCommand("firewl", this));
    StaffChatCommand scc = new StaffChatCommand(this, "firestaffchat");
    man.registerCommand(this, scc);
    Events events = new Events(this, scc);
    man.registerListener(this, events);
    this.check.registerListener(events);
    api = this;
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) PacketCommand(fr.glowstoner.connectionsapi.network.packets.command.PacketCommand) BigBrotherConnectionCheck(fr.glowstoner.fireapi.bigbrother.console.check.BigBrotherConnectionCheck) Website(fr.glowstoner.fireapi.bungeecord.commands.misc.Website) PacketVersion(fr.glowstoner.fireapi.bigbrother.console.packets.PacketVersion) RegisterCommand(fr.glowstoner.fireapi.bungeecord.commands.RegisterCommand) PacketPlayerPing(fr.glowstoner.fireapi.bigbrother.console.packets.ping.PacketPlayerPing) PluginManager(net.md_5.bungee.api.plugin.PluginManager) PacketExecute(fr.glowstoner.fireapi.bigbrother.console.packets.PacketExecute) Events(fr.glowstoner.fireapi.bungeecord.events.Events) FireRankCommand(fr.glowstoner.fireapi.bungeecord.commands.FireRankCommand) BigBrotherLoginGetter(fr.glowstoner.fireapi.bigbrother.console.login.BigBrotherLoginGetter) FireWL(fr.glowstoner.fireapi.wl.FireWL) Discord(fr.glowstoner.fireapi.bungeecord.commands.misc.Discord) Client(fr.glowstoner.connectionsapi.network.client.Client) FireRank(fr.glowstoner.fireapi.rank.FireRank) TextComponent(net.md_5.bungee.api.chat.TextComponent) Packet(fr.glowstoner.connectionsapi.network.packets.Packet) LoginCommand(fr.glowstoner.fireapi.bungeecord.commands.LoginCommand) FireAuth(fr.glowstoner.fireapi.bungeecord.auth.FireAuth) PacketLogin(fr.glowstoner.connectionsapi.network.packets.login.PacketLogin) IOException(java.io.IOException) IOException(java.io.IOException) ClientListener(fr.glowstoner.connectionsapi.network.events.ClientListener) StaffChatCommand(fr.glowstoner.fireapi.bungeecord.commands.StaffChatCommand) ConnectionHandler(fr.glowstoner.connectionsapi.network.ConnectionHandler) FriendsCommand(fr.glowstoner.fireapi.bungeecord.commands.FriendsCommand) FireFriends(fr.glowstoner.fireapi.bungeecord.friends.FireFriends) FireWhiteListCommand(fr.glowstoner.fireapi.bungeecord.commands.FireWhiteListCommand) FireChat(fr.glowstoner.fireapi.chat.FireChat) PacketBigBrotherAC(fr.glowstoner.fireapi.bigbrother.ac.packet.PacketBigBrotherAC) CoinsCheckerCommand(fr.glowstoner.fireapi.bungeecord.commands.CoinsCheckerCommand)

Example 18 with TextComponent

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

the class FireAuth method getRegisterTitle.

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

Example 19 with TextComponent

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

the class FireRankCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (this.rank.hasRankAndSupOrConsole(sender, Rank.STAFF_MANAGER)) {
        if (args.length == 0) {
            sender.sendMessage(new TextComponent(this.pre + "/firerank show <pseudo>"));
            sender.sendMessage(new TextComponent(this.pre + "/firerank set <pseudo> <rang>"));
        } else if (args.length == 1) {
            if (args[0].equalsIgnoreCase("show")) {
                sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firerank show <pseudo>"));
            } else if (args[0].equalsIgnoreCase("set")) {
                sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firerank set <pseudo> <rang>"));
            } else {
                sender.sendMessage(new TextComponent(this.pre + "/firerank show <pseudo>"));
                sender.sendMessage(new TextComponent(this.pre + "/firerank set <pseudo> <rang>"));
            }
        } else if (args.length == 2) {
            if (args[0].equalsIgnoreCase("show")) {
                if (this.sql.hasFireAccount(args[1])) {
                    sender.sendMessage(new TextComponent(this.pre + "Le joueur §a" + args[1] + "§r est §e" + this.rank.getPlayerRank(args[1]).name() + "§r !"));
                } else {
                    sender.sendMessage(new TextComponent(this.pre + "§cImpossible de trouver le joueur \"" + args[1] + "\" !"));
                }
            } else if (args[0].equalsIgnoreCase("set")) {
                sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firerank set <pseudo> <rang>"));
            } else {
                sender.sendMessage(new TextComponent(this.pre + "/firerank show <pseudo>"));
                sender.sendMessage(new TextComponent(this.pre + "/firerank set <pseudo> <rang>"));
            }
        } else if (args.length == 3) {
            if (args[0].equalsIgnoreCase("show")) {
                sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firerank show <pseudo>"));
            } else if (args[0].equalsIgnoreCase("set")) {
                if (this.sql.hasFireAccount(args[1])) {
                    if (containsRank(args[2])) {
                        this.rank.setPlayerRank(args[1], getApproximative(args[2]));
                        sender.sendMessage(new TextComponent(this.pre + "§e" + args[1] + " §rpossède maintenant le grade de §e" + getApproximative(args[2]).name() + "§r !"));
                    } else {
                        sender.sendMessage(new TextComponent(this.pre + "§cErreur, ce grade n'existe pas !"));
                        sender.sendMessage(new TextComponent(this.pre + "§cVoici la liste des grades disponibles : " + getRankList()));
                    }
                } else {
                    sender.sendMessage(new TextComponent(this.pre + "§cImpossible de trouver le joueur \"" + args[1] + "\" !"));
                }
            }
        }
    } else {
        sender.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas la permission d'utiliser cette commande !"));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent)

Example 20 with TextComponent

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

the class FireWhiteListCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    if (!this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
        sender.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas la permission d'utiliser cette commande !"));
        return;
    }
    if (args.length == 0) {
        sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
        return;
    } else if (args.length == 1) {
        if (args[0].equalsIgnoreCase("on")) {
            File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
            try {
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                config.set("enable", true);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est activé !"));
                this.api.getWhitelistSystem().setEnable(true);
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else if (args[0].equalsIgnoreCase("off")) {
            File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
            try {
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                config.set("enable", false);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est désactivé !"));
                this.api.getWhitelistSystem().setEnable(false);
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
            return;
        }
    } else if (args.length == 2) {
        if (this.api.getWhitelistSystem().isEnable() == false) {
            sender.sendMessage(new TextComponent(this.pre + "§cLe plugin est désactivé !"));
            return;
        }
        if (args[0].equalsIgnoreCase("add")) {
            try {
                File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                if (config.getBoolean("players." + args[1] + ".accepted") == true) {
                    sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " est déjà dans la whitelist !"));
                    return;
                }
                config.set("players." + args[1] + ".accepted", true);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aVous avez ajouté le joueur " + args[1] + " à la whitelist !"));
                return;
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else if (args[0].equalsIgnoreCase("remove")) {
            try {
                File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
                Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
                if (config.getBoolean("players." + args[1] + ".accepted") == false) {
                    sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " n'existe pas !"));
                    return;
                }
                config.set("players." + args[1] + ".accepted", false);
                ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
                sender.sendMessage(new TextComponent(this.pre + "§aVous avez retiré le joueur " + args[1] + " de la WhiteList !"));
            } catch (IOException e) {
                sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
            }
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
            return;
        }
    } else {
        sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
        return;
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) IOException(java.io.IOException) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File)

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