CommandInjector.java 文件源码

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

项目:EscapeLag 作者:
/**
 * 
 * @author jiongjionger,Vlvxingze
 */

public static void inject(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);
                        CommandInjector commandInjector = new CommandInjector(plg, commandField.get(pluginCommand), tabField.get(pluginCommand));
                        commandField.set(pluginCommand, commandInjector);
                        tabField.set(pluginCommand, commandInjector);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号