diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java index ab18e61b3..67eb4191b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java @@ -32,7 +32,7 @@ public interface HologramOwner extends ItemAttribute { * The nametag for the hologram */ default void updateHologram(@Nonnull Block b, @Nonnull String text) { - Location loc = b.getLocation().add(getHologramOffset()); + Location loc = b.getLocation().add(getHologramOffset(b)); SlimefunPlugin.getHologramsService().setHologramLabel(loc, ChatColors.color(text)); } @@ -43,7 +43,7 @@ public interface HologramOwner extends ItemAttribute { * The {@link Block} to which the hologram blocks */ default void removeHologram(@Nonnull Block b) { - Location loc = b.getLocation().add(getHologramOffset()); + Location loc = b.getLocation().add(getHologramOffset(b)); SlimefunPlugin.getHologramsService().removeHologram(loc); } @@ -52,11 +52,14 @@ public interface HologramOwner extends ItemAttribute { * This offset is applied to {@link Block#getLocation()} when spawning * the hologram. * + * @param block + * The {@link Block} which serves as the origin point + * * @return The hologram offset */ @Nonnull - default Vector getHologramOffset() { - return new Vector(0.5, 0.75, 0.5); + default Vector getHologramOffset(@Nonnull Block block) { + return SlimefunPlugin.getHologramsService().getDefaultOffset(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java index 1a6db53c8..498025bae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.holograms; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -10,7 +11,6 @@ import org.bukkit.Bukkit; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; -import com.google.common.base.Objects; /** * This represents an {@link ArmorStand} that can expire and be renamed. @@ -99,7 +99,7 @@ class Hologram { * The label to set */ void setLabel(@Nullable String label) { - if (Objects.equal(this.label, label)) { + if (Objects.equals(this.label, label)) { /* * Label is already set, no need to cause an entity * update. But we can update the lastAccess flag. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java index a950bddfd..427cbb5ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java @@ -21,6 +21,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition; import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; @@ -51,6 +52,11 @@ public class HologramsService { */ private final Plugin plugin; + /** + * The default hologram offset + */ + private final Vector defaultOffset = new Vector(0.5, 0.75, 0.5); + /** * The {@link NamespacedKey} used to store data on a hologram */ @@ -82,6 +88,16 @@ public class HologramsService { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, this::purge, PURGE_RATE, PURGE_RATE); } + /** + * This returns the default {@link Hologram} offset. + * + * @return The default offset + */ + @Nonnull + public Vector getDefaultOffset() { + return defaultOffset; + } + /** * This purges any expired {@link Hologram}. */ @@ -252,9 +268,8 @@ public class HologramsService { * @param loc * The {@link Location} * - * @return Whether the {@link Hologram} could be removed, false if the {@link Hologram} does not exist or was - * already - * removed + * @return Whether the {@link Hologram} could be removed, false if the {@link Hologram} does not + * exist or was already removed */ public boolean removeHologram(@Nonnull Location loc) { Validate.notNull(loc, "Location cannot be null");