getHolograms() {
return this.holograms;
}
@@ -248,25 +314,42 @@ protected static void replaceLine(HologramPage page, int line, String text) {
}
+ /**
+ * Assign a click listener to this hologram, a ClickAction will be call when anyone clicks the hologram.
+ * This should be called right when reloading the hologram
+ * {@code
+ * @Override
+ * public void reload(UUID playerUUID) {
+ * super.reload(playerUUID);
+ * super.setClickListener((clickEvent) -> {});
+ * }
+ * @param clickListener Action callback.
+ */
public void setClickListener(@Nullable ClickAction clickListener) {
this.clickListener = clickListener;
}
-
public @Nullable ClickAction getClickListener() {
return this.clickListener;
}
-
+ /**
+ * Get activeDisplays in DecentHologramDisplay by ID
+ * @param id The id first used to construct a new DecentHologramDisplay
+ * @return The hologram assigned to id.
+ */
public static DecentHologramDisplay getById(String id) {
- return (DecentHologramDisplay) activeDisplays.stream().filter((holo) -> {
- return holo.getId().equals(id);
- }).findFirst().orElse((DecentHologramDisplay)null);
+ return activeDisplays.stream().filter(holo -> holo.getId().equals(id)).findFirst().orElse(null);
}
- public interface DataLine {
- T getLine();
- }
+ /**
+ * DataLine of any type, acts as a text lines per hologram page.
+ * @param DataLine type, this can only be ItemStack as ItemLine or String as TextLine
+ */
+ public interface DataLine { T getLine(); }
+ /**
+ * Minecraft ItemStack as DataLine
+ */
public static class ItemLine implements DataLine {
private final ItemStack line;
@@ -279,6 +362,9 @@ public ItemStack getLine() {
}
}
+ /**
+ * String as DataLine
+ */
public static class TextLine implements DataLine {
private final String line;
@@ -290,4 +376,4 @@ public String getLine() {
return this.line;
}
}
-}
+}
\ No newline at end of file
diff --git a/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramListener.java b/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramListener.java
index 6c732d8..ee92f2a 100644
--- a/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramListener.java
+++ b/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramListener.java
@@ -31,6 +31,8 @@
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
+import java.util.Objects;
+
public class DecentHologramListener implements Listener {
public DecentHologramListener() {
@@ -38,10 +40,9 @@ public DecentHologramListener() {
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
- // Create player's hologram each time they join
for (DecentHologramDisplay display : DecentHologramDisplay.activeDisplays) {
if (display.getLocation() == null) return;
- if (display.getLocation().getWorld().getName().equals(event.getPlayer().getWorld().getName()))
+ if (Objects.requireNonNull(display.getLocation().getWorld()).getName().equals(event.getPlayer().getWorld().getName()))
display.create(event.getPlayer());
}
@@ -58,7 +59,7 @@ public void onPlayerQuitEvent(PlayerQuitEvent event) {
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event) {
for (DecentHologramDisplay display : DecentHologramDisplay.activeDisplays) {
if (display.getLocation() == null) return;
- if (display.getLocation().getWorld().getName().equals(event.getFrom().getName())) display.remove(event.getPlayer().getUniqueId());
+ if (Objects.requireNonNull(display.getLocation().getWorld()).getName().equals(event.getFrom().getName())) display.remove(event.getPlayer().getUniqueId());
else if (display.getLocation().getWorld().getName().equals(event.getPlayer().getWorld().getName())) display.create(event.getPlayer());
}
diff --git a/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramPagedDisplay.java b/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramPagedDisplay.java
index d79fdd7..a4bf9e5 100644
--- a/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramPagedDisplay.java
+++ b/hologram/src/main/java/com/aseanbte/aseanlib/hologram/DecentHologramPagedDisplay.java
@@ -44,7 +44,7 @@ public abstract class DecentHologramPagedDisplay extends DecentHologramDisplay {
private int changeState = 0;
private long changeDelay = 0;
private final Plugin plugin;
- private static String contentSeparator = "§7---------------";
+ private static final String contentSeparator = "§7---------------";
protected boolean automaticallySkipPage = true;
public DecentHologramPagedDisplay(@NotNull String id, Location position, boolean isEnabled, @NotNull Plugin plugin) {
diff --git a/http/pom.xml b/http/pom.xml
index f96de06..ddc3e9d 100644
--- a/http/pom.xml
+++ b/http/pom.xml
@@ -5,7 +5,7 @@
aseanlib
com.aseanbte.aseanlib
- 1.1.4
+ 1.1.5
4.0.0
diff --git a/io/pom.xml b/io/pom.xml
index 2abfbe4..5adb3a8 100644
--- a/io/pom.xml
+++ b/io/pom.xml
@@ -5,7 +5,7 @@
aseanlib
com.aseanbte.aseanlib
- 1.1.4
+ 1.1.5
4.0.0
@@ -56,7 +56,7 @@
com.aseanbte.aseanlib
aseanlib-utils
- 1.1.4
+ 1.1.5
provided
diff --git a/jitpack.yml b/jitpack.yml
new file mode 100644
index 0000000..f29a667
--- /dev/null
+++ b/jitpack.yml
@@ -0,0 +1,5 @@
+jdk:
+ - openjdk17
+before_install:
+ - sdk install java 17.0.1-open
+ - sdk use java 17.0.1-open
\ No newline at end of file
diff --git a/libpsterra/pom.xml b/libpsterra/pom.xml
index 11526d2..d3dccf8 100644
--- a/libpsterra/pom.xml
+++ b/libpsterra/pom.xml
@@ -5,7 +5,7 @@
aseanlib
com.aseanbte.aseanlib
- 1.1.4
+ 1.1.5
4.0.0
@@ -48,14 +48,14 @@
com.aseanbte.aseanlib
aseanlib-utils
- 1.1.4
+ 1.1.5
com.aseanbte.aseanlib
aseanlib-io
- 1.1.4
+ 1.1.5
diff --git a/npc/pom.xml b/npc/pom.xml
index 9f02030..419eeec 100644
--- a/npc/pom.xml
+++ b/npc/pom.xml
@@ -5,7 +5,7 @@
aseanlib
com.aseanbte.aseanlib
- 1.1.4
+ 1.1.5
4.0.0
@@ -14,8 +14,8 @@
AseanLib-NPC
- 17
- 17
+ 1.8
+ 1.8
UTF-8
@@ -54,7 +54,7 @@
com.aseanbte.aseanlib
aseanlib-hologram
- 1.1.4
+ 1.1.5
provided
diff --git a/npc/src/main/java/com/aseanbte/aseanlib/npc/AbstractNpc.java b/npc/src/main/java/com/aseanbte/aseanlib/npc/AbstractNpc.java
index 2a05859..75e03fd 100644
--- a/npc/src/main/java/com/aseanbte/aseanlib/npc/AbstractNpc.java
+++ b/npc/src/main/java/com/aseanbte/aseanlib/npc/AbstractNpc.java
@@ -37,7 +37,7 @@
public abstract class AbstractNpc {
public static final List activeNPCs = new ArrayList<>();
- private static final String EMPTY_TAG = "";
+ private static final String EMPTY_TAG = "&f";
private static final String IDENTIFIER_TAG = "alpslib_";
public abstract String getDisplayName(UUID playerUUID);
@@ -78,7 +78,7 @@ public void show(Player player) {
Bukkit.getScheduler().runTaskAsynchronously(FancyNpcs.getInstance().getPlugin(), () -> {
npc.getData().showToPlayer(player.getUniqueId());
npc.spawn(player);
- if (hologram != null && player.getWorld().getName().equals(hologram.getLocation().getWorld().getName()))
+ if (hologram != null && player.getWorld().getName().equals(Objects.requireNonNull(hologram.getLocation().getWorld()).getName()))
hologram.create(player);
});
}
@@ -89,7 +89,7 @@ public void showForAll() {
npc.spawnForAll();
if (hologram != null) {
Bukkit.getOnlinePlayers().forEach(player -> {
- if (player.getWorld().getName().equals(hologram.getLocation().getWorld().getName()))
+ if (player.getWorld().getName().equals(Objects.requireNonNull(hologram.getLocation().getWorld()).getName()))
Bukkit.getScheduler().runTask(FancyNpcs.getInstance().getPlugin(), () -> hologram.create(player));
});
}
diff --git a/npc/src/main/java/com/aseanbte/aseanlib/npc/NpcHologram.java b/npc/src/main/java/com/aseanbte/aseanlib/npc/NpcHologram.java
index 0fcbc25..34bc0b1 100644
--- a/npc/src/main/java/com/aseanbte/aseanlib/npc/NpcHologram.java
+++ b/npc/src/main/java/com/aseanbte/aseanlib/npc/NpcHologram.java
@@ -32,7 +32,12 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
-import java.util.*;
+import java.util.HashMap;
+import java.util.UUID;
+import java.util.Map;
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
public class NpcHologram extends DecentHologramDisplay {
private static final double NPC_HOLOGRAM_Y = 2.3;
@@ -44,7 +49,7 @@ public class NpcHologram extends DecentHologramDisplay {
private Location baseLocation;
public NpcHologram(@NotNull String id, Location location, AbstractNpc npc) {
- super(id, location.add(0, NPC_HOLOGRAM_Y, 0), true);
+ super(id, location.clone().add(0, NPC_HOLOGRAM_Y, 0), true);
this.npc = npc;
this.baseLocation = location;
}
@@ -97,9 +102,8 @@ public void setLocation(Location newLocation) {
}
public void setActionTitleVisibility(UUID playerUUID, boolean isVisible) {
- Location nameLocation = baseLocation.clone();
isActionTitleVisible.put(playerUUID, isVisible);
- getHologram(playerUUID).setLocation(nameLocation.add(0, isActionTitleVisible(playerUUID) ?
+ getHologram(playerUUID).setLocation(baseLocation.clone().add(0, isActionTitleVisible(playerUUID) ?
NPC_HOLOGRAM_Y_WITH_ACTION_TITLE : NPC_HOLOGRAM_Y, 0));
reload(playerUUID);
}
diff --git a/pom.xml b/pom.xml
index 0c5579f..67423a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.aseanbte.aseanlib
aseanlib
- 1.1.4
+ 1.1.5
pom
AseanLib
diff --git a/utils/pom.xml b/utils/pom.xml
index 666e496..2146bfc 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -5,7 +5,7 @@
aseanlib
com.aseanbte.aseanlib
- 1.1.4
+ 1.1.5
4.0.0