Closed ItsHarshXD closed 3 months ago
add the Shadow plugin to gradle: https://plugins.gradle.org/plugin/io.github.goooler.shadow and relocate using something like this:
tasks.shadowJar {
relocate("net.megavex.scoreboardlibrary", "com.yourpackage.scoreboard")
}
add the Shadow plugin to gradle: https://plugins.gradle.org/plugin/io.github.goooler.shadow and relocate using something like this:
tasks.shadowJar { relocate("net.megavex.scoreboardlibrary", "com.yourpackage.scoreboard") }
I tried but this error is coming on server:
[08:28:23 ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'CivilizationRoyale-1.0.0-all.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: org/itsharshxd/civilizationroyale/libs/scoreboard/api/exception/NoPacketAdapterAvailableException at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:127) ~[purpur-1.19.4.jar:git-Purpur-1985] at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:35) ~[purpur-1.19.4.jar:git-Purpur-1985] at io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy.loadProviders(ModernPluginLoadingStrategy.java:116) ~[purpur-1.19.4.jar:git-Purpur-1985] at io.papermc.paper.plugin.storage.SimpleProviderStorage.enter(SimpleProviderStorage.java:39) ~[purpur-1.19.4.jar:git-Purpur-1985] at io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enter(LaunchEntryPointHandler.java:36) ~[purpur-1.19.4.jar:git-Purpur-1985] at org.bukkit.craftbukkit.v1_19_R3.CraftServer.loadPlugins(CraftServer.java:445) ~[purpur-1.19.4.jar:git-Purpur-1985] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:310) ~[purpur-1.19.4.jar:git-Purpur-1985] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1120) ~[purpur-1.19.4.jar:git-Purpur-1985] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:325) ~[purpur-1.19.4.jar:git-Purpur-1985] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: java.lang.NoClassDefFoundError: org/itsharshxd/civilizationroyale/libs/scoreboard/api/exception/NoPacketAdapterAvailableException at java.lang.Class.forName0(Native Method) ~[?:?] at java.lang.Class.forName(Class.java:488) ~[?:?] at java.lang.Class.forName(Class.java:467) ~[?:?] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:78) ~[purpur-api-1.19.4-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[purpur-1.19.4.jar:git-Purpur-1985] ... 9 more Caused by: java.lang.ClassNotFoundException: org.itsharshxd.civilizationroyale.libs.scoreboard.api.exception.NoPacketAdapterAvailableException at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:185) ~[purpur-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:152) ~[purpur-api-1.19.4-R0.1-SNAPSHOT.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?] at java.lang.Class.forName0(Native Method) ~[?:?] at java.lang.Class.forName(Class.java:488) ~[?:?] at java.lang.Class.forName(Class.java:467) ~[?:?] at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:78) ~[purpur-api-1.19.4-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[purpur-1.19.4.jar:git-Purpur-1985] ... 9 more
This is how I shaded it:
shadowJar {
relocate 'net.megavex.scoreboardlibrary', 'org.itsharshxd.civilizationroyale.libs.scoreboard'
}
tasks.build.dependsOn shadowJar
build {
dependsOn shadowJar
}
Please send your full build.gradle if possible
Please send your full build.gradle if possible
Here:
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
group = 'org.itsharshxd'
version = '1.0.0'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven {
name "papermc"
url "https://papermc.io/repo/repository/maven-public/"
}
maven { url 'https://jitpack.io' }
repositories {
maven {
url = uri("https://maven.pkg.github.com/ItsHarshXD/MatrixGliders-API")
repositories {
maven {
url = uri("https://maven.pkg.github.com/ItsHarshXD/MatrixGliders-API")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
}
}
maven {
url "https://repo.oraxen.com/releases"
}
maven {
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
maven {
url = uri('https://repo.codemc.org/repository/maven-public/')
}
maven{
url = uri("https://repo.onarandombox.com/content/groups/public/")
}
maven { url "https://repo.dmulloy2.net/repository/public/" }
}
dependencies {
compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
implementation 'com.github.timsixth.MinigameAPI:api:1.4.1'
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
implementation "io.papermc:paperlib:1.0.7"
compileOnly 'io.th0rgal:oraxen:1.171.0'
compileOnly 'com.github.LoneDev6:API-ItemsAdder:3.6.3-beta-14'
implementation 'com.zaxxer:HikariCP:5.1.0'
implementation 'com.github.hamza-cskn.obliviate-invs:core:4.3.0'
implementation 'com.github.hamza-cskn.obliviate-invs:pagination:4.3.0'
implementation "net.kyori:adventure-api:4.17.0"
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly 'org.itsharshxd:matrixgliders:1.0.2-SNAPSHOT'
compileOnly "org.popcraft:chunky-common:1.3.38"
compileOnly 'com.onarandombox.multiversecore:multiverse-core:4.3.12'
implementation "io.reactivex.rxjava3:rxjava:3.1.8"
compileOnly 'com.comphenix.protocol:ProtocolLib:5.1.0'
compileOnly 'net.megavex:scoreboard-library-api:2.1.10'
}
shadowJar {
relocate 'com.github.timsixth', 'org.itsharshxd.civilizationroyale.libs.minigameapi'
relocate "io.papermc.lib", "org.itsharshxd.civilizationroyale.libs.paperlib"
relocate 'com.zaxxer.hikari', 'org.itsharshxd.civilizationroyale.libs.hikari'
relocate 'net.megavex.scoreboardlibrary', 'org.itsharshxd.civilizationroyale.libs.scoreboard'
}
tasks.build.dependsOn shadowJar
build {
dependsOn shadowJar
}
def targetJavaVersion = 16
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('.yml') {
expand props
}
}
scoreboard-library-api must be marked as implementation
instead of compileOnly
for it to be shaded into your plugin
you also need to add:
runtimeOnly 'net.megavex:scoreboard-library-implementation:2.1.10'
as well as any packet adapters you need
scoreboard-library-api must be marked as
implementation
instead ofcompileOnly
for it to be shaded into your pluginyou also need to add:
runtimeOnly 'net.megavex:scoreboard-library-implementation:2.1.10'
as well as any packet adapters you need
Thanks it is now working, but scoreboard isn't showing up!
Code:
public static final Sidebar sidebar = scoreboardLibrary.createSidebar(); //in my main class
Event code:
public class PlayerGameJoinListener implements Listener {
private final Sidebar sidebar = CoreManager.sidebar;
@EventHandler
public void onPlayerGameJoin(GameJoinEvent event) {
Player player = event.getPlayer();
String gameModeId = event.getGameMode();
if(sidebar.players().contains(player)) {
sidebar.removePlayer(event.getPlayer());
}
GameModeScoreboard scoreboard = getScoreboardByID(gameModeId);
if (scoreboard != null && scoreboard.isEnabled()) {
sidebar.title(Component.text(scoreboard.getTitle()));
int lineIndex = 0;
for (String line : scoreboard.getLines()) {
sidebar.line(lineIndex++, Component.text(line));
}
sidebar.addPlayer(player);
}
}
}
This is custom event...
what is your server software and version and which packet adapters did you add?
what is your server software and version and which packet adapters did you add?
Software: Paper Packet Adapters: none i guess or idk what u mean
my class to get scoreboard info is working but the scoreboard is not showing up.
Read the installation guide again
Read the installation guide again
i did now?
Add the modern packet adapter with runtimeOnly 'net.megavex:scoreboard-library-modern:2.1.10'
for 1.17-latest support. And if you need support for any other versions you also have to setup packetevents
Add the modern packet adapter with
runtimeOnly 'net.megavex:scoreboard-library-modern:2.1.10'
for 1.17-latest support. And if you need support for any other versions you also have to setup packetevents
I want my plugin to support 1.16 to latest so what scoreboard depend do i need to add?
The gradle section in the installation guide has everything you need to know
The gradle section in the installation guide has everything you need to know
I read that but still don't know what to import rather than library and implementation artifact. (am just using low level sidebar)
EDIT: Fixed and thanks for the help ! btw what is the code to make the scoreboard hide from a player?
Is that
sidebar.removePlayer(Player player);
or
sidebar.close();
sidebar.removePlayer() hides the sidebar for a single player and close() hides for all players and cleans it up
sidebar.removePlayer() hides the sidebar for a single player and close() hides for all players and cleans it up
any possible way to manually/force update a sidebar?
It should update automatically when you change any line
It should update automatically when you change any line
Ok thanks for the help!
as the title says how can i shade it?