mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-20 15:57:49 +01:00
Add createHologram with HologramPosition
This commit is contained in:
parent
ca5644153e
commit
dba767dd79
@ -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.
|
||||
*
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user