beautiful
This commit is contained in:
1 parent
ce1533ded5
commit
b16dd7cbac
7 files changed
+16
-53
No files matched your search
@@ -15,17 +15,6 @@ dependencies {
|
||||
runtimeOnly("net.megavex:scoreboard-library-implementation:$scoreboardLibraryVersion")
|
||||
implementation("net.megavex:scoreboard-library-extra-kotlin:$scoreboardLibraryVersion") // Kotlin specific extensions (optional)
|
||||
|
||||
// Add packet adapter implementations you want:
|
||||
runtimeOnly("net.megavex:scoreboard-library-modern:$scoreboardLibraryVersion") // 1.17+
|
||||
runtimeOnly("net.megavex:scoreboard-library-legacy:$scoreboardLibraryVersion") // 1.7.10-1.12.2
|
||||
|
||||
// If using the PacketEvents implementation, scoreboard-library expects PacketEvents to be in the classpath.
|
||||
// Follow either of:
|
||||
// - https://github.com/retrooper/packetevents/wiki/Depending-on-pre%E2%80%90built-PacketEvents
|
||||
// - https://github.com/retrooper/packetevents/wiki/Shading-PacketEvents
|
||||
// Example how to load PacketEvents in your plugin:
|
||||
// https://github.com/retrooper/packetevents-example/blob/24f0c842d47362aef122b794dea29b8fee113fa3/thread-safe-listener/src/main/java/main/Main.java
|
||||
|
||||
// If targeting a Minecraft version without native Adventure support, add it as well:
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
|
||||
}
|
||||
@@ -56,35 +45,6 @@ like [Shadow](https://gradleup.com/shadow/).
|
||||
<version>{VERSION HERE}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Add packet adapter implementations you want: -->
|
||||
<dependency>
|
||||
<groupId>net.megavex</groupId>
|
||||
<artifactId>scoreboard-library-modern</artifactId>
|
||||
<version>{VERSION HERE}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.megavex</groupId>
|
||||
<artifactId>scoreboard-library-packetevents</artifactId>
|
||||
<version>{VERSION HERE}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.megavex</groupId>
|
||||
<artifactId>scoreboard-library-legacy</artifactId>
|
||||
<version>{VERSION HERE}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
If using the PacketEvents implementation, scoreboard-library expects PacketEvents to be in the classpath.
|
||||
Follow either of:
|
||||
- https://github.com/retrooper/packetevents/wiki/Depending-on-pre-built-PacketEvents
|
||||
- https://github.com/retrooper/packetevents/wiki/Shading-PacketEvents
|
||||
Example how to load PacketEvents in your plugin:
|
||||
https://github.com/retrooper/packetevents-example/blob/24f0c842d47362aef122b794dea29b8fee113fa3/thread-safe-listener/src/main/java/main/Main.java
|
||||
-->
|
||||
|
||||
<!-- If targeting a Minecraft version without native Adventure support, add it as well: -->
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
|
||||
@@ -21,13 +21,9 @@ Join the [Discord](https://discord.gg/v7nmTDTW8W) or create an issue for support
|
||||
- Automatically works with `TranslatableComponent`s. All components are translated using `GlobalTranslator` for
|
||||
each player's client locale and automatically update whenever the player changes it in their settings
|
||||
|
||||
## Available Packet Adapters
|
||||
## Supported server versions
|
||||
|
||||
- **modern.** Supports 1.17-1.21.11. Can take advantage of [Paper](https://papermc.io)'s native adventure support to be more efficient.
|
||||
- **legacy.** Supports 1.7.10-1.12.2.
|
||||
|
||||
> [!NOTE]
|
||||
> You can add multiple packet adapters, the best one will automatically be picked depending on the server version.
|
||||
All Paper and Spigot versions from 1.7.10 to 1.21.11 are now natively supported.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -40,9 +36,9 @@ ScoreboardLibrary scoreboardLibrary;
|
||||
try {
|
||||
scoreboardLibrary = ScoreboardLibrary.loadScoreboardLibrary(plugin);
|
||||
} catch (NoPacketAdapterAvailableException e) {
|
||||
// If no packet adapter was found, you can fallback to the no-op implementation:
|
||||
// If server version is not yet supported, you can fallback to the no-op implementation:
|
||||
scoreboardLibrary = new NoopScoreboardLibrary();
|
||||
plugin.getLogger().warning("No scoreboard packet adapter available!");
|
||||
plugin.getLogger().warning("Server version unsupported, scoreboards will not display!");
|
||||
}
|
||||
|
||||
// On plugin shutdown:
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface ScoreboardLibrary {
|
||||
* Creates an instance of {@link ScoreboardLibrary}.
|
||||
*
|
||||
* @param plugin your plugin instance
|
||||
* @throws NoPacketAdapterAvailableException if there is no packet adapter available for the current server version
|
||||
* @throws NoPacketAdapterAvailableException if server version is not supported
|
||||
*/
|
||||
static @NotNull ScoreboardLibrary loadScoreboardLibrary(@NotNull Plugin plugin) throws NoPacketAdapterAvailableException {
|
||||
Class<?> implClass;
|
||||
|
||||
@@ -3,7 +3,6 @@ adventure = "4.25.0"
|
||||
|
||||
[libraries]
|
||||
spigotApi = "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" # do not update
|
||||
packetEvents = "com.github.retrooper:packetevents-spigot:2.11.0"
|
||||
buildIndra = { module = "net.kyori:indra-common", version = "4.0.0" }
|
||||
buildNmcp = "com.gradleup.nmcp:com.gradleup.nmcp.gradle.plugin:0.0.9"
|
||||
|
||||
|
||||
@@ -6,4 +6,7 @@ dependencies {
|
||||
api(project(":scoreboard-library-api"))
|
||||
implementation(project(":scoreboard-library-packet-adapter-base"))
|
||||
compileOnly(libs.spigotApi)
|
||||
|
||||
implementation(project(":scoreboard-library-modern"))
|
||||
implementation(project(":scoreboard-library-legacy"))
|
||||
}
|
||||
@@ -8,7 +8,6 @@ dependencies {
|
||||
|
||||
implementation(project(":scoreboard-library-api"))
|
||||
implementation(project(":scoreboard-library-implementation"))
|
||||
implementation(project(":scoreboard-library-modern"))
|
||||
|
||||
compileOnly(libs.adventureApi)
|
||||
compileOnly(libs.adventureTextSerializerGson)
|
||||
|
||||
+8
-2
@@ -3,7 +3,6 @@ package net.megavex.scoreboardlibrary.testplugin;
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import net.megavex.scoreboardlibrary.api.ScoreboardLibrary;
|
||||
import net.megavex.scoreboardlibrary.api.exception.NoPacketAdapterAvailableException;
|
||||
import net.megavex.scoreboardlibrary.implementation.packetAdapter.modern.util.ModernComponentProvider;
|
||||
import net.megavex.scoreboardlibrary.testplugin.module.Module;
|
||||
import net.megavex.scoreboardlibrary.testplugin.module.ObjectivesModule;
|
||||
import net.megavex.scoreboardlibrary.testplugin.module.SidebarModule;
|
||||
@@ -79,7 +78,14 @@ public final class ScoreboardPlugin extends JavaPlugin implements Listener {
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.sendMessage("Server software: " + this.getServer().getName());
|
||||
player.sendMessage("Server version: " + this.getServer().getVersion());
|
||||
player.sendMessage("Is native adventure: " + ModernComponentProvider.IS_NATIVE_ADVENTURE);
|
||||
|
||||
boolean isNativeAdventure = false;
|
||||
try {
|
||||
Class.forName("io.papermc.paper.adventure.AdventureComponent");
|
||||
isNativeAdventure = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
player.sendMessage("Is native adventure: " + isNativeAdventure);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
Reference in new issue
Block a user