diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java index c947991d..a129db2c 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/Hologram.java @@ -227,17 +227,17 @@ public static Hologram fromFile(final @NotNull String filePath) throws LocationP */ protected final Object visibilityMutex = new Object(); - protected final @NonNull String name; + protected final String name; protected boolean saveToFile; - protected final @Nullable FileConfig config; - protected final @NonNull Map viewerPages = new ConcurrentHashMap<>(); - protected final @NonNull Set hidePlayers = ConcurrentHashMap.newKeySet(); - protected final @NonNull Set showPlayers = ConcurrentHashMap.newKeySet(); + protected final FileConfig config; + protected final Map viewerPages = new ConcurrentHashMap<>(); + protected final Set hidePlayers = ConcurrentHashMap.newKeySet(); + protected final Set showPlayers = ConcurrentHashMap.newKeySet(); protected boolean defaultVisibleState = true; - protected final @NonNull DList pages = new DList<>(); + protected final DList pages = new DList<>(); protected boolean downOrigin = Settings.DEFAULT_DOWN_ORIGIN; protected boolean alwaysFacePlayer = false; - private final @NonNull AtomicInteger tickCounter; + private final AtomicInteger tickCounter; /* * Constructors @@ -334,7 +334,7 @@ public String toString() { } /** - * This method calls {@link #destroy()} before deleting the holograms file. + * This method calls {@link #destroy()} before deleting the hologram file. */ @Override public void delete() { @@ -499,7 +499,7 @@ public Hologram clone(@NonNull String name, @NonNull Location location, boolean * @param clickType The type of the click. * @return True if the click was handled, false otherwise. */ - public boolean onClick(final @NonNull Player player, final int entityId, final @NonNull ClickType clickType) { + public boolean onClick(@NonNull Player player, int entityId, @NonNull ClickType clickType) { HologramPage page = getPage(player); if (page == null || !page.hasEntity(entityId)) { return false; @@ -783,7 +783,7 @@ public void hideClickableEntities(@NonNull Player player) { return; } - // Despawn clickable entities + // De-spawn clickable entities NMS nms = NMS.getInstance(); page.getClickableEntityIds().forEach(id -> nms.hideFakeEntities(player, id)); } @@ -820,43 +820,35 @@ public void teleportClickableEntitiesAll() { /** - * Check whether the given player is in display range of this hologram object. + * Check whether the given player is in the display range of this hologram object. * * @param player Given player. - * @return Boolean whether the given player is in display range of this hologram object. + * @return Boolean whether the given player is in the display range of this hologram object. */ public boolean isInDisplayRange(@NonNull Player player) { - /* - * Some forks (e.g., Pufferfish) throw an exception, when we try to get - * the world of a location, which is not loaded. We catch this exception - * and return false, because the player is not in range. - */ - try { - if (player.getWorld().equals(location.getWorld())) { - return player.getLocation().distanceSquared(location) <= displayRange * displayRange; - } - } catch (Exception ignored) { - // Ignored - } - return false; + return isInRange(player, displayRange); } /** - * Check whether the given player is in update range of this hologram object. + * Check whether the given player is in the update range of this hologram object. * * @param player Given player. - * @return Boolean whether the given player is in update range of this hologram object. + * @return Boolean whether the given player is in the update range of this hologram object. */ @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean isInUpdateRange(@NonNull Player player) { + return isInRange(player, updateRange); + } + + private boolean isInRange(@NonNull Player player, double range) { /* * Some forks (e.g., Pufferfish) throw an exception, when we try to get - * the world of a location, which is not loaded. We catch this exception - * and return false, because the player is not in range. + * the world of a location, which is not loaded. + * We catch this exception and return false, because the player is not in range. */ try { if (player.getWorld().equals(location.getWorld())) { - return player.getLocation().distanceSquared(location) <= updateRange * updateRange; + return player.getLocation().distanceSquared(location) <= range * range; } } catch (Exception ignored) { // Ignored @@ -893,7 +885,7 @@ public Set getViewerPlayers(int pageIndex) { */ /** - * Re-Align the lines in this hologram putting them to the right place. + * Re-Align the lines in this hologram, putting them to the right place. *

* This method is good to use after teleporting the hologram. *

diff --git a/src/main/java/eu/decentsoftware/holograms/api/utils/items/HologramItem.java b/src/main/java/eu/decentsoftware/holograms/api/utils/items/HologramItem.java index a2284ca6..b8d86625 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/utils/items/HologramItem.java +++ b/src/main/java/eu/decentsoftware/holograms/api/utils/items/HologramItem.java @@ -21,7 +21,7 @@ @AllArgsConstructor public class HologramItem { - public static final String ENCHANTED_INDICATOR = "!ENCHANTED"; + private static final String ENCHANTED_INDICATOR = "!ENCHANTED"; private final String content; private String nbt; private String extras;