Closed MarkManFlame55 closed 2 months ago
That means you have either not configured Maven/Gradle to include the AnvilGUI classes into your JAR file (using the Maven Shade plugin or Gradle Shadow plugin), or you have not deployed the shaded JAR with the AnvilGUI clases to your server (perhaps you deployed the unshaded version?).
Please double-check this and send your Maven/Gradle build file if you can't figure it out.
This is how I have my build.gradle
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven {
name = "codemc-snapshot"
url = "https://repo.codemc.io/repository/maven-snapshots/"
}
}
dependencies {
compileOnly "io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT"
compileOnly 'net.luckperms:api:5.4'
compileOnly "net.wesjd:anvilgui:1.10.2-SNAPSHOT"
}
it is getting imported cause I can navigate through the library inside my IDE, maybe its tha unshaded version but I dont know how to verify that. Any help?
Thanks, now I see why it's not working for you. Right now you are only compiling against AnvilGUI (which yes, does mean you can see it in your IDE), but you are not including the class files from AnvilGUI inside your plugin JAR file. This is normally done via the Maven Shade plugin, or (in your case) the Gradle Shadow plugin, which I linked above.
Here's an example of how you could modify your build.gradle
script you provided, in order to include the AnvilGUI classes:
plugins {
// Your other plugins
// ...
id "com.gradleup.shadow" version "8.3.0"
}
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven {
name = "codemc-snapshot"
url = "https://repo.codemc.io/repository/maven-snapshots/"
}
}
dependencies {
compileOnly "io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT"
compileOnly 'net.luckperms:api:5.4'
implementation "net.wesjd:anvilgui:1.10.2-SNAPSHOT"
}
tasks.named("shadowJar") {
archiveClassifier = ""
relocate "net.wesjd.anvilgui", "[YOUR_PLUGIN_PACKAGE].anvilgui"
}
tasks.named("assemble") {
dependsOn tasks.named("shadowJar")
}
Note especially the switch from compileOnly
to implementation
on the AnvilGUI dependency. Also, don't forget to replace the [YOUR_PLUGIN_PACKAGE]
part with your plugin package name, such as com.example.myplugin
. After modifying your buildscript to include all this, just run the Gradle build
task like normal, and you should get a plugin JAR with AnvilGUI included, in your build/libs/
directory that Gradle creates.
Note, this stuff is already documented for Maven Shade plugin, but the documentation could be improved, and an example for Gradle like the one I just showed you is missing, so I'll add that when I get time.
Let me know if you have further questions. If you'd like to read more about Gradle Shadow plugin etc, here are some links:
Happy to say that it worked!! Tysm <3
Following tutorial on README and getting to try ot get a string from the menu. Getting this error on the console.
Also getting NoClassDefFoundError when trying to call the function that opens the gui