final class
This commit is contained in:
1 parent
36a0ef0dfd
commit
cd53aaf8e3
36 files changed
+40
-37
No files matched your search
+1
-1
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
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;
|
||||
|
||||
+1
-1
@@ -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,
|
||||
/**
|
||||
|
||||
+5
-2
@@ -12,10 +12,13 @@ import java.util.function.Function;
|
||||
|
||||
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() {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
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<>();
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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();
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import java.util.*;
|
||||
|
||||
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;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import java.util.Collection;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PacketAdapterProviderImpl implements PacketAdapterProvider {
|
||||
public final class PacketAdapterProviderImpl implements PacketAdapterProvider {
|
||||
public PacketAdapterProviderImpl(Plugin plugin) {}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.Locale;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
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<>();
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import java.util.Collection;
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import java.util.Collection;
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.UnknownNullability;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
public class ConstructorAccessor<T> {
|
||||
public final class ConstructorAccessor<T> {
|
||||
private final MethodHandle handle;
|
||||
|
||||
public ConstructorAccessor(@NotNull MethodHandle handle) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.UnknownNullability;
|
||||
|
||||
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) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.UnknownNullability;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
public class MethodAccessor {
|
||||
public final class MethodAccessor {
|
||||
private final MethodHandle handle;
|
||||
|
||||
public MethodAccessor(@NotNull MethodHandle handle) {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.lang.invoke.MethodType;
|
||||
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
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DisplayableQueue<T extends PlayerDisplayable> {
|
||||
public final class DisplayableQueue<T extends PlayerDisplayable> {
|
||||
private final UUID playerUuid;
|
||||
private final List<T> queue = new ArrayList<>(1);
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLocaleChangeEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LocaleListener implements Listener {
|
||||
public final class LocaleListener implements Listener {
|
||||
private final ScoreboardLibraryImpl scoreboardLibrary;
|
||||
|
||||
public LocaleListener(@NotNull ScoreboardLibraryImpl scoreboardLibrary) {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ScoreboardLibraryPlayer {
|
||||
public final class ScoreboardLibraryPlayer {
|
||||
private final DisplayableQueue<TeamManagerImpl> teamManagerQueue;
|
||||
private final DisplayableQueue<ObjectiveManagerImpl> objectiveManagerQueue;
|
||||
private final DisplayableQueue<AbstractSidebar> sidebarQueue;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package net.megavex.scoreboardlibrary.implementation.scheduler;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class BukkitTaskScheduler implements TaskScheduler {
|
||||
final class BukkitTaskScheduler implements TaskScheduler {
|
||||
private final Plugin plugin;
|
||||
|
||||
public BukkitTaskScheduler(@NotNull Plugin plugin) {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.lang.invoke.MethodType;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class FoliaTaskScheduler implements TaskScheduler {
|
||||
final class FoliaTaskScheduler implements TaskScheduler {
|
||||
private static final Class<?> asyncSchedulerClass;
|
||||
private static final Class<?> scheduledTaskClass;
|
||||
private static final Class<?> cancelledStateClass;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class PlayerDependantLocaleSidebar extends AbstractSidebar {
|
||||
public final class PlayerDependantLocaleSidebar extends AbstractSidebar {
|
||||
private final Map<Player, LocaleLineHandler> playerMap = new HashMap<>();
|
||||
private final Map<Locale, LocaleLineHandler> localeMap = new HashMap<>();
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SidebarUpdaterTask implements Runnable {
|
||||
public final class SidebarUpdaterTask implements Runnable {
|
||||
private final ScoreboardLibraryImpl scoreboardLibrary;
|
||||
private final RunningTask task;
|
||||
private final Object lock = new Object();
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class SingleLocaleSidebar extends AbstractSidebar {
|
||||
public final class SingleLocaleSidebar extends AbstractSidebar {
|
||||
private final Locale locale;
|
||||
private final LocaleLineHandler sidebar;
|
||||
private final Set<Player> internalPlayers = new HashSet<>(8);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import net.megavex.scoreboardlibrary.implementation.sidebar.AbstractSidebar;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GlobalLineInfo {
|
||||
public final class GlobalLineInfo {
|
||||
private final String player;
|
||||
private final int line;
|
||||
private final TeamsPacketAdapter packetAdapter;
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleLineHandler {
|
||||
public final class LocaleLineHandler {
|
||||
private final AbstractSidebar sidebar;
|
||||
private final Locale locale;
|
||||
private final SidebarLineHandler[] lineHandlers;
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SidebarLineHandler {
|
||||
public final class SidebarLineHandler {
|
||||
private final LineRenderingStrategy strategy;
|
||||
private final LocaleLineHandler localeLineHandler;
|
||||
private final Set<Player> players = new HashSet<>(1);
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import java.util.Set;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection;
|
||||
|
||||
// Implementation for versions below 1.13
|
||||
public class LegacyLocaleLine implements LocaleLine, ImmutableTeamProperties<String> {
|
||||
public final class LegacyLocaleLine implements LocaleLine, ImmutableTeamProperties<String> {
|
||||
private final GlobalLineInfo info;
|
||||
private final SidebarLineHandler handler;
|
||||
private final TeamDisplayPacketAdapter packetAdapter;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import java.util.Collection;
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
|
||||
// Implementation for versions above 1.13
|
||||
public class ModernLocaleLine implements LocaleLine, ImmutableTeamProperties<Component> {
|
||||
public final class ModernLocaleLine implements LocaleLine, ImmutableTeamProperties<Component> {
|
||||
private final GlobalLineInfo info;
|
||||
private final SidebarLineHandler handler;
|
||||
private final Collection<String> entries;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
// Implementation for versions 1.20.3+
|
||||
// This is not yet being used as it might break on servers with plugins such as ViaBackwards,
|
||||
// however it will once Mojang decides to remove legacy chat format support
|
||||
public class PostModernLocaleLine implements LocaleLine {
|
||||
public final class PostModernLocaleLine implements LocaleLine {
|
||||
private final GlobalLineInfo info;
|
||||
private final SidebarLineHandler handler;
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ScoreboardTeamImpl implements ScoreboardTeam {
|
||||
public final class ScoreboardTeamImpl implements ScoreboardTeam {
|
||||
private final TeamManagerImpl teamManager;
|
||||
private final String name;
|
||||
private final TeamsPacketAdapter packetAdapter;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import java.util.*;
|
||||
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
|
||||
public class TeamDisplayImpl implements TeamDisplay, ImmutableTeamProperties<Component> {
|
||||
public final class TeamDisplayImpl implements TeamDisplay, ImmutableTeamProperties<Component> {
|
||||
private final ScoreboardTeamImpl team;
|
||||
private final TeamDisplayPacketAdapter packetAdapter;
|
||||
private final Set<Player> players = new HashSet<>(4);
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class TeamManagerImpl implements TeamManager, PlayerDisplayable {
|
||||
public final class TeamManagerImpl implements TeamManager, PlayerDisplayable {
|
||||
private final ScoreboardLibraryImpl scoreboardLibrary;
|
||||
|
||||
private final Set<Player> players = new HashSet<>(8);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TeamUpdaterTask implements Runnable {
|
||||
public final class TeamUpdaterTask implements Runnable {
|
||||
private final ScoreboardLibraryImpl scoreboardLibrary;
|
||||
private final RunningTask task;
|
||||
private final Object lock = new Object();
|
||||
|
||||
Reference in new issue
Block a user