Search in sources :

Example 26 with CommandSender

use of net.md_5.bungee.api.CommandSender 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 27 with CommandSender

use of net.md_5.bungee.api.CommandSender 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)

Example 28 with CommandSender

use of net.md_5.bungee.api.CommandSender in project LuckPerms by lucko.

the class BungeeCommandExecutor method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
    List<String> arguments = CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
    this.manager.onCommand(lpSender, "lpb", arguments);
}
Also used : CommandSender(net.md_5.bungee.api.CommandSender) Sender(me.lucko.luckperms.common.sender.Sender)

Example 29 with CommandSender

use of net.md_5.bungee.api.CommandSender in project CloudNet by Dytanic.

the class CommandCloudDev method execute.

@Override
public void execute(CommandSender commandSender, String[] args) {
    if (!(commandSender instanceof ProxiedPlayer))
        return;
    switch(args.length) {
        case 0:
            for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                    DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                    if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                        ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                        return;
                    }
                }
            }
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev forTemplate <group> <template>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev forTemplate <group>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev testServer <group>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev testServer <group> <template>");
            break;
        case 2:
            {
                for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                    if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                        DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                        if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                            ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                            return;
                        }
                    }
                }
                if (args[0].equalsIgnoreCase("forTemplate")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(NetworkUtils.DEV_PROPERTY, new DevService(((ProxiedPlayer) commandSender).getUniqueId(), true)), System.currentTimeMillis());
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig, "Dev" + args[1] + "-" + commandSender.getName());
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
                if (args[0].equalsIgnoreCase("testServer")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(), System.currentTimeMillis());
                    CloudAPI.getInstance().startCloudServer("TestServer-" + ((ProxiedPlayer) commandSender).getUniqueId(), serverConfig, 356, true);
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
            }
        case 3:
            {
                for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                    if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                        DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                        if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                            ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                            return;
                        }
                    }
                }
                if (args[0].equalsIgnoreCase("forTemplate")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerGroup serverGroup = CloudAPI.getInstance().getServerGroup(args[1]);
                    if (CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template template) {
                            return template.getName().equalsIgnoreCase(args[2]);
                        }
                    }) == null) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The template doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(NetworkUtils.DEV_PROPERTY, new DevService(((ProxiedPlayer) commandSender).getUniqueId(), true)), System.currentTimeMillis());
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig, CloudAPI.getInstance().getServerGroupData(args[1]).getMemory(), true, new Properties(), CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template e) {
                            return e.getName().equalsIgnoreCase(args[2]);
                        }
                    }), "Dev" + args[1] + "-" + commandSender.getName());
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
                if (args[0].equalsIgnoreCase("testServer")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerGroup serverGroup = CloudAPI.getInstance().getServerGroup(args[1]);
                    if (CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template template) {
                            return template.getName().equalsIgnoreCase(args[2]);
                        }
                    }) == null) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The template doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(), System.currentTimeMillis());
                    /*
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig,
                            CloudAPI.getInstance().getServerGroupData(args[1]).getMemory(),
                            new String[0], null, "TestServer-" + commandSender.getName(), false, true, new Properties(),
                            null, Arrays.asList()
                            , "Dev" + args[1] + "-" + commandSender.getName());
                    */
                    CloudAPI.getInstance().startCloudServer("TestServer-" + ((ProxiedPlayer) commandSender).getUniqueId(), serverConfig, 356, true);
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
            }
            break;
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ServerConfig(de.dytanic.cloudnet.lib.server.ServerConfig) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) DevService(de.dytanic.cloudnet.lib.server.advanced.DevService) Document(de.dytanic.cloudnet.lib.utility.document.Document) Properties(java.util.Properties) Template(de.dytanic.cloudnet.lib.server.template.Template)

Example 30 with CommandSender

use of net.md_5.bungee.api.CommandSender in project CloudNet by Dytanic.

the class CommandHub method execute.

@Override
public void execute(CommandSender commandSender, String[] args) {
    if (!(commandSender instanceof ProxiedPlayer))
        return;
    ServerInfo serverInfo = CloudProxy.getInstance().getCachedServers().get(((ProxiedPlayer) commandSender).getServer().getInfo().getName());
    if (serverInfo != null)
        if (CloudProxy.getInstance().getProxyGroup().getProxyConfig().getDynamicFallback().getNamedFallbackes().contains(serverInfo.getServiceId().getGroup())) {
            commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("hub-already")));
            return;
        }
    String fallback = CloudProxy.getInstance().fallbackOnEnabledKick((((ProxiedPlayer) commandSender)), CloudAPI.getInstance().getGroup(), ((ProxiedPlayer) commandSender).getServer().getInfo().getName());
    ProxiedPlayerFallbackEvent proxiedPlayerFallbackEvent = new ProxiedPlayerFallbackEvent((ProxiedPlayer) commandSender, CloudAPI.getInstance().getOnlinePlayer(((ProxiedPlayer) commandSender).getUniqueId()), ProxiedPlayerFallbackEvent.FallbackType.HUB_COMMAND, fallback);
    ProxyServer.getInstance().getPluginManager().callEvent(proxiedPlayerFallbackEvent);
    fallback = proxiedPlayerFallbackEvent.getFallback();
    ProxyServer.getInstance().getPluginManager().callEvent(proxiedPlayerFallbackEvent);
    if (fallback == null)
        commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("hubCommandNoServerFound")));
    else
        ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(fallback));
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) ProxiedPlayerFallbackEvent(de.dytanic.cloudnet.bridge.event.proxied.ProxiedPlayerFallbackEvent)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)22 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)15 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)11 CommandSender (net.md_5.bungee.api.CommandSender)9 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)8 Player (org.bukkit.entity.Player)8 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)6 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)6 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)5 ArrayList (java.util.ArrayList)4 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)3 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)3 ChatSender (at.pcgamingfreaks.Bungee.Message.Sender.ChatSender)2 SendMethod (at.pcgamingfreaks.Bungee.Message.Sender.SendMethod)2 CommandHandler (com.Ben12345rocks.AdvancedCore.Objects.CommandHandler)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)2 SoliniaActiveSpell (com.solinia.solinia.Models.SoliniaActiveSpell)2 SoliniaEntitySpells (com.solinia.solinia.Models.SoliniaEntitySpells)2 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)2