Skip to content
Closed

Dev #130

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Join the [Discord](https://discord.gg/v7nmTDTW8W) or create an issue for support

## Supported server versions

All Paper and Spigot versions from 1.7.10 to 1.21.11 are natively supported.
All Paper and Spigot versions from 1.7.10 to 26.1 are natively supported.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
allprojects {
version = "2.7.0"
version = "2.7.1-SNAPSHOT"
group = "net.megavex"
description = "Powerful packet-level scoreboard library for Paper/Spigot servers"
}
8 changes: 0 additions & 8 deletions commons/build.gradle.kts

This file was deleted.

This file was deleted.

11 changes: 8 additions & 3 deletions implementation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plugins {
id("net.megavex.scoreboardlibrary.base-conventions")
//id("io.papermc.paperweight.userdev") version "2.0.0-beta.19"
}

repositories {
maven("https://repo.viaversion.com")
}

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"))
compileOnly("com.viaversion:viaversion-api:5.7.1")
compileOnly("io.netty:netty-buffer:4.2.10.Final")
compileOnly("io.netty:netty-handler:4.2.10.Final")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.lang.reflect.InvocationTargetException;

public final class PacketAdapterLoader {
private static final String MODERN = "modern", LEGACY = "legacy";

private PacketAdapterLoader() {
}

Expand Down Expand Up @@ -61,7 +59,11 @@ private PacketAdapterLoader() {
case "1.12":
case "1.12.1":
case "1.12.2":
return tryLoadImplementationClass(LEGACY);
try {
return Class.forName("net.megavex.scoreboardlibrary.implementation.packetAdapter.legacy.PacketAdapterProviderImpl");
} catch (ClassNotFoundException ignored) {
return null;
}
case "1.13":
case "1.13.1":
case "1.13.2":
Expand Down Expand Up @@ -108,22 +110,22 @@ private PacketAdapterLoader() {
case "1.21.9":
case "1.21.10":
case "1.21.11":
return tryLoadImplementationClass(MODERN);
case "26.1":
return tryLoadModern();
default:
// Hide from relocation checkers
String property = "net.mega".concat("vex.scoreboardlibrary.forceModern");
if (System.getProperty(property, "").equalsIgnoreCase("true")) {
return tryLoadImplementationClass(MODERN);
return tryLoadModern();
}

return null;
}
}

private static @Nullable Class<?> tryLoadImplementationClass(@NotNull String name) {
private static Class<?> tryLoadModern() {
try {
String path = "net.megavex.scoreboardlibrary.implementation.packetAdapter." + name + ".PacketAdapterProviderImpl";
return Class.forName(path);
return Class.forName("net.megavex.scoreboardlibrary.implementation.packetAdapter.modern.PacketAdapterProviderImpl");
} catch (ClassNotFoundException ignored) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class ScoreboardLibraryImpl implements ScoreboardLibrary {
public final class ScoreboardLibraryImpl implements ScoreboardLibrary {
private final Plugin plugin;
private final PacketAdapterProvider packetAdapter;
private final TaskScheduler taskScheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.ChatColor;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
Expand All @@ -21,7 +22,7 @@ public final class LegacyFormatUtil {

static {
ChatColor[] values = ChatColor.values();
chatColorMap = CollectionProvider.map(values.length);
chatColorMap = new HashMap<>(values.length);
for (ChatColor value : values) {
if (!value.isColor()) continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum LineRenderingStrategy {
*/
LEGACY,
/**
* For versions 1.13-1.20.2, where team properties are stored as components with no limits.
* For versions 1.13+, where team properties are stored as components with no limits.
*/
MODERN,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

public final class LocaleProvider {
private static final Locale DEFAULT_LOCALE = Locale.US;
private static final Function<Player, Locale> provider = get();
private static final Function<Player, Locale> PROVIDER = get();

private LocaleProvider() {
}

public static @NotNull Locale locale(Player player) {
return provider.apply(player);
return PROVIDER.apply(player);
}

private static @NotNull Function<Player, Locale> get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.megavex.scoreboardlibrary.api.objective.ObjectiveScore;
import net.megavex.scoreboardlibrary.api.objective.ScoreboardObjective;
import net.megavex.scoreboardlibrary.implementation.ScoreboardLibraryImpl;
import net.megavex.scoreboardlibrary.implementation.commons.CollectionProvider;
import net.megavex.scoreboardlibrary.implementation.packetAdapter.PropertiesPacketType;
import net.megavex.scoreboardlibrary.implementation.packetAdapter.objective.ObjectivePacketAdapter;
import net.megavex.scoreboardlibrary.implementation.player.PlayerDisplayable;
Expand All @@ -19,13 +18,13 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

public class ObjectiveManagerImpl implements ObjectiveManager, PlayerDisplayable {
public final class ObjectiveManagerImpl implements ObjectiveManager, PlayerDisplayable {
private final ScoreboardLibraryImpl library;
private final Map<String, ScoreboardObjectiveImpl> objectives = new ConcurrentHashMap<>();
private final Map<ObjectiveDisplaySlot, ScoreboardObjectiveImpl> displaySlots = new HashMap<>();

private final Set<Player> players = CollectionProvider.set(8);
private final Set<Player> displayingPlayers = CollectionProvider.set(8);
private final Set<Player> players = new HashSet<>(8);
private final Set<Player> displayingPlayers = new HashSet<>(8);
private final Queue<ObjectiveManagerTask> taskQueue = new ConcurrentLinkedQueue<>();
private boolean closed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Iterator;
import java.util.logging.Level;

public class ObjectiveUpdaterTask implements Runnable {
public final class ObjectiveUpdaterTask implements Runnable {
private final ScoreboardLibraryImpl scoreboardLibrary;
private final RunningTask task;
private final Object lock = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static net.kyori.adventure.text.Component.empty;

public class ScoreboardObjectiveImpl implements ScoreboardObjective {
public final class ScoreboardObjectiveImpl implements ScoreboardObjective {
private final ObjectivePacketAdapter packetAdapter;
private final Queue<ObjectiveManagerTask> taskQueue;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection;

public class ObjectivePacketAdapterImpl implements ObjectivePacketAdapter {
public final class ObjectivePacketAdapterImpl implements ObjectivePacketAdapter {
private final String objectiveName;
private Object removePacket;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
public class PacketAdapterProviderImpl implements PacketAdapterProvider {
public final class PacketAdapterProviderImpl implements PacketAdapterProvider {
public PacketAdapterProviderImpl(Plugin plugin) {}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static net.megavex.scoreboardlibrary.implementation.commons.LegacyFormatUtil.limitLegacyText;

public class TeamsPacketAdapterImpl implements TeamsPacketAdapter {
public final class TeamsPacketAdapterImpl implements TeamsPacketAdapter {
private final String teamName;
private Object removePacket;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.WeakHashMap;

@SuppressWarnings("unused")
public class PacketAdapterProviderImpl implements PacketAdapterProvider {
public final class PacketAdapterProviderImpl implements PacketAdapterProvider {
private final ViaAPI<Player> via;
private final ModernPacketSender packetSender;
private final WeakHashMap<Player, Integer> viaTeamPacketIds = new WeakHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.Collection;

public class PaperObjectivePacketAdapter extends AbstractObjectivePacketAdapter {
public final class PaperObjectivePacketAdapter extends AbstractObjectivePacketAdapter {
public PaperObjectivePacketAdapter(@NotNull PacketAdapterProviderImpl provider, @NotNull String objectiveName) {
super(provider, objectiveName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.Collection;

public class SpigotObjectivePacketAdapter extends AbstractObjectivePacketAdapter {
public final class SpigotObjectivePacketAdapter extends AbstractObjectivePacketAdapter {
public SpigotObjectivePacketAdapter(@NotNull PacketAdapterProviderImpl provider, @NotNull String objectiveName) {
super(provider, objectiveName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Locale;
import java.util.Optional;

public class PaperTeamsPacketAdapterImpl extends AbstractTeamsPacketAdapterImpl {
public final class PaperTeamsPacketAdapterImpl extends AbstractTeamsPacketAdapterImpl {
public PaperTeamsPacketAdapterImpl(PacketAdapterProviderImpl provider, @NotNull String teamName) {
super(provider, teamName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Locale;
import java.util.Optional;

public class SpigotTeamsPacketAdapter extends AbstractTeamsPacketAdapterImpl {
public final class SpigotTeamsPacketAdapter extends AbstractTeamsPacketAdapterImpl {
public SpigotTeamsPacketAdapter(PacketAdapterProviderImpl provider, @NotNull String teamName) {
super(provider, teamName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package net.megavex.scoreboardlibrary.implementation.packetAdapter.util;

import net.megavex.scoreboardlibrary.implementation.commons.CollectionProvider;
import net.megavex.scoreboardlibrary.implementation.commons.LocaleProvider;
import net.megavex.scoreboardlibrary.implementation.packetAdapter.PacketSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
Expand All @@ -31,7 +31,7 @@ public static <P> void sendLocalePackets(
return;
}

Map<Locale, P> map = CollectionProvider.map(1);
Map<Locale, P> map = new HashMap<>(1);
for (Player player : players) {
Locale locale = LocaleProvider.locale(player);
P packet = map.computeIfAbsent(locale, i -> packetFunction.apply(locale));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.lang.invoke.MethodHandle;

public class ConstructorAccessor<T> {
public final class ConstructorAccessor<T> {
private final MethodHandle handle;

public ConstructorAccessor(@NotNull MethodHandle handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.lang.invoke.MethodHandle;

public class FieldAccessor<T, V> {
public final class FieldAccessor<T, V> {
private final MethodHandle getter, setter;

public FieldAccessor(@NotNull MethodHandle getter, @Nullable MethodHandle setter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.lang.invoke.MethodHandle;

public class MethodAccessor {
public final class MethodAccessor {
private final MethodHandle handle;

public MethodAccessor(@NotNull MethodHandle handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class ReflectUtil {
public final class ReflectUtil {
// Inspired by
// https://github.com/dmulloy2/ProtocolLib/blob/02e917cd08cf5b37a52052e22b223272a040e0df/src/main/java/com/comphenix/protocol/reflect/accessors/MethodHandleHelper.java

Expand Down
Loading
Loading