mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-23 10:55:10 +01:00
Rename classes
This commit is contained in:
parent
d97751100e
commit
b7b922fb37
@ -37,7 +37,7 @@ import me.filoghost.holographicdisplays.plugin.listener.UpdateNotificationListen
|
||||
import me.filoghost.holographicdisplays.plugin.log.PrintableErrorCollector;
|
||||
import me.filoghost.holographicdisplays.plugin.tick.TickClock;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.tick.TickingTask;
|
||||
import me.filoghost.holographicdisplays.plugin.util.NMSVersion;
|
||||
import me.filoghost.holographicdisplays.plugin.util.NMSVersion.OutdatedVersionException;
|
||||
@ -104,7 +104,7 @@ public class HolographicDisplays extends FCommonsPlugin {
|
||||
bungeeServerTracker = new BungeeServerTracker(this);
|
||||
placeholderRegistry = new PlaceholderRegistry();
|
||||
TickClock tickClock = new TickClock();
|
||||
PlaceholderTracker placeholderTracker = new PlaceholderTracker(placeholderRegistry, tickClock);
|
||||
ActivePlaceholderTracker placeholderTracker = new ActivePlaceholderTracker(placeholderRegistry, tickClock);
|
||||
LineClickListener lineClickListener = new LineClickListener();
|
||||
lineTrackerManager = new LineTrackerManager(nmsManager, placeholderTracker, lineClickListener);
|
||||
internalHologramManager = new InternalHologramManager(lineTrackerManager);
|
||||
|
@ -9,7 +9,7 @@ import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.holographicdisplays.plugin.bridge.placeholderapi.PlaceholderAPIHook;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.PlaceholderOccurrence;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.parsing.StringWithPlaceholders;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -19,7 +19,7 @@ import java.util.Objects;
|
||||
|
||||
class DisplayText {
|
||||
|
||||
private final PlaceholderTracker placeholderTracker;
|
||||
private final ActivePlaceholderTracker placeholderTracker;
|
||||
|
||||
private @Nullable StringWithPlaceholders unreplacedText;
|
||||
private boolean allowPlaceholders;
|
||||
@ -28,7 +28,7 @@ class DisplayText {
|
||||
private @Nullable Boolean containsIndividualPlaceholders;
|
||||
private long lastPlaceholderRegistryVersion;
|
||||
|
||||
DisplayText(PlaceholderTracker placeholderTracker) {
|
||||
DisplayText(ActivePlaceholderTracker placeholderTracker) {
|
||||
this.placeholderTracker = placeholderTracker;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import me.filoghost.holographicdisplays.nms.common.NMSManager;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseItemHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -20,11 +20,11 @@ import java.util.LinkedList;
|
||||
public class LineTrackerManager {
|
||||
|
||||
private final NMSManager nmsManager;
|
||||
private final PlaceholderTracker placeholderTracker;
|
||||
private final ActivePlaceholderTracker placeholderTracker;
|
||||
private final LineClickListener lineClickListener;
|
||||
private final Collection<LineTracker<?>> lineTrackers;
|
||||
|
||||
public LineTrackerManager(NMSManager nmsManager, PlaceholderTracker placeholderTracker, LineClickListener lineClickListener) {
|
||||
public LineTrackerManager(NMSManager nmsManager, ActivePlaceholderTracker placeholderTracker, LineClickListener lineClickListener) {
|
||||
this.nmsManager = nmsManager;
|
||||
this.placeholderTracker = placeholderTracker;
|
||||
this.lineClickListener = lineClickListener;
|
||||
|
@ -10,7 +10,7 @@ import me.filoghost.holographicdisplays.nms.common.NMSManager;
|
||||
import me.filoghost.holographicdisplays.nms.common.entity.TextNMSPacketEntity;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||
|
||||
@ -28,7 +28,7 @@ public class TextLineTracker extends ClickableLineTracker<TextLineViewer> {
|
||||
BaseTextHologramLine line,
|
||||
NMSManager nmsManager,
|
||||
LineClickListener lineClickListener,
|
||||
PlaceholderTracker placeholderTracker) {
|
||||
ActivePlaceholderTracker placeholderTracker) {
|
||||
super(line, nmsManager, lineClickListener);
|
||||
this.line = line;
|
||||
this.textEntity = nmsManager.newTextPacketEntity();
|
||||
|
@ -10,11 +10,11 @@ import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderE
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
abstract class TrackedPlaceholder {
|
||||
abstract class ActivePlaceholder {
|
||||
|
||||
private final @Nullable PlaceholderExpansion source;
|
||||
|
||||
TrackedPlaceholder(@Nullable PlaceholderExpansion source) {
|
||||
ActivePlaceholder(@Nullable PlaceholderExpansion source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class PlaceholderTracker {
|
||||
public class ActivePlaceholderTracker {
|
||||
|
||||
private final PlaceholderRegistry registry;
|
||||
private final TickClock tickClock;
|
||||
@ -27,11 +27,11 @@ public class PlaceholderTracker {
|
||||
|
||||
// Use WeakHashMap to ensure that when a PlaceholderOccurrence is no longer referenced in other objects
|
||||
// the corresponding entry is removed from the map automatically.
|
||||
private final WeakHashMap<PlaceholderOccurrence, TrackedPlaceholder> activePlaceholders;
|
||||
private final WeakHashMap<PlaceholderOccurrence, ActivePlaceholder> activePlaceholders;
|
||||
|
||||
private long lastRegistryVersion;
|
||||
|
||||
public PlaceholderTracker(PlaceholderRegistry registry, TickClock tickClock) {
|
||||
public ActivePlaceholderTracker(PlaceholderRegistry registry, TickClock tickClock) {
|
||||
this.registry = registry;
|
||||
this.tickClock = tickClock;
|
||||
this.exceptionHandler = new PlaceholderExceptionHandler(tickClock);
|
||||
@ -57,11 +57,11 @@ public class PlaceholderTracker {
|
||||
|
||||
public @Nullable String updateAndGetGlobalReplacement(PlaceholderOccurrence placeholderOccurrence) {
|
||||
try {
|
||||
TrackedPlaceholder trackedPlaceholder = getTrackedPlaceholder(placeholderOccurrence);
|
||||
if (trackedPlaceholder.isIndividual()) {
|
||||
ActivePlaceholder activePlaceholder = trackAndGetPlaceholder(placeholderOccurrence);
|
||||
if (activePlaceholder.isIndividual()) {
|
||||
return null;
|
||||
}
|
||||
return trackedPlaceholder.updateAndGetReplacement(null, tickClock.getCurrentTick());
|
||||
return activePlaceholder.updateAndGetReplacement(null, tickClock.getCurrentTick());
|
||||
} catch (PlaceholderException e) {
|
||||
exceptionHandler.handle(e);
|
||||
return "[Error]";
|
||||
@ -70,26 +70,26 @@ public class PlaceholderTracker {
|
||||
|
||||
public @Nullable String updateAndGetReplacement(PlaceholderOccurrence placeholderOccurrence, Player player) {
|
||||
try {
|
||||
TrackedPlaceholder trackedPlaceholder = getTrackedPlaceholder(placeholderOccurrence);
|
||||
return trackedPlaceholder.updateAndGetReplacement(player, tickClock.getCurrentTick());
|
||||
ActivePlaceholder activePlaceholder = trackAndGetPlaceholder(placeholderOccurrence);
|
||||
return activePlaceholder.updateAndGetReplacement(player, tickClock.getCurrentTick());
|
||||
} catch (PlaceholderException e) {
|
||||
exceptionHandler.handle(e);
|
||||
return "[Error]";
|
||||
}
|
||||
}
|
||||
|
||||
private @NotNull TrackedPlaceholder getTrackedPlaceholder(PlaceholderOccurrence placeholderOccurrence) throws PlaceholderException {
|
||||
TrackedPlaceholder trackedPlaceholder = activePlaceholders.get(placeholderOccurrence);
|
||||
private @NotNull ActivePlaceholder trackAndGetPlaceholder(PlaceholderOccurrence placeholderOccurrence) throws PlaceholderException {
|
||||
ActivePlaceholder activePlaceholder = activePlaceholders.get(placeholderOccurrence);
|
||||
|
||||
if (trackedPlaceholder == null) {
|
||||
trackedPlaceholder = createTrackedPlaceholder(placeholderOccurrence);
|
||||
activePlaceholders.put(placeholderOccurrence, trackedPlaceholder);
|
||||
if (activePlaceholder == null) {
|
||||
activePlaceholder = createActivePlaceholder(placeholderOccurrence);
|
||||
activePlaceholders.put(placeholderOccurrence, activePlaceholder);
|
||||
}
|
||||
|
||||
return trackedPlaceholder;
|
||||
return activePlaceholder;
|
||||
}
|
||||
|
||||
private TrackedPlaceholder createTrackedPlaceholder(PlaceholderOccurrence placeholderOccurrence) throws PlaceholderException {
|
||||
private ActivePlaceholder createActivePlaceholder(PlaceholderOccurrence placeholderOccurrence) throws PlaceholderException {
|
||||
PlaceholderExpansion placeholderExpansion = registry.find(placeholderOccurrence);
|
||||
StandardPlaceholder placeholder;
|
||||
|
||||
@ -100,11 +100,11 @@ public class PlaceholderTracker {
|
||||
}
|
||||
|
||||
if (placeholder == null) {
|
||||
return new TrackedNullPlaceholder(placeholderExpansion);
|
||||
return new NullActivePlaceholder(placeholderExpansion);
|
||||
} else if (placeholder.isIndividual()) {
|
||||
return new TrackedIndividualPlaceholder(placeholder, placeholderOccurrence);
|
||||
return new IndividualActivePlaceholder(placeholder, placeholderOccurrence);
|
||||
} else {
|
||||
return new TrackedGlobalPlaceholder(placeholder, placeholderOccurrence);
|
||||
return new GlobalActivePlaceholder(placeholder, placeholderOccurrence);
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class TrackedGlobalPlaceholder extends TrackedPlaceholder {
|
||||
class GlobalActivePlaceholder extends ActivePlaceholder {
|
||||
|
||||
private final ReplacementHolder replacementHolder;
|
||||
|
||||
TrackedGlobalPlaceholder(@NotNull StandardPlaceholder placeholder, @NotNull PlaceholderOccurrence placeholderOccurrence) {
|
||||
GlobalActivePlaceholder(@NotNull StandardPlaceholder placeholder, @NotNull PlaceholderOccurrence placeholderOccurrence) {
|
||||
super(placeholder.getSource());
|
||||
this.replacementHolder = new ReplacementHolder(placeholder, placeholderOccurrence);
|
||||
}
|
@ -14,13 +14,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
class TrackedIndividualPlaceholder extends TrackedPlaceholder {
|
||||
class IndividualActivePlaceholder extends ActivePlaceholder {
|
||||
|
||||
private final @NotNull StandardPlaceholder placeholder;
|
||||
private final @NotNull PlaceholderOccurrence placeholderOccurrence;
|
||||
private final WeakHashMap<Player, ReplacementHolder> replacementHolderByPlayer;
|
||||
|
||||
TrackedIndividualPlaceholder(@NotNull StandardPlaceholder placeholder, @NotNull PlaceholderOccurrence placeholderOccurrence) {
|
||||
IndividualActivePlaceholder(@NotNull StandardPlaceholder placeholder, @NotNull PlaceholderOccurrence placeholderOccurrence) {
|
||||
super(placeholder.getSource());
|
||||
this.placeholder = placeholder;
|
||||
this.placeholderOccurrence = placeholderOccurrence;
|
@ -9,9 +9,9 @@ import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderE
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class TrackedNullPlaceholder extends TrackedPlaceholder {
|
||||
class NullActivePlaceholder extends ActivePlaceholder {
|
||||
|
||||
TrackedNullPlaceholder(@Nullable PlaceholderExpansion placeholderExpansion) {
|
||||
NullActivePlaceholder(@Nullable PlaceholderExpansion placeholderExpansion) {
|
||||
super(placeholderExpansion);
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ package me.filoghost.holographicdisplays.plugin.tick;
|
||||
import me.filoghost.fcommons.logging.Log;
|
||||
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
|
||||
public class TickingTask implements Runnable {
|
||||
|
||||
private final TickClock tickClock;
|
||||
private final PlaceholderTracker placeholderTracker;
|
||||
private final ActivePlaceholderTracker placeholderTracker;
|
||||
private final LineTrackerManager lineTrackerManager;
|
||||
private final LineClickListener lineClickListener;
|
||||
|
||||
@ -21,7 +21,7 @@ public class TickingTask implements Runnable {
|
||||
|
||||
public TickingTask(
|
||||
TickClock tickClock,
|
||||
PlaceholderTracker placeholderTracker,
|
||||
ActivePlaceholderTracker placeholderTracker,
|
||||
LineTrackerManager lineTrackerManager,
|
||||
LineClickListener lineClickListener) {
|
||||
this.tickClock = tickClock;
|
||||
|
@ -8,14 +8,14 @@ package me.filoghost.holographicdisplays.plugin.test;
|
||||
import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramManager;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||
import me.filoghost.holographicdisplays.plugin.listener.LineClickListener;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.ActivePlaceholderTracker;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class TestV2HologramManager extends V2HologramManager {
|
||||
|
||||
public TestV2HologramManager() {
|
||||
super(new LineTrackerManager(new TestNMSManager(), mock(PlaceholderTracker.class), new LineClickListener()));
|
||||
super(new LineTrackerManager(new TestNMSManager(), mock(ActivePlaceholderTracker.class), new LineClickListener()));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user