Compare commits

...
12 Commits
Author SHA1 Message Date
vytskalt 2ca874346d release: 2.3.1 2025-05-04 19:29:04 +03:00
vytskalt cb08e5d3d9 Merge remote-tracking branch 'origin/main' 2025-04-26 23:53:16 +03:00
vytskalt eecde934a8 setup snapshot 2025-04-26 23:52:50 +03:00
vytskalt 2a070cdc3d remove transitive dependency on spigot-api 2025-04-26 23:52:11 +03:00
vytskalt 589ab095b2 [ci skip] Update INSTALLATION.md 2025-04-21 19:52:18 +03:00
vytskalt 41fb8aa4aa Update INSTALLATION.md 2025-04-21 19:43:22 +03:00
vytskalt da69391930 release: 2.3.0 2025-04-12 19:31:35 +03:00
vytskalt 47ef9a8143 update junit platform launcher 2025-04-12 19:27:25 +03:00
vytskalt ccf9aad96d update dependencies 2025-04-12 19:23:17 +03:00
vytskalt facb3a4d1c allow getting/setting sidebar objective name 2025-04-03 21:42:29 +03:00
vytskalt f41c1ce0b1 1.21.5 2025-03-27 19:59:49 +02:00
vytskalt e72d442f9b upgrade to gradle 8.13 2025-03-27 18:44:23 +02:00
32 changed files with 141 additions and 54 deletions

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/install-nix-action@v31
- name: Cache Gradle
uses: actions/cache@v4
with:
+3 -3
View File
@@ -1,6 +1,6 @@
# Installation
Latest version: `2.2.2`
Latest version: `2.3.1`
## Gradle
@@ -29,12 +29,12 @@ dependencies {
// 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.0.1")
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
}
```
You will need to shade these dependencies and relocate them with something
like [Shadow](https://imperceptiblethoughts.com/shadow/).
like [Shadow](https://gradleup.com/shadow/).
## Maven
+1 -1
View File
@@ -23,7 +23,7 @@ Join the [Discord](https://discord.gg/v7nmTDTW8W) or create an issue for support
## Available Packet Adapters
- **modern.** Supports 1.17-1.21.4. Can take advantage of [Paper](https://papermc.io)'s native adventure support to be more efficient.
- **modern.** Supports 1.17-1.21.5. Can take advantage of [Paper](https://papermc.io)'s native adventure support to be more efficient.
- **legacy.** Supports 1.7.10-1.12.2.
- **PacketEvents.** Supports 1.8+. Requires [PacketEvents 2.0](https://github.com/retrooper/packetevents/tree/2.0) to be shaded or installed as a plugin.
+5
View File
@@ -1,3 +1,8 @@
plugins {
id("net.megavex.scoreboardlibrary.base-conventions")
}
dependencies {
compileOnlyApi(libs.bundles.adventure)
compileOnly(libs.spigotApi)
}
@@ -5,6 +5,7 @@ import net.megavex.scoreboardlibrary.api.noop.NoopScoreboardLibrary;
import net.megavex.scoreboardlibrary.api.objective.ObjectiveManager;
import net.megavex.scoreboardlibrary.api.sidebar.Sidebar;
import net.megavex.scoreboardlibrary.api.team.TeamManager;
import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.ApiStatus;
@@ -56,7 +57,7 @@ public interface ScoreboardLibrary {
* @return newly created sidebar
*/
default @NotNull Sidebar createSidebar() {
return createSidebar(Sidebar.MAX_LINES, null);
return createSidebar(Sidebar.MAX_LINES);
}
/**
@@ -79,7 +80,21 @@ public interface ScoreboardLibrary {
* or null if the locale should depend on the player
* @return newly created sidebar
*/
@NotNull Sidebar createSidebar(@Range(from = 1, to = Integer.MAX_VALUE) int maxLines, @Nullable Locale locale);
default @NotNull Sidebar createSidebar(@Range(from = 1, to = Integer.MAX_VALUE) int maxLines, @Nullable Locale locale) {
return createSidebar(maxLines, locale, RandomStringUtils.randomAlphanumeric(16));
}
/**
* Creates a new {@link Sidebar}.
*
* @param maxLines max amount of lines the sidebar will have.
* Note that vanilla clients can only display at most {@value Sidebar#MAX_LINES}
* @param locale locale which will be used for translating {@link net.kyori.adventure.text.TranslatableComponent}s,
* or null if the locale should depend on the player
* @param objectiveName objective name the sidebar should use
* @return newly created sidebar
*/
@NotNull Sidebar createSidebar(@Range(from = 1, to = Integer.MAX_VALUE) int maxLines, @Nullable Locale locale, @NotNull String objectiveName);
/**
* Creates a new {@link TeamManager}.
@@ -19,9 +19,9 @@ public final class NoopScoreboardLibrary implements ScoreboardLibrary {
private boolean closed = false;
@Override
public @NotNull Sidebar createSidebar(@Range(from = 1, to = Sidebar.MAX_LINES) int maxLines, @Nullable Locale locale) {
public @NotNull Sidebar createSidebar(@Range(from = 1, to = Integer.MAX_VALUE) int maxLines, @Nullable Locale locale, @NotNull String objectiveName) {
checkClosed();
return new NoopSidebar(maxLines, locale);
return new NoopSidebar(maxLines, objectiveName, locale);
}
@Override
@@ -17,14 +17,16 @@ import static net.kyori.adventure.text.Component.empty;
class NoopSidebar implements Sidebar {
private final Set<Player> players = new HashSet<>();
private final int maxLines;
private final String objectiveName;
private final Locale locale;
private final Component[] lines;
private Component title = empty();
private boolean closed;
NoopSidebar(int maxLines, @Nullable Locale locale) {
NoopSidebar(int maxLines, String objectiveName, @Nullable Locale locale) {
this.maxLines = maxLines;
this.locale = locale;
this.objectiveName = objectiveName;
this.lines = new Component[maxLines];
}
@@ -62,6 +64,11 @@ class NoopSidebar implements Sidebar {
return maxLines;
}
@Override
public @NotNull String objectiveName() {
return objectiveName;
}
@Override
public @Nullable Locale locale() {
return locale;
@@ -33,6 +33,11 @@ public interface Sidebar {
*/
@Range(from = 1, to = Integer.MAX_VALUE) int maxLines();
/**
* @return objective name used by this sidebar
*/
@NotNull String objectiveName();
/**
* @return locale which is used for translating {@link net.kyori.adventure.text.TranslatableComponent}s,
* or null if it depends on each player's client locale.
+1 -1
View File
@@ -1,5 +1,5 @@
allprojects {
version = "2.2.2"
version = "2.3.1"
group = "net.megavex"
description = "Powerful packet-level scoreboard library for Paper/Spigot servers"
}
@@ -19,13 +19,10 @@ repositories {
}
dependencies {
compileOnly(libs.spigotApi)
compileOnly(libs.bundles.adventure)
testImplementation(libs.spigotApi)
testImplementation(libs.bundles.adventure)
testImplementation(libs.junitJupiterApi)
testRuntimeOnly(libs.junitJupiterEngine)
testImplementation(libs.junitJupiter)
testRuntimeOnly(libs.junitPlatformLauncher)
}
indra {
+1
View File
@@ -4,4 +4,5 @@ plugins {
dependencies {
api(project(":scoreboard-library-api"))
compileOnly(libs.spigotApi)
}
+1
View File
@@ -12,6 +12,7 @@ kotlin {
dependencies {
api(project(":scoreboard-library-api"))
testImplementation(kotlin("test"))
compileOnly(libs.spigotApi)
}
tasks.withType<KotlinCompile>().configureEach {
+7 -8
View File
@@ -1,11 +1,10 @@
[versions]
adventure = "4.17.0"
junitJupiter = "5.11.3"
devBundle = "1.21.4-R0.1-20241208.061653-9" # find latest here: https://repo.papermc.io/repository/maven-snapshots/io/papermc/paper/dev-bundle/1.21.4-R0.1-SNAPSHOT/maven-metadata.xml
adventure = "4.20.0"
devBundle = "1.21.5-R0.1-20250412.153935-1" # find latest here: https://repo.papermc.io/repository/maven-snapshots/io/papermc/paper/dev-bundle/1.21.5-R0.1-SNAPSHOT/maven-metadata.xml
[libraries]
spigotApi = "org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" # do not update
packetEvents = "com.github.retrooper:packetevents-spigot:2.6.0"
packetEvents = "com.github.retrooper:packetevents-spigot:2.7.0"
buildIndra = { module = "net.kyori:indra-common", version = "3.1.3" }
buildNmcp = "com.gradleup.nmcp:com.gradleup.nmcp.gradle.plugin:0.0.9"
@@ -13,12 +12,12 @@ adventureApi = { module = "net.kyori:adventure-api", version.ref = "adventure" }
adventureTextSerializerGson = { module = "net.kyori:adventure-text-serializer-gson", version.ref = "adventure" }
adventureTextSerializerLegacy = { module = "net.kyori:adventure-text-serializer-legacy", version.ref = "adventure" }
junitJupiterApi = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiter" }
junitJupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiter" }
junitJupiter = "org.junit.jupiter:junit-jupiter:5.12.2"
junitPlatformLauncher = "org.junit.platform:junit-platform-launcher:1.12.2"
[plugins]
kotlin = "org.jetbrains.kotlin.jvm:2.1.0"
paperweight = "io.papermc.paperweight.userdev:1.7.7"
kotlin = "org.jetbrains.kotlin.jvm:2.1.20"
paperweight = "io.papermc.paperweight.userdev:2.0.0-beta.16"
[bundles]
adventure = [ "adventureApi", "adventureTextSerializerGson", "adventureTextSerializerLegacy" ]
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -3
View File
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
+1
View File
@@ -5,4 +5,5 @@ plugins {
dependencies {
api(project(":scoreboard-library-api"))
implementation(project(":scoreboard-library-packet-adapter-base"))
compileOnly(libs.spigotApi)
}
@@ -90,6 +90,7 @@ public final class PacketAdapterLoader {
case "1.21.2":
case "1.21.3":
case "1.21.4":
case "1.21.5":
return tryLoadImplementationClass(MODERN);
default:
// Hide from relocation checkers
@@ -90,7 +90,7 @@ public class ScoreboardLibraryImpl implements ScoreboardLibrary {
}
@Override
public @NotNull Sidebar createSidebar(int maxLines, @Nullable Locale locale) {
public @NotNull Sidebar createSidebar(int maxLines, @Nullable Locale locale, @NotNull String objectiveName) {
checkClosed();
if (maxLines <= 0) {
@@ -99,9 +99,9 @@ public class ScoreboardLibraryImpl implements ScoreboardLibrary {
AbstractSidebar sidebar;
if (locale == null) {
sidebar = new PlayerDependantLocaleSidebar(this, maxLines);
sidebar = new PlayerDependantLocaleSidebar(this, maxLines, objectiveName);
} else {
sidebar = new SingleLocaleSidebar(this, maxLines, locale);
sidebar = new SingleLocaleSidebar(this, maxLines, objectiveName, locale);
}
sidebars().add(sidebar);
@@ -17,7 +17,6 @@ import net.megavex.scoreboardlibrary.implementation.player.PlayerDisplayable;
import net.megavex.scoreboardlibrary.implementation.player.ScoreboardLibraryPlayer;
import net.megavex.scoreboardlibrary.implementation.sidebar.line.GlobalLineInfo;
import net.megavex.scoreboardlibrary.implementation.sidebar.line.LocaleLineHandler;
import org.apache.commons.lang.RandomStringUtils;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,10 +41,8 @@ public abstract class AbstractSidebar implements Sidebar, PlayerDisplayable {
private final Queue<SidebarTask> taskQueue = new ConcurrentLinkedQueue<>();
public AbstractSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int maxLines) {
public AbstractSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int maxLines, @NotNull String objectiveName) {
this.scoreboardLibrary = scoreboardLibrary;
String objectiveName = RandomStringUtils.randomAlphanumeric(16);
this.packetAdapter = scoreboardLibrary.packetAdapter().createObjectiveAdapter(objectiveName);
this.lines = new GlobalLineInfo[maxLines];
}
@@ -107,6 +104,11 @@ public abstract class AbstractSidebar implements Sidebar, PlayerDisplayable {
return lines.length;
}
@Override
public @NotNull String objectiveName() {
return packetAdapter.objectiveName();
}
@Override
public final void line(@Range(from = 0, to = MAX_LINES - 1) int index, @Nullable ComponentLike value, @Nullable ScoreFormat scoreFormat) {
checkClosed();
@@ -17,8 +17,8 @@ public class PlayerDependantLocaleSidebar extends AbstractSidebar {
private final Map<Player, LocaleLineHandler> playerMap = new HashMap<>();
private final Map<Locale, LocaleLineHandler> localeMap = new HashMap<>();
public PlayerDependantLocaleSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int maxLines) {
super(scoreboardLibrary, maxLines);
public PlayerDependantLocaleSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int maxLines, @NotNull String objectiveName) {
super(scoreboardLibrary, maxLines, objectiveName);
}
@Override
@@ -16,8 +16,8 @@ public class SingleLocaleSidebar extends AbstractSidebar {
private final LocaleLineHandler sidebar;
private final Set<Player> internalPlayers;
public SingleLocaleSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int size, @NotNull Locale locale) {
super(scoreboardLibrary, size);
public SingleLocaleSidebar(@NotNull ScoreboardLibraryImpl scoreboardLibrary, int size, @NotNull String objectiveName, @NotNull Locale locale) {
super(scoreboardLibrary, size, objectiveName);
this.locale = locale;
this.sidebar = new LocaleLineHandler(this, locale);
this.internalPlayers = CollectionProvider.set(8);
+1
View File
@@ -4,4 +4,5 @@ plugins {
dependencies {
compileOnly(project(":scoreboard-library-packet-adapter-base"))
compileOnly(libs.spigotApi)
}
@@ -26,6 +26,11 @@ public class ObjectivePacketAdapterImpl implements ObjectivePacketAdapter {
this.objectiveName = objectiveName;
}
@Override
public @NotNull String objectiveName() {
return objectiveName;
}
@Override
public void display(@NotNull Collection<Player> players, @NotNull ObjectiveDisplaySlot slot) {
Object packet = PacketAccessors.DISPLAY_OBJECTIVE_CONSTRUCTOR.invoke();
+7 -1
View File
@@ -4,7 +4,9 @@ plugins {
}
dependencies {
compileOnly(project(":scoreboard-library-packet-adapter-base"))
compileOnly(project(":scoreboard-library-packet-adapter-base")) {
exclude(group = "org.spigotmc", module = "spigot-api")
}
paperweight.paperDevBundle(libs.versions.devBundle.get())
}
@@ -23,6 +25,10 @@ tasks {
assemble {
dependsOn(reobfJar)
}
javadoc {
exclude("**")
}
}
java {
@@ -13,6 +13,7 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.network.protocol.game.ClientboundSetScorePacket;
import net.minecraft.server.ServerScoreboard;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.Team;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
import java.util.Collection;
@@ -44,6 +45,26 @@ public final class PacketAccessors {
}
IS_1_20_5_OR_ABOVE = is1_20_5OrAbove;
boolean is1_21_5OrAbove = false;
try {
Class.forName("net.minecraft.world.item.component.BlocksAttacks"); // Random 1.21.5 class
is1_21_5OrAbove = true;
} catch (ClassNotFoundException ignored) {
}
IS_1_21_5_OR_ABOVE = is1_21_5OrAbove;
if (is1_21_5OrAbove) {
NAME_TAG_VISIBILITY_FIELD_1_21_5 = ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 0, Team.Visibility.class);
COLLISION_RULE_FIELD_1_21_5 = ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 0, Team.CollisionRule.class);
NAME_TAG_VISIBILITY_FIELD_1_21_4 = null;
COLLISION_RULE_FIELD_1_21_4 = null;
} else {
NAME_TAG_VISIBILITY_FIELD_1_21_4 = ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 0, String.class);
COLLISION_RULE_FIELD_1_21_4 = ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 1, String.class);
NAME_TAG_VISIBILITY_FIELD_1_21_5 = null;
COLLISION_RULE_FIELD_1_21_5 = null;
}
if (is1_20_5OrAbove) {
OBJECTIVE_NUMBER_FORMAT_FIELD = ReflectUtil.findFieldUnchecked(ClientboundSetObjectivePacket.class, 0, Optional.class);
SCORE_1_20_2_CONSTRUCTOR = null;
@@ -59,7 +80,7 @@ public final class PacketAccessors {
}
}
public static final boolean IS_1_20_2_OR_ABOVE, IS_1_20_3_OR_ABOVE, IS_1_20_5_OR_ABOVE;
public static final boolean IS_1_20_2_OR_ABOVE, IS_1_20_3_OR_ABOVE, IS_1_20_5_OR_ABOVE, IS_1_21_5_OR_ABOVE;
public static final PacketConstructor<ClientboundSetObjectivePacket> OBJECTIVE_PACKET_CONSTRUCTOR =
ReflectUtil.getEmptyConstructor(ClientboundSetObjectivePacket.class);
@@ -92,10 +113,12 @@ public final class PacketAccessors {
ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 1, net.minecraft.network.chat.Component.class);
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, net.minecraft.network.chat.Component> SUFFIX_FIELD =
ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 2, net.minecraft.network.chat.Component.class);
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, String> NAME_TAG_VISIBILITY_FIELD =
ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 0, String.class);
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, String> COLLISION_RULE_FIELD =
ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 1, String.class);
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, String> NAME_TAG_VISIBILITY_FIELD_1_21_4;
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, String> COLLISION_RULE_FIELD_1_21_4;
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, Team.Visibility> NAME_TAG_VISIBILITY_FIELD_1_21_5;
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, Team.CollisionRule> COLLISION_RULE_FIELD_1_21_5;
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, ChatFormatting> COLOR_FIELD =
ReflectUtil.findField(ClientboundSetPlayerTeamPacket.Parameters.class, 0, ChatFormatting.class);
public static final FieldAccessor<ClientboundSetPlayerTeamPacket.Parameters, Integer> OPTIONS_FIELD =
@@ -37,6 +37,11 @@ public abstract class AbstractObjectivePacketAdapter implements ObjectivePacketA
this.objectiveName = objectiveName;
}
@Override
public @NotNull String objectiveName() {
return objectiveName;
}
@Override
public void display(@NotNull Collection<Player> players, @NotNull ObjectiveDisplaySlot slot) {
sender.sendPacket(players, createDisplayPacket(slot));
@@ -14,15 +14,13 @@ import net.minecraft.ChatFormatting;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket.Parameters;
import net.minecraft.world.scores.Team;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.Optional;
import java.util.*;
public abstract class AbstractTeamsPacketAdapterImpl implements TeamsPacketAdapter {
protected final PacketSender<Packet<?>> sender;
@@ -71,11 +69,19 @@ public abstract class AbstractTeamsPacketAdapterImpl implements TeamsPacketAdapt
}
protected void fillParameters(@NotNull Parameters parameters, @UnknownNullability Locale locale) {
String nameTagVisibilityKey = properties.nameTagVisibility().key();
PacketAccessors.NAME_TAG_VISIBILITY_FIELD.set(parameters, nameTagVisibilityKey);
if (PacketAccessors.IS_1_21_5_OR_ABOVE) {
Objects.requireNonNull(PacketAccessors.NAME_TAG_VISIBILITY_FIELD_1_21_5)
.set(parameters, Team.Visibility.valueOf(properties.nameTagVisibility().name()));
String collisionRuleKey = properties.collisionRule().key();
PacketAccessors.COLLISION_RULE_FIELD.set(parameters, collisionRuleKey);
Objects.requireNonNull(PacketAccessors.COLLISION_RULE_FIELD_1_21_5)
.set(parameters, Team.CollisionRule.valueOf(properties.collisionRule().name()));
} else {
Objects.requireNonNull(PacketAccessors.NAME_TAG_VISIBILITY_FIELD_1_21_4)
.set(parameters, properties.nameTagVisibility().key());
Objects.requireNonNull(PacketAccessors.COLLISION_RULE_FIELD_1_21_4)
.set(parameters, properties.collisionRule().key());
}
char legacyChar = LegacyFormatUtil.getChar(properties.playerColor());
PacketAccessors.COLOR_FIELD.set(parameters, ChatFormatting.getByCode(legacyChar));
@@ -5,4 +5,5 @@ plugins {
dependencies {
api(project(":scoreboard-library-api"))
api(project(":scoreboard-library-commons"))
compileOnly(libs.spigotApi)
}
@@ -12,6 +12,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collection;
public interface ObjectivePacketAdapter {
@NotNull String objectiveName();
void display(@NotNull Collection<Player> players, @NotNull ObjectiveDisplaySlot slot);
void sendProperties(
+1
View File
@@ -9,4 +9,5 @@ repositories {
dependencies {
compileOnly(project(":scoreboard-library-packet-adapter-base"))
compileOnly(libs.packetEvents)
compileOnly(libs.spigotApi)
}
@@ -2,7 +2,6 @@ package net.megavex.scoreboardlibrary.implementation.packetAdapter.packetevents;
import com.github.retrooper.packetevents.PacketEventsAPI;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDisplayScoreboard;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerResetScore;
@@ -38,6 +37,11 @@ public class ObjectivePacketAdapterImpl implements ObjectivePacketAdapter {
this.objectiveName = objectiveName;
}
@Override
public @NotNull String objectiveName() {
return objectiveName;
}
@Override
public void display(@NotNull Collection<Player> players, @NotNull ObjectiveDisplaySlot slot) {
WrapperPlayServerDisplayScoreboard packet = new WrapperPlayServerDisplayScoreboard(ObjectiveConstants.displaySlotIndex(slot), objectiveName);