Search in sources :

Example 26 with CommandSource

use of com.velocitypowered.api.command.CommandSource in project MiraiMC by DreamVoid.

the class MiraiCommand method execute.

@Override
public void execute(Invocation invocation) {
    CommandSource source = invocation.source();
    // Get the arguments after the command alias
    String[] args = invocation.arguments();
    if (!(args.length == 0)) {
        switch(args[0].toLowerCase()) {
            case "login":
                {
                    if (source.hasPermission("miraimc.command.mirai.login")) {
                        if (args.length >= 3) {
                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                BotConfiguration.MiraiProtocol Protocol = null;
                                boolean useHttpApi = false;
                                if (args.length == 3) {
                                    Protocol = BotConfiguration.MiraiProtocol.ANDROID_PHONE;
                                } else if (args[3].equalsIgnoreCase("httpapi")) {
                                    useHttpApi = true;
                                } else
                                    try {
                                        Protocol = BotConfiguration.MiraiProtocol.valueOf(args[3].toUpperCase());
                                    } catch (IllegalArgumentException ignored) {
                                        source.sendMessage(Component.text(Color.translate("&e无效的协议类型,已自动选择 ANDROID_PHONE.")));
                                        source.sendMessage(Component.text(Color.translate("&e可用的协议类型: " + Arrays.toString(BotConfiguration.MiraiProtocol.values()).replace("[", "").replace("]", "") + ", HTTPAPI")));
                                        Protocol = BotConfiguration.MiraiProtocol.ANDROID_PHONE;
                                    }
                                try {
                                    if (!useHttpApi) {
                                        MiraiBot.doBotLogin(Long.parseLong(args[1]), args[2], Protocol);
                                    } else {
                                        if (Config.Gen_EnableHttpApi) {
                                            MiraiHttpAPI httpAPI = new MiraiHttpAPI(Config.HTTPAPI_Url);
                                            httpAPI.bind(httpAPI.verify(args[2]).session, Long.parseLong(args[1]));
                                            source.sendMessage(Component.text(Color.translate("&a" + args[1] + " HTTP-API登录成功!")));
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c" + "此服务器没有启用HTTP-API模式,请检查配置文件!")));
                                    }
                                } catch (InterruptedException | IOException e) {
                                    Utils.logger.warning("登录机器人时出现异常,原因: " + e);
                                    source.sendMessage(Component.text(Color.translate("&c登录机器人时出现异常,请检查控制台输出!")));
                                } catch (AbnormalStatusException e) {
                                    Utils.logger.warning("使用HTTPAPI登录机器人时出现异常,状态码:" + e.getCode() + ",原因: " + e.getMessage());
                                    source.sendMessage(Component.text(Color.translate("&c登录机器人时出现异常,状态码:" + e.getCode() + ",原因: " + e.getMessage())));
                                }
                            }).schedule();
                        } else {
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai login <账号> <密码> [协议]")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "logout":
                {
                    if (source.hasPermission("miraimc.command.mirai.logout")) {
                        if (args.length >= 2) {
                            try {
                                MiraiBot.getBot(Long.parseLong(args[1])).doLogout();
                                source.sendMessage(Component.text(Color.translate("&a已退出指定机器人!")));
                            } catch (NoSuchElementException e) {
                                source.sendMessage(Component.text(Color.translate("&c指定的机器人不存在!")));
                            }
                        } else {
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai logout <账号>")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "sendgroupmessage":
                {
                    if (source.hasPermission("miraimc.command.mirai.sendgroupmessage")) {
                        if (args.length >= 4) {
                            StringBuilder message = new StringBuilder();
                            for (int i = 0; i < args.length; i++) {
                                // list.size()就是循环的次数
                                if (i >= 3) {
                                    message.append(args[i]).append(" ");
                                }
                            }
                            MiraiBot.getBot(Long.parseLong(args[1])).getGroup(Long.parseLong(args[2])).sendMessageMirai(message.toString().replace("\\n", System.lineSeparator()));
                        } else {
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai sendgroupmessage <账号> <群号> <消息>")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "sendfriendmessage":
                {
                    if (source.hasPermission("miraimc.command.mirai.sendfriendmessage")) {
                        if (args.length >= 4) {
                            StringBuilder message = new StringBuilder();
                            for (int i = 0; i < args.length; i++) {
                                // list.size()就是循环的次数
                                if (i >= 3) {
                                    message.append(args[i]).append(" ");
                                }
                            }
                            MiraiBot.getBot(Long.parseLong(args[1])).getFriend(Long.parseLong(args[2])).sendMessageMirai(message.toString().replace("\\n", System.lineSeparator()));
                        } else {
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai sendfriendmessage <账号> <好友> <消息>")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "sendfriendnudge":
                {
                    if (source.hasPermission("miraimc.command.mirai.sendfriendnudge")) {
                        if (args.length >= 3) {
                            MiraiBot.getBot(Long.parseLong(args[1])).getFriend(Long.parseLong(args[2])).sendNudge();
                        } else {
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai sendfriendnudge <账号> <好友>")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "list":
                {
                    if (source.hasPermission("miraimc.command.mirai.list")) {
                        source.sendMessage(Component.text(Color.translate("&a存在的机器人: ")));
                        List<Long> BotList = MiraiBot.getOnlineBots();
                        for (long bots : BotList) {
                            Bot bot = Bot.getInstance(bots);
                            if (bot.isOnline()) {
                                source.sendMessage(Component.text(Color.translate("&b" + bot.getId() + "&r &7-&r &6" + Bot.getInstance(bots).getNick())));
                            } else {
                                source.sendMessage(Component.text(Color.translate("&b" + bot.getId() + "&r &7-&r &c离线")));
                            }
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "checkonline":
                {
                    if (source.hasPermission("miraimc.command.mirai.checkonline")) {
                        if (args.length >= 2) {
                            if (MiraiBot.getBot(Long.parseLong(args[1])).isOnline()) {
                                source.sendMessage(Component.text(Color.translate("&a当前机器人在线")));
                            } else
                                source.sendMessage(Component.text(Color.translate("&e当前机器人不在线")));
                        } else
                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai checkonline <账号>")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "autologin":
                {
                    if (source.hasPermission("miraimc.command.mirai.autologin")) {
                        if (args.length >= 2) {
                            switch(args[1]) {
                                case "add":
                                    {
                                        boolean result;
                                        if (args.length >= 4) {
                                            if (args.length == 5) {
                                                result = MiraiAutoLogin.addAutoLoginBot(Long.parseLong(args[2]), args[3], args[4]);
                                            } else
                                                result = MiraiAutoLogin.addAutoLoginBot(Long.parseLong(args[2]), args[3], "ANDROID_PHONE");
                                            if (result) {
                                                source.sendMessage(Component.text(Color.translate("&a新的自动登录机器人添加成功!")));
                                            } else
                                                source.sendMessage(Component.text(Color.translate("&c新的自动登录机器人添加失败,请检查控制台错误输出!")));
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai autologin add <账号> <密码> [协议]")));
                                        break;
                                    }
                                case "remove":
                                    {
                                        boolean result;
                                        if (args.length >= 3) {
                                            result = MiraiAutoLogin.delAutoLoginBot(Long.parseLong(args[2]));
                                            if (result) {
                                                source.sendMessage(Component.text(Color.translate("&a删除自动登录机器人成功!")));
                                            } else
                                                source.sendMessage(Component.text(Color.translate("&c删除自动登录机器人失败,请检查控制台错误输出!")));
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /mirai autologin remove <账号>")));
                                        break;
                                    }
                                case "list":
                                    {
                                        source.sendMessage(Component.text(Color.translate("&a存在的自动登录机器人: ")));
                                        try {
                                            source.sendMessage(Component.text(Color.translate("&a存在的自动登录机器人: ")));
                                            List<AutoLoginObject.Accounts> AutoLoginBotList = MiraiAutoLogin.loadAutoLoginList();
                                            for (AutoLoginObject.Accounts bots : AutoLoginBotList) {
                                                source.sendMessage(Component.text(Color.translate("&b" + bots.getAccount())));
                                            }
                                        } catch (FileNotFoundException e) {
                                            plugin.getLogger().warn("读取自动登录机器人列表时出现异常,原因: " + e);
                                            source.sendMessage(Component.text(Color.translate("&c读取列表时出现异常,请查看控制台了解更多信息!")));
                                        }
                                        break;
                                    }
                                default:
                                    {
                                        source.sendMessage(Component.text(Color.translate("&c未知或不完整的命令,请输入 /mirai help 查看帮助!")));
                                        break;
                                    }
                            }
                        } else
                            source.sendMessage(Component.text(Color.translate("&c未知或不完整的命令,请输入 /mirai help 查看帮助!")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "help":
                {
                    source.sendMessage(Component.text(Color.translate("&6&lMiraiMC&r &b机器人帮助菜单")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai login <账号> <密码> [协议]:&r 登录一个机器人")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai logout <账号>:&r 退出一个机器人")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai list:&r 查看当前存在的机器人")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai sendfriendmessage <账号> <好友> <消息>:&r 向指定好友发送私聊消息")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai sendgroupmessage <账号> <群号> <消息>:&r 向指定群发送群聊消息")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai sendfriendnudge <账号> <好友>:&r 向指定好友发送戳一戳")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai checkonline <账号>:&r 检查指定的机器人是否在线")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai autologin add <账号> <密码> [协议]:&r 添加一个自动登录账号")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai autologin list:&r 查看自动登录账号列表")));
                    source.sendMessage(Component.text(Color.translate("&6/mirai autologin remove <账号>:&r 删除一个自动登录账号")));
                    break;
                }
            default:
                {
                    source.sendMessage(Component.text(Color.translate("&c未知或不完整的命令,请输入 /mirai help 查看帮助!")));
                    break;
                }
        }
    } else {
        source.sendMessage(Component.text("This server is running " + plugin.getPluginContainer().getDescription().getName() + " version " + plugin.getPluginContainer().getDescription().getVersion() + " by " + plugin.getPluginContainer().getDescription().getAuthors().toString().replace("[", "").replace("]", "")));
    }
}
Also used : Bot(net.mamoe.mirai.Bot) MiraiBot(me.dreamvoid.miraimc.api.MiraiBot) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) AbnormalStatusException(me.dreamvoid.miraimc.internal.httpapi.exception.AbnormalStatusException) CommandSource(com.velocitypowered.api.command.CommandSource) AutoLoginObject(me.dreamvoid.miraimc.velocity.utils.AutoLoginObject) MiraiHttpAPI(me.dreamvoid.miraimc.internal.httpapi.MiraiHttpAPI) List(java.util.List) NoSuchElementException(java.util.NoSuchElementException) BotConfiguration(net.mamoe.mirai.utils.BotConfiguration)

Example 27 with CommandSource

use of com.velocitypowered.api.command.CommandSource in project MiraiMC by DreamVoid.

the class MiraiMcCommand method execute.

@Override
public void execute(Invocation invocation) {
    CommandSource source = invocation.source();
    // Get the arguments after the command alias
    String[] args = invocation.arguments();
    if (!(args.length == 0)) {
        switch(args[0].toLowerCase()) {
            case "reload":
                {
                    if (source.hasPermission("miraimc.command.miraimc.reload")) {
                        try {
                            VelocityConfig.reloadConfig();
                            source.sendMessage(Component.text(Color.translate("&a配置文件已经重新加载,部分配置可能需要重新启动服务器才能生效!")));
                        } catch (IOException e) {
                            e.printStackTrace();
                            source.sendMessage(Component.text(Color.translate("&c加载配置文件时出错,请检查控制台了解更多信息!")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "bind":
                {
                    if (source.hasPermission("miraimc.command.miraimc.bind")) {
                        if (args.length >= 2) {
                            switch(args[1].toLowerCase()) {
                                case "add":
                                    {
                                        if (args.length >= 4) {
                                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                                Player player = plugin.getServer().getPlayer(args[2]).orElse(null);
                                                if (player != null) {
                                                    String uuid = player.getUniqueId().toString();
                                                    long qqid = Long.parseLong(args[3]);
                                                    MiraiMC.addBinding(uuid, qqid);
                                                    source.sendMessage(Component.text(Color.translate("&a已添加绑定!")));
                                                } else
                                                    source.sendMessage(Component.text(Color.translate("&c指定的玩家不存在,请检查是否存在拼写错误!")));
                                            });
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /miraimc bind add <玩家名> <QQ号>")));
                                        break;
                                    }
                                case "removeplayer":
                                    {
                                        if (args.length >= 3) {
                                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                                Player player = plugin.getServer().getPlayer(args[2]).orElse(null);
                                                if (player != null) {
                                                    String uuid = player.getUniqueId().toString();
                                                    MiraiMC.removeBinding(uuid);
                                                    source.sendMessage(Component.text(Color.translate("&a已移除相应绑定!")));
                                                } else
                                                    source.sendMessage(Component.text(Color.translate("&c指定的玩家不存在,请检查是否存在拼写错误!")));
                                            });
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /miraimc bind removeplayer <玩家名>")));
                                        break;
                                    }
                                case "removeqq":
                                    {
                                        if (args.length >= 3) {
                                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                                long qqid = Long.parseLong(args[2]);
                                                MiraiMC.removeBinding(qqid);
                                                source.sendMessage(Component.text(Color.translate("&a已移除相应绑定!")));
                                            });
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /miraimc bind removeqq <QQ号>")));
                                        break;
                                    }
                                case "getplayer":
                                    {
                                        if (args.length >= 3) {
                                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                                Player player = plugin.getServer().getPlayer(args[2]).orElse(null);
                                                if (player != null) {
                                                    String uuid = player.getUniqueId().toString();
                                                    long qqId = MiraiMC.getBinding(uuid);
                                                    if (qqId != 0) {
                                                        source.sendMessage(Component.text(Color.translate("&a绑定的QQ号:" + qqId)));
                                                    } else
                                                        source.sendMessage(Component.text(Color.translate("&c未找到符合条件的记录!")));
                                                } else
                                                    source.sendMessage(Component.text(Color.translate("&c指定的玩家不存在,请检查是否存在拼写错误!")));
                                            });
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /miraimc bind getplayer <玩家名>")));
                                        break;
                                    }
                                case "getqq":
                                    {
                                        if (args.length >= 3) {
                                            plugin.getServer().getScheduler().buildTask(plugin, () -> {
                                                long qqid = Long.parseLong(args[2]);
                                                String playerName = MiraiMC.getBinding(qqid);
                                                if (!playerName.equals("")) {
                                                    source.sendMessage(Component.text(Color.translate("&a绑定的玩家名:" + plugin.getServer().getPlayer(UUID.fromString(playerName)).get().getUsername())));
                                                } else
                                                    source.sendMessage(Component.text(Color.translate("&c未找到符合条件的记录!")));
                                            });
                                        } else
                                            source.sendMessage(Component.text(Color.translate("&c无效的参数!用法: /miraimc bind getqq <QQ号>")));
                                        break;
                                    }
                                default:
                                    {
                                        source.sendMessage(Component.text(Color.translate("&c未知或不完整的命令,请输入 /miraimc bind 查看帮助!")));
                                        break;
                                    }
                            }
                        } else {
                            source.sendMessage(Component.text(Color.translate("&6&lMiraiMC&r &b插件帮助菜单&r &a玩家绑定")));
                            source.sendMessage(Component.text(Color.translate("&6/miraimc bind add <玩家名> <QQ号>:&r 为玩家和QQ号添加绑定")));
                            source.sendMessage(Component.text(Color.translate("&6/miraimc bind getplayer <玩家名>:&r 获取指定玩家名绑定的QQ号")));
                            source.sendMessage(Component.text(Color.translate("&6/miraimc bind getqq <QQ号>:&r 获取指定QQ号绑定的玩家名")));
                            source.sendMessage(Component.text(Color.translate("&6/miraimc bind removeplayer <玩家名>:&r 删除一个玩家的绑定")));
                            source.sendMessage(Component.text(Color.translate("&6/miraimc bind removeqq <QQ号>:&r 删除一个QQ号的绑定")));
                        }
                    } else
                        source.sendMessage(Component.text(Color.translate("&c你没有足够的权限执行此命令!")));
                    break;
                }
            case "help":
                {
                    source.sendMessage(Component.text(Color.translate("&6&lMiraiMC&r &b插件帮助菜单")));
                    source.sendMessage(Component.text(Color.translate("&6/miraimc bind:&r 玩家绑定菜单")));
                    source.sendMessage(Component.text(Color.translate("&6/miraimc reload:&r 重新加载插件")));
                    break;
                }
            default:
                {
                    source.sendMessage(Component.text(Color.translate("&c未知或不完整的命令,请输入 /miraimc help 查看帮助!")));
                    break;
                }
        }
    } else {
        source.sendMessage(Component.text("This server is running " + plugin.getPluginContainer().getDescription().getName() + " version " + plugin.getPluginContainer().getDescription().getVersion() + " by " + plugin.getPluginContainer().getDescription().getAuthors().toString().replace("[", "").replace("]", "")));
    }
}
Also used : Player(com.velocitypowered.api.proxy.Player) IOException(java.io.IOException) CommandSource(com.velocitypowered.api.command.CommandSource)

Example 28 with CommandSource

use of com.velocitypowered.api.command.CommandSource in project MiraiMC by DreamVoid.

the class MiraiVerifyCommand method execute.

@Override
public void execute(Invocation invocation) {
    CommandSource source = invocation.source();
    // Get the arguments after the command alias
    String[] args = invocation.arguments();
    if (args.length > 0) {
        switch(args[0].toLowerCase()) {
            case "unsafedevice":
                {
                    if (args.length >= 2) {
                        MiraiLoginSolver.solveUnsafeDeviceLoginVerify(Long.parseLong(args[1]), false);
                        source.sendMessage(Component.text(Color.translate("&a已将验证请求提交到服务器")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify unsafedevice <账号>")));
                    break;
                }
            case "unsafedevicecancel":
                {
                    if (args.length >= 2) {
                        MiraiLoginSolver.solveUnsafeDeviceLoginVerify(Long.parseLong(args[1]), true);
                        source.sendMessage(Component.text(Color.translate("&a已取消登录验证流程")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify unsafedevicecancel <账号>")));
                    break;
                }
            case "slidercaptcha":
                {
                    if (args.length >= 3) {
                        source.sendMessage(Component.text(Color.translate("&a已将ticket提交到服务器")));
                        MiraiLoginSolver.solveSliderCaptcha(Long.parseLong(args[1]), args[2]);
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify slidercaptcha <账号> <ticket>")));
                    break;
                }
            case "slidercaptchacancel":
                {
                    if (args.length >= 2) {
                        MiraiLoginSolver.solveSliderCaptcha(Long.parseLong(args[1]), true);
                        source.sendMessage(Component.text(Color.translate("&a已取消登录验证流程")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify slidercaptchacancel <账号>")));
                    break;
                }
            case "piccaptcha":
                {
                    if (args.length >= 3) {
                        source.sendMessage(Component.text(Color.translate("&a已将验证码提交到服务器")));
                        MiraiLoginSolver.solvePicCaptcha(Long.parseLong(args[1]), args[2]);
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify piccaptcha <账号> <验证码>")));
                    break;
                }
            case "piccaptchacancel":
                {
                    if (args.length >= 2) {
                        MiraiLoginSolver.solvePicCaptcha(Long.parseLong(args[1]), true);
                        source.sendMessage(Component.text(Color.translate("&a已取消登录验证流程")));
                    } else
                        source.sendMessage(Component.text(Color.translate("&c无效的参数!用法:/miraiverify piccaptchacancel <账号>")));
                    break;
                }
            default:
                break;
        }
    }
}
Also used : CommandSource(com.velocitypowered.api.command.CommandSource)

Example 29 with CommandSource

use of com.velocitypowered.api.command.CommandSource in project VotingPlugin by Ben12345rocks.

the class VotingPluginVelocityCommand method execute.

@Override
public void execute(final Invocation invocation) {
    CommandSource source = invocation.source();
    // Get the arguments after the command alias
    String[] args = invocation.arguments();
    if (args.length > 0) {
        if (args[0].equalsIgnoreCase("reload")) {
            plugin.reload(false);
            source.sendMessage(Component.text("Reloading VotingPluginBungee").color(NamedTextColor.AQUA));
        }
        if (args[0].equalsIgnoreCase("reloadmysql")) {
            plugin.reload(true);
            source.sendMessage(Component.text("Reloading VotingPluginBungee MySQL").color(NamedTextColor.AQUA));
        }
        if (args[0].equalsIgnoreCase("vote")) {
            if (args.length >= 2) {
                String user = args[1];
                String site = args[2];
                plugin.vote(user, site, false);
                source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
            }
        }
        if (args[0].equalsIgnoreCase("status")) {
            if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
                source.sendMessage(Component.text("Checking status, waiting for response, check console, method: sockets").color(NamedTextColor.AQUA));
                plugin.status();
            } else if (plugin.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
                source.sendMessage(Component.text("Checking status, waiting for response, check console, method: pluginmessaging").color(NamedTextColor.AQUA));
                plugin.status();
            } else {
                source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable").color(NamedTextColor.AQUA));
            }
        }
        if (args[0].equalsIgnoreCase("help")) {
            String[] msg = new String[4];
            msg[0] = "votingpluginbungee reload - Reload plugin";
            msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
            msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
            msg[3] = "votingpluginbungee status - Check socket connection status";
            for (String m : msg) {
                source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
            }
        }
    }
}
Also used : CommandSource(com.velocitypowered.api.command.CommandSource)

Example 30 with CommandSource

use of com.velocitypowered.api.command.CommandSource in project Fallback-Server by sasi2006166.

the class FallbackVelocityCommand method execute.

@Override
public void execute(Invocation invocation) {
    String[] args = invocation.arguments();
    CommandSource commandSource = invocation.source();
    if (args.length > 0) {
    }
}
Also used : CommandSource(com.velocitypowered.api.command.CommandSource)

Aggregations

CommandSource (com.velocitypowered.api.command.CommandSource)43 Player (com.velocitypowered.api.proxy.Player)23 Component (net.kyori.adventure.text.Component)10 SimpleCommand (com.velocitypowered.api.command.SimpleCommand)7 SQLException (java.sql.SQLException)6 List (java.util.List)6 LegacyComponentSerializer (net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer)6 NamedTextColor (net.kyori.adventure.text.format.NamedTextColor)5 Subscribe (com.velocitypowered.api.event.Subscribe)4 ConsoleCommandSource (com.velocitypowered.api.proxy.ConsoleCommandSource)4 ProxyServer (com.velocitypowered.api.proxy.ProxyServer)4 RegisteredServer (com.velocitypowered.api.proxy.server.RegisteredServer)4 ArrayList (java.util.ArrayList)4 Collectors (java.util.stream.Collectors)4 RegisteredPlayer (net.elytrium.limboauth.model.RegisteredPlayer)4 Gson (com.google.gson.Gson)3 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)3 BrigadierCommand (com.velocitypowered.api.command.BrigadierCommand)3 RawCommand (com.velocitypowered.api.command.RawCommand)3 ServerConnection (com.velocitypowered.api.proxy.ServerConnection)3