From 67a4d3d61d2ece5e948d5356f12cce598b78cb35 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Mon, 21 Feb 2022 18:29:09 +0100 Subject: [PATCH] Updates SongodaCore to v2.6.11 (+ updated to new hologram methods) --- pom.xml | 2 +- .../ultimaterepairing/anvil/UAnvil.java | 38 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index dd38506..8bc8590 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,7 @@ com.songoda SongodaCore - 2.6.8 + 2.6.11 compile diff --git a/src/main/java/com/songoda/ultimaterepairing/anvil/UAnvil.java b/src/main/java/com/songoda/ultimaterepairing/anvil/UAnvil.java index 53d2669..0cb2790 100644 --- a/src/main/java/com/songoda/ultimaterepairing/anvil/UAnvil.java +++ b/src/main/java/com/songoda/ultimaterepairing/anvil/UAnvil.java @@ -11,6 +11,8 @@ import java.util.ArrayList; import java.util.Objects; public class UAnvil { + private static int nextHologramId = 0; + private final String hologramId = "UltimateRepairing-Anvil#" + (++nextHologramId); private final Location location; @@ -30,26 +32,28 @@ public class UAnvil { public void setHologram(boolean hologram) { this.hologram = hologram; if (HologramManager.getManager().isEnabled()) { - - ArrayList lines = new ArrayList<>(); - - if (!Settings.ENABLE_ANVIL_DEFAULT_FUNCTION.getBoolean()) { - lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.oneclick").getMessage()); - } else if (Settings.SWAP_LEFT_RIGHT.getBoolean()) { - lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.swapclick").getMessage()); - } else { - lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.click").getMessage()); - } - - lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.torepair").getMessage()); - - Location location = getLocation().add(0, .1, 0); - Bukkit.getScheduler().runTaskLater(UltimateRepairing.getInstance(), () -> { if (!hologram) { - HologramManager.removeHologram(location); + HologramManager.removeHologram(hologramId); } else { - HologramManager.updateHologram(location, lines); + ArrayList lines = new ArrayList<>(); + + if (!Settings.ENABLE_ANVIL_DEFAULT_FUNCTION.getBoolean()) { + lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.oneclick").getMessage()); + } else if (Settings.SWAP_LEFT_RIGHT.getBoolean()) { + lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.swapclick").getMessage()); + } else { + lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.click").getMessage()); + } + + lines.add(UltimateRepairing.getInstance().getLocale().getMessage("general.hologram.torepair").getMessage()); + + if (!HologramManager.isHologramLoaded(hologramId)) { + HologramManager.createHologram(hologramId, getLocation().add(0, .1, 0), lines); + return; + } + + HologramManager.updateHologram(hologramId, lines); } }, 1L);