monun/kommand

1.19.2 사용시 아래와 같은 오류 발생

Closed this issue · 10 comments

paper : paper-1.19.2-125.jar

build.gradle

    repositories {
        maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
        mavenCentral()
    }

    dependencies {
        compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
        implementation("io.github.monun:kommand-core:2.14.0")
    }

plugin.yml

libraries:
  - net.kyori:adventure-api:4.10.1
  - org.jetbrains.kotlin:kotlin-stdlib:1.6.21
  - org.jetbrains.kotlin:kotlin-reflect:1.6.21
  - io.github.monun:kommand-core:2.14.0

서버로그 ( 에러 )

java.lang.ExceptionInInitializerError: null
	at io.github.monun.kommand.Kommand.<clinit>(Kommand.kt) ~[liha-bingo.jar:?]
	at io.github.monun.kommand.PluginKommand.register(Kommand.kt:39) ~[liha-bingo.jar:?]
	at io.github.donghune.MissionCommand$initEn$1.invoke(MissionCommand.kt:74) ~[liha-bingo.jar:?]
	at io.github.donghune.MissionCommand$initEn$1.invoke(MissionCommand.kt:73) ~[liha-bingo.jar:?]
	at io.github.monun.kommand.KommandKt.kommand(Kommand.kt:44) ~[liha-bingo.jar:?]
	at io.github.donghune.MissionCommand.initEn(MissionCommand.kt:73) ~[liha-bingo.jar:?]
	at io.github.donghune.WildPlugin.onEnable(WildPlugin.kt:16) ~[liha-bingo.jar:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:542) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:565) ~[paper-1.19.2.jar:git-Paper-125]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:479) ~[paper-1.19.2.jar:git-Paper-125]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.reload(CraftServer.java:1020) ~[paper-1.19.2.jar:git-Paper-125]
	at org.bukkit.Bukkit.reload(Bukkit.java:910) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:911) ~[paper-1.19.2.jar:git-Paper-125]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchServerCommand(CraftServer.java:874) ~[paper-1.19.2.jar:git-Paper-125]
	at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:473) ~[paper-1.19.2.jar:git-Paper-125]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.19.2.jar:git-Paper-125]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1416) ~[paper-1.19.2.jar:git-Paper-125]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1192) ~[paper-1.19.2.jar:git-Paper-125]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-125]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassCastException: class io.github.monun.kommand.v1_19_2.NMSKommand
	at java.lang.Class.asSubclass(Class.java:3924) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS(LibraryLoader.kt:74) ~[liha-bingo.jar:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS$default(LibraryLoader.kt:54) ~[liha-bingo.jar:?]
	at io.github.monun.kommand.Kommand$Companion.<init>(Kommand.kt:27) ~[liha-bingo.jar:?]
	at io.github.monun.kommand.Kommand$Companion.<clinit>(Kommand.kt) ~[liha-bingo.jar:?]
monun commented

확인해보겠습니다

monun commented

소스코드 올려주실수 있나요
저는 정상작동합니다

https://github.com/donghune/minecraft-terraria

1.18.2 이지만 동일한 오류가 발생하여 해당 레포 첨부드립니다

plugin.yml에 libraries로 받아온 라이브러리도
ShadowJar로 포함 하면서 생긴 문제같습니다
mavenCentral에서 가져온 라이브러리들을
implenmentation에서 compileOnly로 바꾸고 테스트 하니
모두 잘 작동하였습니다

아마도 shadow 된건 api뿐이인데
Class.forName에서 플러그인의 클래스로더로 NMSKommand를 가지고 올려고 해서
작동이 안된걸로 추정이 되네유

monun commented

살짝 둘러봤는데 kommand 라이브러리를 셰딩하시나요?

Kommand는 shadow로 작동하지 않고 spigot의 라이브러리 기능으로 동작합니다.

kommand 모듈을 exclude해보세요

shadow 를 완전히 제거하고 빌드를 돌렸을때는

java.lang.ExceptionInInitializerError: null
	at io.github.monun.kommand.Kommand.<clinit>(Kommand.kt) ~[?:?]
	at io.github.monun.kommand.PluginKommand.register(Kommand.kt:39) ~[?:?]
	at io.github.donghune.AuctonCommand$initialize$1.invoke(AuctonCommand.kt:8) ~[terraria-auction.jar:?]
	at io.github.donghune.AuctonCommand$initialize$1.invoke(AuctonCommand.kt:7) ~[terraria-auction.jar:?]
	at io.github.monun.kommand.KommandKt.kommand(Kommand.kt:44) ~[?:?]
	at io.github.donghune.AuctonCommand.initialize(AuctonCommand.kt:7) ~[terraria-auction.jar:?]
	at io.github.donghune.AuctionPlugin.onEnable(AuctionPlugin.kt:11) ~[terraria-auction.jar:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[paper-1.18.2.jar:git-Paper-388]
	at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[paper-1.18.2.jar:git-Paper-388]
	at org.bukkit.craftbukkit.v1_18_R2.CraftServer.reload(CraftServer.java:1016) ~[paper-1.18.2.jar:git-Paper-388]
	at org.bukkit.Bukkit.reload(Bukkit.java:909) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:906) ~[paper-1.18.2.jar:git-Paper-388]
	at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchServerCommand(CraftServer.java:869) ~[paper-1.18.2.jar:git-Paper-388]
	at net.minecraft.server.dedicated.DedicatedServer.handleConsoleInputs(DedicatedServer.java:510) ~[paper-1.18.2.jar:git-Paper-388]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:484) ~[paper-1.18.2.jar:git-Paper-388]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1456) ~[paper-1.18.2.jar:git-Paper-388]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1226) ~[paper-1.18.2.jar:git-Paper-388]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.18.2.jar:git-Paper-388]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.UnsupportedOperationException: io.github.monun.kommand.Kommand has an error occurred while creating the instance
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS(LibraryLoader.kt:93) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS$default(LibraryLoader.kt:54) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<init>(Kommand.kt:27) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<clinit>(Kommand.kt) ~[?:?]
	... 24 more
Caused by: java.lang.reflect.InvocationTargetException
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS(LibraryLoader.kt:82) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS$default(LibraryLoader.kt:54) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<init>(Kommand.kt:27) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<clinit>(Kommand.kt) ~[?:?]
	... 24 more
Caused by: java.lang.NoSuchFieldError: vanillaCommandDispatcher
	at io.github.monun.kommand.v1_18_2.NMSKommand.<init>(NMSKommand.kt:45) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS(LibraryLoader.kt:82) ~[?:?]
	at io.github.monun.kommand.loader.LibraryLoader.loadNMS$default(LibraryLoader.kt:54) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<init>(Kommand.kt:27) ~[?:?]
	at io.github.monun.kommand.Kommand$Companion.<clinit>(Kommand.kt) ~[?:?]
	... 24 more
	```

이런식으로 출력이 됩니다.

신규 프로젝트를 생성해서 kommand 만 넣어도 위와 같은 오류가 발생합니다.

JAR=/Users/yudonghun/.mcservers/paper/paper-mojmap-1.18.2-388.jar
MEMORY=4
BACKUP=false
RESTART=false
PLAYERS=100
PLUGINS=plugins-dev
WORLDS=worlds
PORT=-1
DEBUG_PORT=5005
JVM_TYPE=hotspot
Use Aikar's standard memory options
DEBUG MODE: JDK9+
Parameters: -Xmx4G -Xms4G -Dfile.encoding=UTF-8 -Dcom.mojang.eula.agree=true -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar /Users/yudonghun/.mcservers/paper/paper-mojmap-1.18.2-388.jar --nogui -s100 -Pplugins-dev -Wworlds
Listening for transport dt_socket at address: 5005
Downloading mojang_1.18.2.jar
Applying patches
Starting org.bukkit.craftbukkit.Main
*** Warning, you've not updated in a while! ***
*** Please download a new build as per instructions from https://papermc.io/downloads ***
System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.1+12) Host: Mac OS X 10.16 (x86_64)

추가로 확인 한 정보로 paper-mojmap-1.18.2-388.jar 에서 구동시 위와 같은 에러가 발생하고 paper-1.18.2-388.jar 일 경우 정상적으로 로드 되는 상태 입니다. 하지만 오류는 안나는대신 실제 코드 동작은 안하는거 같네요 :(

shadow 제거 후 정상 작동 확인 했습니다