Luohuayu / CatServer

高性能和高兼容性的1.12.2/1.16.5/1.18.2版本Forge+Bukkit+Spigot服务端 (A high performance and high compatibility 1.12.2/1.16.5/1.18.2 version Forge+Bukkit+Spigot server)
https://catmc.org
GNU Lesser General Public License v3.0
1.98k stars 211 forks source link

[1.18.2] forge模组自定义的指令会被bukkit/spigot拦截而无法使用 #835

Closed NattoCB closed 9 months ago

NattoCB commented 10 months ago

运行环境

Minecraft版本(1.12.2/1.16.5/1.18.2): 1.18.2 构建版本(从/version指令获取): https://github.com/Luohuayu/CatServer/commit/6c3f59653b3cc3e1528206f1b5998ebeee62f3ba 相关模组/插件: 任意新模组

描述这个BUG 模组命令失效

导致的问题 模组命令失效

复现方法

写一个模组如下:

    private static final Logger LOGGER = LoggerFactory.getLogger(TestMod.class);
    @SubscribeEvent
    public void onServerStarting(ServerStartingEvent event) {
        event.getServer().getCommands().getDispatcher().register(Commands.literal("testmod")
                .then(Commands.literal("test")
                       .executes(TestMod::testLogic)));
    }
    private static int testLogic(CommandContext<CommandSourceStack> context) {
        context.getSource().sendSuccess(new TextComponent("test"), false);
        LOGGER.info("test");
        return Command.SINGLE_SUCCESS;
    }

/testmod test 调用 testLogic 的 LOGGER 输出日志 test ,并给玩家发送信息 “test”

实测结果:

Kotori0629 commented 9 months ago

经过测试后Create命令正常,若还有问题提供测试mod(我不晓得为什么拉不下来forgemdk)并再开启一个issue