diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/api/current/APIHologram.java b/core/src/main/java/me/filoghost/holographicdisplays/core/api/current/APIHologram.java index 82e8bdcf..d690875c 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/api/current/APIHologram.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/api/current/APIHologram.java @@ -12,7 +12,6 @@ import me.filoghost.holographicdisplays.api.beta.hologram.PlaceholderSetting; import me.filoghost.holographicdisplays.core.base.BaseHologram; import me.filoghost.holographicdisplays.core.base.ImmutablePosition; import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -21,7 +20,6 @@ class APIHologram extends BaseHologram implements Hologram { private final APIHologramLines lines; private final Plugin plugin; private final APIHologramManager hologramManager; - private final DefaultVisibilitySettings visibilitySettings; private @NotNull PlaceholderSetting placeholderSetting; @@ -35,7 +33,6 @@ class APIHologram extends BaseHologram implements Hologram { this.lines = new APIHologramLines(this); this.plugin = plugin; this.hologramManager = hologramManager; - this.visibilitySettings = new DefaultVisibilitySettings(); this.placeholderSetting = PlaceholderSetting.DEFAULT; } @@ -44,11 +41,6 @@ class APIHologram extends BaseHologram implements Hologram { return lines; } - @Override - public @NotNull DefaultVisibilitySettings getVisibilitySettings() { - return visibilitySettings; - } - @Override public void setPosition(@NotNull Position position) { super.setPosition(ImmutablePosition.of(position)); @@ -79,11 +71,6 @@ class APIHologram extends BaseHologram implements Hologram { return plugin; } - @Override - public boolean isVisibleTo(Player player) { - return visibilitySettings.isVisibleTo(player); - } - @Override public void delete() { hologramManager.deleteHologram(this); diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2Hologram.java b/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2Hologram.java index 58247e2e..9de3f01b 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2Hologram.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2Hologram.java @@ -16,7 +16,6 @@ import me.filoghost.holographicdisplays.core.base.ImmutablePosition; import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; @@ -39,7 +38,7 @@ class V2Hologram extends BaseHologram implements Hologram { this.plugin = plugin; this.hologramManager = hologramManager; this.lines = new BaseHologramLines<>(this); - this.visibilityManager = new V2VisibilityManager(); + this.visibilityManager = new V2VisibilityManager(getVisibilitySettings()); this.creationTimestamp = System.currentTimeMillis(); } @@ -48,11 +47,6 @@ class V2Hologram extends BaseHologram implements Hologram { return lines; } - @Override - protected boolean isVisibleTo(Player player) { - return visibilityManager.isVisibleTo(player); - } - @Override public Plugin getCreatorPlugin() { return plugin; diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2VisibilityManager.java b/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2VisibilityManager.java index 59832a2b..bd597fe0 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2VisibilityManager.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/api/v2/V2VisibilityManager.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.core.api.v2; import com.gmail.filoghost.holographicdisplays.api.VisibilityManager; +import me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings; import me.filoghost.holographicdisplays.api.beta.hologram.VisibilitySettings.Visibility; import me.filoghost.holographicdisplays.core.api.current.DefaultVisibilitySettings; import org.bukkit.entity.Player; @@ -13,9 +14,9 @@ import org.bukkit.entity.Player; @SuppressWarnings("deprecation") class V2VisibilityManager implements VisibilityManager { - private final DefaultVisibilitySettings v3VisibilitySettings; + private final VisibilitySettings v3VisibilitySettings; - V2VisibilityManager() { + V2VisibilityManager(VisibilitySettings visibilitySettings) { this.v3VisibilitySettings = new DefaultVisibilitySettings(); } diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologram.java b/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologram.java index 48c0192f..24f095f0 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologram.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologram.java @@ -6,11 +6,11 @@ package me.filoghost.holographicdisplays.core.base; import me.filoghost.fcommons.Preconditions; +import me.filoghost.holographicdisplays.core.api.current.DefaultVisibilitySettings; import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,17 +18,17 @@ import org.jetbrains.annotations.Nullable; public abstract class BaseHologram extends BaseHologramComponent { private final HologramPosition hologramPosition; + private final DefaultVisibilitySettings visibilitySettings; private final LineTrackerManager lineTrackerManager; public BaseHologram(ImmutablePosition position, LineTrackerManager lineTrackerManager) { this.hologramPosition = new HologramPosition(position); + this.visibilitySettings = new DefaultVisibilitySettings(); this.lineTrackerManager = lineTrackerManager; } public abstract BaseHologramLines getLines(); - protected abstract boolean isVisibleTo(Player player); - public abstract Plugin getCreatorPlugin(); protected final LineTrackerManager getTrackerManager() { @@ -45,6 +45,10 @@ public abstract class BaseHologram extends BaseHologramComponent { return hologramPosition.getPosition(); } + public @NotNull DefaultVisibilitySettings getVisibilitySettings() { + return visibilitySettings; + } + public @Nullable World getWorldIfLoaded() { return hologramPosition.getWorldIfLoaded(); } diff --git a/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologramLine.java b/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologramLine.java index 82ec5d02..dfbdc041 100644 --- a/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologramLine.java +++ b/core/src/main/java/me/filoghost/holographicdisplays/core/base/BaseHologramLine.java @@ -61,7 +61,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements } public final boolean isVisibleTo(Player player) { - return hologram.isVisibleTo(player); + return hologram.getVisibilitySettings().isVisibleTo(player); } public final Plugin getCreatorPlugin() {