mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-04 18:02:24 +01:00
Rename API methods
This commit is contained in:
parent
1a9a80fe36
commit
fdd76f179e
@ -9,57 +9,56 @@ 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.
|
||||
* Settings to manage the visibility of a hologram to players. Allows to set a global visibility and an individual
|
||||
* visibility for specific players.
|
||||
*
|
||||
* @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.
|
||||
* Returns the visibility of the hologram. The initial value is {@link Visibility#VISIBLE}.
|
||||
*
|
||||
* @return the default visibility
|
||||
* @return the visibility
|
||||
* @since 1
|
||||
*/
|
||||
@NotNull Visibility getDefaultVisibility();
|
||||
@NotNull Visibility getVisibility();
|
||||
|
||||
/**
|
||||
* 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)}.
|
||||
* Sets the visibility of the hologram. This value only affects player which do not have an individual visibility
|
||||
* (see {@link #setIndividualVisibility(Player, Visibility)}).
|
||||
*
|
||||
* @param defaultVisibility the new default visibility
|
||||
* @param visibility the new visibility
|
||||
* @since 1
|
||||
*/
|
||||
void setDefaultVisibility(@NotNull Visibility defaultVisibility);
|
||||
void setVisibility(@NotNull Visibility visibility);
|
||||
|
||||
/**
|
||||
* Sets the visibility for a specific player, overriding the default value ({@link #getDefaultVisibility()}).
|
||||
* The individual visibility value can be reverted with {@link #resetIndividualVisibility(Player)}.
|
||||
* Sets the visibility for a specific player, overriding the global value of ({@link #getVisibility()}).
|
||||
* The individual visibility value can be removed with {@link #removeIndividualVisibility(Player)}.
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void setIndividualVisibility(@NotNull Player player, @NotNull Visibility visibility);
|
||||
|
||||
/**
|
||||
* Resets the visibility for a specific player to the default value ({@link #getDefaultVisibility()}).
|
||||
* Removes the individual visibility for a player. The visibility for the player would then be determined by the
|
||||
* global visibility ({@link #getVisibility()}).
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void resetIndividualVisibility(@NotNull Player player);
|
||||
void removeIndividualVisibility(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Resets the visibility for all players to the default value ({@link #getDefaultVisibility()}).
|
||||
* Removes the individual visibility all players which have one.
|
||||
*
|
||||
* @since 1
|
||||
*/
|
||||
void resetIndividualVisibilityAll();
|
||||
void clearIndividualVisibilities();
|
||||
|
||||
/**
|
||||
* Checks if a hologram is visible to a player, taking into account the individual visibility for the specific
|
||||
* player and the default visibility.
|
||||
* Checks if a hologram is visible to a player, taking into account both the global visibility and the individual
|
||||
* visibility of the player (if set).
|
||||
*
|
||||
* @param player the player
|
||||
* @return if the player can see the hologram
|
||||
|
@ -16,34 +16,34 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class DefaultVisibilitySettings implements VisibilitySettings {
|
||||
|
||||
private Map<UUID, Visibility> visibilityByPlayer;
|
||||
private Visibility defaultVisibility;
|
||||
private Visibility globalVisibility;
|
||||
private Map<UUID, Visibility> individualVisibilities;
|
||||
|
||||
public DefaultVisibilitySettings() {
|
||||
this.defaultVisibility = Visibility.VISIBLE;
|
||||
this.globalVisibility = Visibility.VISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Visibility getDefaultVisibility() {
|
||||
return defaultVisibility;
|
||||
public @NotNull Visibility getVisibility() {
|
||||
return globalVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultVisibility(@NotNull Visibility defaultVisibility) {
|
||||
if (this.defaultVisibility == defaultVisibility) {
|
||||
public void setVisibility(@NotNull Visibility visibility) {
|
||||
if (this.globalVisibility == visibility) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.defaultVisibility = defaultVisibility;
|
||||
this.globalVisibility = visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndividualVisibility(@NotNull Player player, @NotNull Visibility visibility) {
|
||||
// Lazy initialization
|
||||
if (visibilityByPlayer == null) {
|
||||
visibilityByPlayer = new ConcurrentHashMap<>();
|
||||
if (individualVisibilities == null) {
|
||||
individualVisibilities = new ConcurrentHashMap<>();
|
||||
}
|
||||
visibilityByPlayer.put(player.getUniqueId(), visibility);
|
||||
individualVisibilities.put(player.getUniqueId(), visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,41 +54,41 @@ public class DefaultVisibilitySettings implements VisibilitySettings {
|
||||
}
|
||||
|
||||
private Visibility getVisibility(Player player) {
|
||||
if (visibilityByPlayer != null) {
|
||||
Visibility visibility = visibilityByPlayer.get(player.getUniqueId());
|
||||
if (individualVisibilities != null) {
|
||||
Visibility visibility = individualVisibilities.get(player.getUniqueId());
|
||||
if (visibility != null) {
|
||||
return visibility;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultVisibility;
|
||||
return globalVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIndividualVisibility(@NotNull Player player) {
|
||||
public void removeIndividualVisibility(@NotNull Player player) {
|
||||
Preconditions.notNull(player, "player");
|
||||
|
||||
if (visibilityByPlayer == null) {
|
||||
if (individualVisibilities == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
visibilityByPlayer.remove(player.getUniqueId());
|
||||
individualVisibilities.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIndividualVisibilityAll() {
|
||||
if (visibilityByPlayer == null) {
|
||||
public void clearIndividualVisibilities() {
|
||||
if (individualVisibilities == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
visibilityByPlayer.clear();
|
||||
individualVisibilities.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VisibilitySettings{"
|
||||
+ "defaultVisibility=" + defaultVisibility
|
||||
+ ", visibilityByPlayer=" + visibilityByPlayer
|
||||
+ "globalVisibility=" + globalVisibility
|
||||
+ ", individualVisibilities=" + individualVisibilities
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
@ -21,12 +21,12 @@ class V2VisibilityManager implements VisibilityManager {
|
||||
|
||||
@Override
|
||||
public boolean isVisibleByDefault() {
|
||||
return v3VisibilitySettings.getDefaultVisibility() == Visibility.VISIBLE;
|
||||
return v3VisibilitySettings.getVisibility() == Visibility.VISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleByDefault(boolean visibleByDefault) {
|
||||
v3VisibilitySettings.setDefaultVisibility(visibleByDefault ? Visibility.VISIBLE : Visibility.HIDDEN);
|
||||
v3VisibilitySettings.setVisibility(visibleByDefault ? Visibility.VISIBLE : Visibility.HIDDEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,12 +46,12 @@ class V2VisibilityManager implements VisibilityManager {
|
||||
|
||||
@Override
|
||||
public void resetVisibility(Player player) {
|
||||
v3VisibilitySettings.resetIndividualVisibility(player);
|
||||
v3VisibilitySettings.removeIndividualVisibility(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetVisibilityAll() {
|
||||
v3VisibilitySettings.resetIndividualVisibilityAll();
|
||||
v3VisibilitySettings.clearIndividualVisibilities();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user