diff --git a/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java b/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java index bbb74688..7052f3d9 100644 --- a/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java +++ b/api/src/main/java/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.java @@ -6,6 +6,7 @@ package me.filoghost.holographicdisplays.api; import me.filoghost.holographicdisplays.api.hologram.Hologram; +import me.filoghost.holographicdisplays.api.hologram.HologramPosition; import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider; import me.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer; import org.bukkit.Location; @@ -64,6 +65,8 @@ public interface HolographicDisplaysAPI { */ @NotNull Hologram createHologram(@NotNull Location location); + @NotNull Hologram createHologram(@NotNull HologramPosition position); + /** * Returns all the active holograms. A hologram is no longer active after {@link Hologram#delete()} is invoked. * diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java index 46096284..88e1c995 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/api/current/DefaultHolographicDisplaysAPI.java @@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.plugin.api.current; import me.filoghost.fcommons.Preconditions; import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI; import me.filoghost.holographicdisplays.api.hologram.Hologram; +import me.filoghost.holographicdisplays.api.hologram.HologramPosition; import me.filoghost.holographicdisplays.api.placeholder.PlaceholderReplacer; import me.filoghost.holographicdisplays.plugin.hologram.api.APIHologramManager; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition; @@ -39,6 +40,15 @@ class DefaultHolographicDisplaysAPI implements HolographicDisplaysAPI { return apiHologramManager.createHologram(new BaseHologramPosition(location), plugin); } + @Override + public @NotNull Hologram createHologram(@NotNull HologramPosition position) { + Preconditions.notNull(position, "position"); + Preconditions.notNull(position.getWorldName(), "position world name"); + Preconditions.checkMainThread("async hologram creation"); + + return apiHologramManager.createHologram(new BaseHologramPosition(position), plugin); + } + @Override public void registerPlaceholder(@NotNull String identifier, int refreshIntervalTicks, @NotNull PlaceholderReplacer replacer) { Preconditions.notEmpty(identifier, "identifier"); diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramPosition.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramPosition.java index 85101c61..07890a88 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramPosition.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramPosition.java @@ -38,6 +38,15 @@ public class BaseHologramPosition implements HologramPosition { this.z = location.getZ(); } + public BaseHologramPosition(@NotNull HologramPosition position) { + Preconditions.notNull(position, "position"); + Preconditions.notNull(position.getWorldName(), "position's worldName"); + this.worldName = position.getWorldName(); + this.x = position.getX(); + this.y = position.getY(); + this.z = position.getZ(); + } + @Override public @NotNull String getWorldName() { return worldName;