From 5a0c1ebf8857aa2342a21261a26df350051d5b81 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 14 Dec 2024 11:06:53 +0100 Subject: [PATCH 1/2] Allow inserting hologram lines at the end of the list Previously, inserting at the end of the hologram required workarounds as the index check did not permit it. This change updates the logic to allow an index equal to `size()`, enabling straightforward insertion at the end. It improves functionality and aligns with expected behavior. --- .../eu/decentsoftware/holograms/api/holograms/HologramPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java index efc2284e..dabc3bb9 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java @@ -173,7 +173,7 @@ public boolean addLine(@NonNull HologramLine line) { * @see eu.decentsoftware.holograms.api.DHAPI#insertHologramLine(Hologram, int, String) */ public boolean insertLine(int index, @NonNull HologramLine line) { - if (index < 0 || index >= size()) { + if (index < 0 || index > size()) { return false; } lines.add(index, line); From 6f6546cece71948bccee2847d81c16adfc52af3f Mon Sep 17 00:00:00 2001 From: david Date: Sat, 14 Dec 2024 11:09:18 +0100 Subject: [PATCH 2/2] Refactor addLine method to use insertLine for simplicity Replaced redundant code in the addLine method with a call to insertLine to improve code clarity and maintainability. This ensures consistent behavior and reduces duplication, streamlining future updates. --- .../decentsoftware/holograms/api/holograms/HologramPage.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java index dabc3bb9..9b1c5438 100644 --- a/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java +++ b/src/main/java/eu/decentsoftware/holograms/api/holograms/HologramPage.java @@ -158,10 +158,7 @@ public void realignLines() { * @see eu.decentsoftware.holograms.api.DHAPI#addHologramLine(HologramPage, String) */ public boolean addLine(@NonNull HologramLine line) { - lines.add(line); - parent.getViewerPlayers(this.index).forEach(line::show); - realignLines(); - return true; + return insertLine(size(), line); } /**