diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java b/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java
index 95fcc1f1..a79cae78 100644
--- a/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java
+++ b/api/src/main/java/me/filoghost/holographicdisplays/api/Hologram.java
@@ -178,14 +178,14 @@ public interface Hologram {
/**
- * Returns the {@link VisibilityManager} of this hologram.
- *
Note: the usage of the VisibilityManager requires ProtocolLib.
+ * Returns the {@link VisibilitySettings} of this hologram.
+ *
Note: the usage of the VisibilitySettings requires ProtocolLib.
* Without the plugin, holograms will be always visible.
*
- * @return the VisibilityManager of this hologram
+ * @return the VisibilitySettings of this hologram
* @since 1
*/
- @NotNull VisibilityManager getVisibilityManager();
+ @NotNull VisibilitySettings getVisibilitySettings();
/**
diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilityManager.java b/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilityManager.java
deleted file mode 100644
index 63ec70d4..00000000
--- a/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilityManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) filoghost and contributors
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-package me.filoghost.holographicdisplays.api;
-
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * This object is used to manage the visibility of a hologram.
- * It allows to hide/show the hologram to certain players, and the default behaviour
- * (when a hologram is not specifically being hidden/shown to a player) can be customized.
- *
- * @since 1
- */
-public interface VisibilityManager {
-
- /**
- * Returns if the hologram is visible by default. If not changed, this value
- * is true by default so the hologram is visible to everyone.
- *
- * @return if the hologram hologram is visible by default
- * @since 1
- */
- boolean isVisibleByDefault();
-
- /**
- * Sets if the hologram is visible by default. If not changed, this value
- * is true by default so the hologram is visible to everyone.
- *
- * @param visibleByDefault the new behaviour
- * @since 1
- */
- void setVisibleByDefault(boolean visibleByDefault);
-
- /**
- * Shows the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
- * This is persistent if the players goes offline.
- *
- * @param player the involved player
- * @since 1
- */
- void showTo(@NotNull Player player);
-
- /**
- * Hides the hologram to a player, overriding the value of {@link #isVisibleByDefault()}.
- * This is persistent if the players goes offline.
- *
- * @param player the involved player
- * @since 1
- */
- void hideTo(@NotNull Player player);
-
- /**
- * Checks if a hologram is visible to a player.
- *
- * @param player the involved player
- * @return if the player can see the hologram
- * @since 1
- */
- boolean isVisibleTo(@NotNull Player player);
-
- /**
- * Resets the visibility to the default value. If you previously called {@link #showTo(Player)}
- * or {@link #hideTo(Player)} to override the default visibility, this method will reset it
- * to reflect the value of {@link #isVisibleByDefault()}.
- *
- * @param player the involved player
- * @since 1
- */
- void resetVisibility(@NotNull Player player);
-
- /**
- * Resets the visibility for all the players. See {@link #resetVisibility(Player)} for more details.
- *
- * @since 1
- */
- void resetVisibilityAll();
-
-}
diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java b/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java
new file mode 100644
index 00000000..73b07fb9
--- /dev/null
+++ b/api/src/main/java/me/filoghost/holographicdisplays/api/VisibilitySettings.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) filoghost and contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+package me.filoghost.holographicdisplays.api;
+
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Settings to manage the visibility of a hologram to players. Allows to set both the default visibility and the
+ * visibility to a specific player.
+ *
+ * Warning: changing the visibility requires ProtocolLib, otherwise methods of this class have no effect.
+ *
+ * @since 1
+ */
+public interface VisibilitySettings {
+
+ /**
+ * Returns the default visibility of the hologram. The initial value is {@link Visibility#VISIBLE}, meaning that the
+ * hologram is visible to everyone.
+ *
+ * @return the default visibility
+ * @since 1
+ */
+ @NotNull Visibility getDefaultVisibility();
+
+ /**
+ * Sets the default visibility. This value affects player which do not have an individual visibility set with {@link
+ * #setIndividualVisibility(Player, Visibility)} and player whose individual visibility has been reset with {@link
+ * #resetIndividualVisibility(Player)}.
+ *
+ * @param defaultVisibility the new default visibility
+ * @since 1
+ */
+ void setDefaultVisibility(@NotNull Visibility defaultVisibility);
+
+ /**
+ * Sets the visibility for a specific player, overriding the default value ({@link #getDefaultVisibility()}).
+ * The individual visibility value can be reverted with {@link #resetIndividualVisibility(Player)}.
+ *
+ * @since 1
+ */
+ void setIndividualVisibility(@NotNull Player player, @NotNull Visibility visibility);
+
+ /**
+ * Resets the visibility for a specific player to the default value ({@link #getDefaultVisibility()}).
+ *
+ * @since 1
+ */
+ void resetIndividualVisibility(@NotNull Player player);
+
+ /**
+ * Resets the visibility for all players to the default value ({@link #getDefaultVisibility()}).
+ *
+ * @since 1
+ */
+ void resetIndividualVisibilityAll();
+
+ /**
+ * Checks if a hologram is visible to a player, taking into account the individual visibility for the specific
+ * player and the default visibility.
+ *
+ * @param player the player
+ * @return if the player can see the hologram
+ * @since 1
+ */
+ boolean isVisibleTo(@NotNull Player player);
+
+
+ /**
+ * The available statuses for the visibility of a hologram.
+ */
+ enum Visibility {
+
+ VISIBLE,
+ HIDDEN
+
+ }
+
+}
diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2HologramAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2HologramAdapter.java
index 2084f531..e41c84da 100644
--- a/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2HologramAdapter.java
+++ b/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2HologramAdapter.java
@@ -106,7 +106,7 @@ public class V2HologramAdapter implements Hologram {
@Override
public VisibilityManager getVisibilityManager() {
- return newHologram.getVisibilityManager().getV2Adapter();
+ return newHologram.getVisibilitySettings().getV2Adapter();
}
@Override
diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2VisibilityManagerAdapter.java b/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2VisibilityManagerAdapter.java
index 78cbb346..bf8e868d 100644
--- a/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2VisibilityManagerAdapter.java
+++ b/plugin/src/main/java/me/filoghost/holographicdisplays/legacy/api/v2/V2VisibilityManagerAdapter.java
@@ -6,51 +6,52 @@
package me.filoghost.holographicdisplays.legacy.api.v2;
import com.gmail.filoghost.holographicdisplays.api.VisibilityManager;
-import me.filoghost.holographicdisplays.object.api.DefaultVisibilityManager;
+import me.filoghost.holographicdisplays.api.VisibilitySettings.Visibility;
+import me.filoghost.holographicdisplays.object.api.DefaultVisibilitySettings;
import org.bukkit.entity.Player;
@SuppressWarnings("deprecation")
public class V2VisibilityManagerAdapter implements VisibilityManager {
- private final DefaultVisibilityManager newVisibilityManager;
+ private final DefaultVisibilitySettings newVisibilitySettings;
- public V2VisibilityManagerAdapter(DefaultVisibilityManager newVisibilityManager) {
- this.newVisibilityManager = newVisibilityManager;
+ public V2VisibilityManagerAdapter(DefaultVisibilitySettings newVisibilitySettings) {
+ this.newVisibilitySettings = newVisibilitySettings;
}
@Override
public boolean isVisibleByDefault() {
- return newVisibilityManager.isVisibleByDefault();
+ return newVisibilitySettings.getDefaultVisibility() == Visibility.VISIBLE;
}
@Override
public void setVisibleByDefault(boolean visibleByDefault) {
- newVisibilityManager.setVisibleByDefault(visibleByDefault);
+ newVisibilitySettings.setDefaultVisibility(visibleByDefault ? Visibility.VISIBLE : Visibility.HIDDEN);
}
@Override
public void showTo(Player player) {
- newVisibilityManager.showTo(player);
+ newVisibilitySettings.setIndividualVisibility(player, Visibility.VISIBLE);
}
@Override
public void hideTo(Player player) {
- newVisibilityManager.hideTo(player);
+ newVisibilitySettings.setIndividualVisibility(player, Visibility.HIDDEN);
}
@Override
public boolean isVisibleTo(Player player) {
- return newVisibilityManager.isVisibleTo(player);
+ return newVisibilitySettings.isVisibleTo(player);
}
@Override
public void resetVisibility(Player player) {
- newVisibilityManager.resetVisibility(player);
+ newVisibilitySettings.resetIndividualVisibility(player);
}
@Override
public void resetVisibilityAll() {
- newVisibilityManager.resetVisibilityAll();
+ newVisibilitySettings.resetIndividualVisibilityAll();
}
@Override
@@ -63,17 +64,17 @@ public class V2VisibilityManagerAdapter implements VisibilityManager {
}
V2VisibilityManagerAdapter other = (V2VisibilityManagerAdapter) obj;
- return this.newVisibilityManager.equals(other.newVisibilityManager);
+ return this.newVisibilitySettings.equals(other.newVisibilitySettings);
}
@Override
public final int hashCode() {
- return newVisibilityManager.hashCode();
+ return newVisibilitySettings.hashCode();
}
@Override
public final String toString() {
- return newVisibilityManager.toString();
+ return newVisibilitySettings.toString();
}
}
diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java
index 62aa6cdd..f1cfc0e4 100644
--- a/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java
+++ b/plugin/src/main/java/me/filoghost/holographicdisplays/object/api/APIHologram.java
@@ -25,7 +25,7 @@ public class APIHologram extends BaseHologram