CommandInjector.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:EscapeLag 作者:
public static void uninject(Plugin plg) {
    if (plg != null) {
        try {
            SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
            for (Command command : simpleCommandMap.getCommands()) {
                if (command instanceof PluginCommand) {
                    PluginCommand pluginCommand = (PluginCommand) command;
                    if (plg.equals(pluginCommand.getPlugin())) {
                        FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
                        FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
                        CommandExecutor executor = commandField.get(pluginCommand);
                        if (executor instanceof CommandInjector) {
                            commandField.set(pluginCommand, ((CommandInjector) executor).getCommandExecutor());
                        }
                        TabCompleter completer = tabField.get(pluginCommand);
                        if (completer instanceof CommandInjector) {
                            tabField.set(pluginCommand, ((CommandInjector) executor).getTabCompleter());
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号