Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit 745a3c7

Browse files
Fix linking & unlinking with npc
1 parent d1b30f8 commit 745a3c7

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

plugin/src/main/java/de/oliver/fancyholograms/FancyHologramsManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ public void syncHologramWithNpc(@NotNull final Hologram hologram) {
206206

207207
npc.getData().setDisplayName("<empty>");
208208
npc.getData().setShowInTab(false);
209+
npc.updateForAll();
209210

210-
final var location = npc.getData().getLocation().clone().add(0, npc.getEyeHeight(), 0);
211+
final var location = npc.getData().getLocation().clone().add(0, npc.getEyeHeight() + 0.5, 0);
211212
hologram.getData().setLocation(location);
212213
}
213214

plugin/src/main/java/de/oliver/fancyholograms/commands/HologramCMD.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,14 @@ private boolean edit(@NotNull final Player player, @NotNull final Hologram holog
363363

364364
if (action.equals("position")) {
365365
return editLocation(player, hologram, player.getLocation());
366+
} else if (action.equals("unlinkwithnpc")) {
367+
if (!FancyHologramsPlugin.isUsingFancyNpcs()) {
368+
MessageHelper.warning(player, "You need to install the FancyNpcs plugin for this functionality to work");
369+
MessageHelper.warning(player, "Download link: <click:open_url:'https://modrinth.com/plugin/fancynpcs/versions'><u>click here</u></click>.");
370+
return false;
371+
}
372+
373+
return editUnlinkWithNpc(player, hologram);
366374
}
367375

368376
if (args.isEmpty()) {
@@ -576,15 +584,6 @@ private boolean edit(@NotNull final Player player, @NotNull final Hologram holog
576584

577585
yield editLinkWithNpc(player, hologram, args.remove(0));
578586
}
579-
case "unlinkwithnpc" -> {
580-
if (!FancyHologramsPlugin.isUsingFancyNpcs()) {
581-
MessageHelper.warning(player, "You need to install the FancyNpcs plugin for this functionality to work");
582-
MessageHelper.warning(player, "Download link: <click:open_url:'https://modrinth.com/plugin/fancynpcs/versions'><u>click here</u></click>.");
583-
yield false;
584-
}
585-
586-
yield editUnlinkWithNpc(player, hologram);
587-
}
588587
default -> false;
589588
};
590589
}

plugin/src/main/java/de/oliver/fancyholograms/listeners/NpcListener.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public void onModify(@NotNull final NpcModifyEvent event) {
4646
final var players = Bukkit.getOnlinePlayers();
4747

4848
needsToBeUpdated.forEach(this.plugin.getHologramsManager()::syncHologramWithNpc);
49-
needsToBeUpdated.forEach(hologram -> hologram.refreshHologram(players));
49+
needsToBeUpdated.forEach(hologram -> {
50+
hologram.updateHologram();
51+
hologram.refreshHologram(players);
52+
});
5053
});
5154
}
5255
case DISPLAY_NAME, SHOW_IN_TAB -> {

0 commit comments

Comments
 (0)