From 208e2278ecb37e940ed00dc1f7ac827b5b92ba22 Mon Sep 17 00:00:00 2001 From: EpicPlayerA10 Date: Thu, 30 May 2024 12:50:53 +0200 Subject: [PATCH] remove updateHologram and add getHologramOrCreate --- .../services/holograms/HologramsService.java | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) 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 04ffa89a5f..ae582c261d 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 @@ -114,6 +114,14 @@ private void purge() { } } + /** + * @see HologramsService#getHologram(Location, boolean) + */ + @Nonnull + private Hologram getHologramOrCreate(@Nonnull Location loc) { + return getHologram(loc, true); + } + /** * This returns the {@link Hologram} associated with the given {@link Location}. * If createIfNoneExists is set to true a new {@link ArmorStand} will be spawned @@ -237,31 +245,6 @@ private Hologram getAsHologram(@Nonnull BlockPosition position, @Nonnull Entity } } - /** - * This updates the {@link Hologram}. - * You can use it to set the nametag or other properties. - *

- * This method must be executed on the main {@link Server} {@link Thread}. - * - * @param loc - * The {@link Location} - */ - @Nullable - private Hologram updateHologram(@Nonnull Location loc) { - Validate.notNull(loc, "Location must not be null"); - - if (!Bukkit.isPrimaryThread()) { - throw new UnsupportedOperationException("You cannot update a hologram asynchronously"); - } - - try { - return getHologram(loc, true); - } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, "Hologram located at {0}", new BlockPosition(loc)); - throw new RuntimeException("Something went wrong while trying to update this hologram", x); - } - } - /** * This removes the {@link Hologram} at that given {@link Location}. *

@@ -308,10 +291,8 @@ public boolean removeHologram(@Nonnull Location loc) { public void setHologramLabel(@Nonnull Location loc, @Nullable String label) { Validate.notNull(loc, "Location must not be null"); - Hologram hologram = updateHologram(loc); - if (hologram != null) { - hologram.setLabel(label); - } + Hologram hologram = getHologramOrCreate(loc); + hologram.setLabel(label); } }