From 95288fd8b01094224948330f26ddb2225fc2c11a Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 22 Aug 2019 01:09:29 -0400 Subject: [PATCH] More hologram support. --- .../core/library/hologram/HologramManager.java | 14 ++++++++++++-- .../core/library/hologram/holograms/Hologram.java | 15 ++++++++++++--- .../holograms/HolographicDisplaysHologram.java | 6 +++--- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/core/library/hologram/HologramManager.java b/src/main/java/com/songoda/core/library/hologram/HologramManager.java index b1e753ba..39f38d11 100644 --- a/src/main/java/com/songoda/core/library/hologram/HologramManager.java +++ b/src/main/java/com/songoda/core/library/hologram/HologramManager.java @@ -87,7 +87,12 @@ public class HologramManager { return Collections.unmodifiableCollection(registeredHolograms.values()); } - public static void add(Location location, ArrayList lines) { + public static void add(Location location, String line) { + if (defaultHolo != null) + defaultHolo.add(location, line); + } + + public static void add(Location location, List lines) { if (defaultHolo != null) defaultHolo.add(location, lines); } @@ -97,7 +102,12 @@ public class HologramManager { defaultHolo.remove(location); } - public static void update(Location location, ArrayList lines) { + public static void update(Location location, String line) { + if (defaultHolo != null) + defaultHolo.update(location, line); + } + + public static void update(Location location, List lines) { if (defaultHolo != null) defaultHolo.update(location, lines); } diff --git a/src/main/java/com/songoda/core/library/hologram/holograms/Hologram.java b/src/main/java/com/songoda/core/library/hologram/holograms/Hologram.java index cfe8295f..c9d21443 100644 --- a/src/main/java/com/songoda/core/library/hologram/holograms/Hologram.java +++ b/src/main/java/com/songoda/core/library/hologram/holograms/Hologram.java @@ -3,7 +3,8 @@ package com.songoda.core.library.hologram.holograms; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; -import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public abstract class Hologram { @@ -26,11 +27,19 @@ public abstract class Hologram { public abstract String getName(); - public abstract void add(Location location, ArrayList lines); + public void add(Location location, String line) { + add(location, Collections.singletonList(line)); + } + + public abstract void add(Location location, List lines); public abstract void remove(Location location); - public abstract void update(Location location, ArrayList lines); + public void update(Location location, String line) { + update(location, Collections.singletonList(line)); + } + + public abstract void update(Location location, List lines); void fixLocation(Location location) { location.add(x, y, z); diff --git a/src/main/java/com/songoda/core/library/hologram/holograms/HolographicDisplaysHologram.java b/src/main/java/com/songoda/core/library/hologram/holograms/HolographicDisplaysHologram.java index 157cd9bb..a8c3f6f1 100644 --- a/src/main/java/com/songoda/core/library/hologram/holograms/HolographicDisplaysHologram.java +++ b/src/main/java/com/songoda/core/library/hologram/holograms/HolographicDisplaysHologram.java @@ -4,7 +4,7 @@ import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; -import java.util.ArrayList; +import java.util.List; public class HolographicDisplaysHologram extends Hologram { @@ -18,7 +18,7 @@ public class HolographicDisplaysHologram extends Hologram { } @Override - public void add(Location location, ArrayList lines) { + public void add(Location location, List lines) { fixLocation(location); com.gmail.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, location); @@ -39,7 +39,7 @@ public class HolographicDisplaysHologram extends Hologram { } @Override - public void update(Location location, ArrayList lines) { + public void update(Location location, List lines) { for (com.gmail.filoghost.holographicdisplays.api.Hologram hologram : HologramsAPI.getHolograms(plugin)) { if (hologram.getX() != location.getX() || hologram.getY() != location.getY()