Skip to content

Commit

Permalink
feat: NPC with DecentHologram plugin
Browse files Browse the repository at this point in the history
* edited npc module to be using the DecentHologramDisplay class

* added new README.md documentation
  • Loading branch information
tintinkung committed Apr 22, 2024
1 parent eab2b84 commit a885d82
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 65 deletions.
70 changes: 38 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# AlpsLib
# ASEAN Lib
This is the ASEAN BTE implementation of AlpsLib package.
> To use the latest version of AlpsLib, you need to add the following dependencies to your pom.xml. You can find a list of all dependencies here:
> </br>https://mvn.alps-bte.com/#browse/browse:alps-lib
## Modules
To use the latest version of AlpsLib, you need to add the following dependencies to your pom.xml. You can find a list of all dependencies here:
</br>https://mvn.alps-bte.com/#browse/browse:alps-lib
The package is hosted in Github Package therefore an access key is required to authorize the package endpoints.


Repository
```xml
<repositories>
<repository>
<id>alpsbte-repo</id>
<url>https://mvn.alps-bte.com/repository/alps-bte/</url>
<id>aseanbte-repo</id>
<url>https://maven.pkg.github.com/asean-build-the-earth/</url>
</repository>
</repositories>
```

Replace ```latest``` with the version of the module you want to use. You can find a list of all versions by clicking the link above.

### AlpsLib-Hologram
Includes an abstract HolographicDisplay which can be used to create custom holograms.
### AseanLib-Hologram
Implemented DecentHologram Plugin
Includes an abstract DecentHologramDisplay which can be used to create custom holograms.
```xml
<repositories>
<!-- HolographicDisplays -->
<!-- Decent Hologram -->
<repository>
<id>jitpack</id>
<url>https://jitpack.io/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
Expand All @@ -29,44 +37,42 @@ Includes an abstract HolographicDisplay which can be used to create custom holog
```
```xml
<dependencies>
<!-- Decent Hologram Display Class-->
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-hologram</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-hologram</artifactId>
<version>latest</version>
<scope>compile</scope>
</dependency>

<!-- HolographicDisplays -->
<!-- Decent Hologram -->
<dependency>
<groupId>me.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>3.0.0</version>
<groupId>com.github.decentsoftware-eu</groupId>
<artifactId>decentholograms</artifactId>
<version>2.8.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
```

### AlpsLib-IO
Includes Config-Manager, Language-Manager and FTP-Manager.
### AseanLib-NPC
Fancy NPC plugin manager class with Decent Hologram as npc name-tag.
```xml
<dependencies>
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-io</artifactId>
<version>latest</version>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-npc</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
```

### AlpsLib-Utils
Includes ItemBuilder & LoreBuilder, CustomHeads and other useful utilities.
```Important: This module is already included in the AlpsLib-IO module.```
```xml
<dependencies>
<!-- FancyNpcs Plugin -->
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-utils</artifactId>
<version>latest</version>
<groupId>de.oliver</groupId>
<artifactId>FancyNpcs</artifactId>
<version>2.0.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
```
```
---
## Unimplemented
The other module has no addition from alpslib package and can be ignored.

2 changes: 1 addition & 1 deletion hologram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-utils</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions libpsterra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -48,14 +48,14 @@
<dependency>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-utils</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</dependency>

<!-- io from AlpsLib for config -->
<dependency>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-io</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</dependency>

<!-- Spigot -->
Expand Down
19 changes: 11 additions & 8 deletions npc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -24,6 +24,10 @@
<id>alpsbte-repo</id>
<url>https://mvn.alps-bte.com/repository/alps-bte/</url>
</repository>
<repository>
<id>jitpack</id>
<url>https://jitpack.io/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
Expand All @@ -42,16 +46,15 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>3.0.3</version>
<groupId>com.github.decentsoftware-eu</groupId>
<artifactId>decentholograms</artifactId>
<version>2.8.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alpsbte.alpslib</groupId>
<artifactId>alpslib-hologram</artifactId>
<version>1.0.61</version>
<scope>provided</scope>
<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib-hologram</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>de.oliver</groupId>
Expand Down
9 changes: 4 additions & 5 deletions npc/src/main/java/com/aseanbte/aseanlib/npc/AbstractNpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcData;
import de.oliver.fancynpcs.api.utils.SkinFetcher;
import me.filoghost.holographicdisplays.api.Position;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -70,15 +69,15 @@ public void create(Location spawnPos, boolean saveToFile, boolean turnToPlayer)
npc.getData().setOnlyVisibleTo(true);
npc.create();
FancyNpcsPlugin.get().getNpcManager().registerNpc(npc);
hologram = new NpcHologram(IDENTIFIER_TAG + id, Position.of(spawnPos), this);
hologram = new NpcHologram(IDENTIFIER_TAG + id, spawnPos, this);
activeNPCs.add(this);
}

public void show(Player player) {
if (npc == null) return;
npc.getData().showToPlayer(player.getUniqueId());
npc.spawn(player);
if (hologram != null && player.getWorld().getName().equals(hologram.getPosition().getWorldName()))
if (hologram != null && player.getWorld().getName().equals(hologram.getLocation().getWorld().getName()))
Bukkit.getScheduler().runTask(FancyNpcs.getInstance().getPlugin(), () -> hologram.create(player));
}

Expand All @@ -88,7 +87,7 @@ public void showForAll() {
npc.spawnForAll();
if (hologram != null) {
Bukkit.getOnlinePlayers().forEach(player -> {
if (player.getWorld().getName().equals(hologram.getPosition().getWorldName()))
if (player.getWorld().getName().equals(hologram.getLocation().getWorld().getName()))
Bukkit.getScheduler().runTask(FancyNpcs.getInstance().getPlugin(), () -> hologram.create(player));
});
}
Expand All @@ -102,7 +101,7 @@ public void hide(Player player) {
}

public void setActionTitleVisibility(UUID playerUUID, boolean isVisible, boolean enableGlow) {
if (hologram != null && hologram.getHologram(playerUUID) != null && !hologram.getHologram(playerUUID).isDeleted())
if (hologram != null && hologram.getHologram(playerUUID) != null && !hologram.getHologram(playerUUID).isDisabled())
hologram.setActionTitleVisibility(playerUUID, isVisible);
if (npc != null) {
if (npc.getData().isGlowing() != enableGlow) {
Expand Down
22 changes: 11 additions & 11 deletions npc/src/main/java/com/aseanbte/aseanlib/npc/NpcHologram.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@

package com.aseanbte.aseanlib.npc;

import com.alpsbte.alpslib.hologram.HolographicDisplay;
import me.filoghost.holographicdisplays.api.Position;
import com.aseanbte.aseanlib.hologram.DecentHologramDisplay;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.*;

public class NpcHologram extends HolographicDisplay {
public class NpcHologram extends DecentHologramDisplay {
private static final double NPC_HOLOGRAM_Y = 2.3;
private static final double NPC_HOLOGRAM_Y_WITH_ACTION_TITLE = 2.6;

private final AbstractNpc npc;
private final Map<UUID, Boolean> isActionTitleVisible = new HashMap<>();

private Position basePosition;
private Location baseLocation;

public NpcHologram(@NotNull String id, Position position, AbstractNpc npc) {
super(id, position.add(0, NPC_HOLOGRAM_Y, 0), false);
public NpcHologram(@NotNull String id, Location location, AbstractNpc npc) {
super(id, location.add(0, NPC_HOLOGRAM_Y, 0), false);
this.npc = npc;
this.basePosition = position;
this.baseLocation = location;
}

@Override
Expand Down Expand Up @@ -77,15 +77,15 @@ public List<DataLine<?>> getFooter(UUID playerUUID) {
}

@Override
public void setPosition(Position newPosition) {
this.basePosition = newPosition;
public void setLocation(Location newLocation) {
this.baseLocation = newLocation;
for (UUID playerUUID : getHolograms().keySet()) getHolograms().get(playerUUID)
.setPosition(newPosition.add(0, isActionTitleVisible(playerUUID) ? NPC_HOLOGRAM_Y_WITH_ACTION_TITLE : NPC_HOLOGRAM_Y, 0));
.setLocation(newLocation.add(0, isActionTitleVisible(playerUUID) ? NPC_HOLOGRAM_Y_WITH_ACTION_TITLE : NPC_HOLOGRAM_Y, 0));
}

public void setActionTitleVisibility(UUID playerUUID, boolean isVisible) {
isActionTitleVisible.put(playerUUID, isVisible);
getHologram(playerUUID).setPosition(basePosition.add(0, isActionTitleVisible(playerUUID) ? NPC_HOLOGRAM_Y_WITH_ACTION_TITLE : NPC_HOLOGRAM_Y, 0));
getHologram(playerUUID).setLocation(baseLocation.add(0, isActionTitleVisible(playerUUID) ? NPC_HOLOGRAM_Y_WITH_ACTION_TITLE : NPC_HOLOGRAM_Y, 0));
reload(playerUUID);
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.aseanbte.aseanlib</groupId>
<artifactId>aseanlib</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>pom</packaging>

<name>AseanLib</name>
Expand Down
2 changes: 1 addition & 1 deletion utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>aseanlib</artifactId>
<groupId>com.aseanbte.aseanlib</groupId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit a885d82

Please # to comment.