Skip to content

Commit

Permalink
Add hologram types (#51)
Browse files Browse the repository at this point in the history
* Add hologram types (text, item, block)

* Add hologram types for 1.20.1 and 1.19.4

* Add checks for hologram types in subcommands

* Remove debug messages
  • Loading branch information
OliverSchlueter authored Nov 4, 2023
1 parent 799fc2f commit 973336e
Show file tree
Hide file tree
Showing 51 changed files with 1,408 additions and 806 deletions.
12 changes: 9 additions & 3 deletions api/src/main/java/de/oliver/fancyholograms/api/Hologram.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.oliver.fancyholograms.api;

import de.oliver.fancyholograms.api.data.HologramData;
import de.oliver.fancyholograms.api.data.TextHologramData;
import de.oliver.fancyholograms.api.events.HologramHideEvent;
import de.oliver.fancyholograms.api.events.HologramShowEvent;
import io.github.miniplaceholders.api.MiniPlaceholders;
Expand Down Expand Up @@ -253,7 +255,7 @@ public final boolean isShown(@NotNull final Player player) {
* @return the distance to the other location, or NaN if the locations are null or in different worlds
*/
public final double distanceTo(@Nullable final Location other) {
final var location = getData().getLocation();
final var location = getData().getDisplayData().getLocation();
if (location == null || other == null) {
return Double.NaN;
}
Expand All @@ -272,9 +274,13 @@ public final double distanceTo(@Nullable final Location other) {
* @param player the player to get the placeholders for, or null if no placeholders should be replaced
* @return the text shown in the hologram
*/
public final @NotNull Component getShownText(@Nullable final Player player) {
public final Component getShownText(@Nullable final Player player) {
if (!(getData().getTypeData() instanceof TextHologramData textData)) {
return null;
}

var tags = TagResolver.empty();
var text = String.join("\n", getData().getText());
var text = String.join("\n", textData.getText());

if (player != null) {
if (isUsingPlaceholderApi()) {
Expand Down
Loading

0 comments on commit 973336e

Please sign in to comment.