Skip to content

Commit

Permalink
fix: item lines not showing to players upon joining (DecentSoftware-e…
Browse files Browse the repository at this point in the history
  • Loading branch information
bridge committed Apr 17, 2024
1 parent e6ac39a commit d1c26c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,21 +633,21 @@ public boolean show(@NonNull Player player, int pageIndex) {
if (page != null && page.size() > 0 && canShow(player) && isInDisplayRange(player)) {
if (isVisible(player)) {
hide(player);
return true; // Skip a tick before updating, should fix the previous issue with clients desyncing.
}
if (Version.after(8)) {
showPageTo(player, page, pageIndex);
} else {
// We need to run the task later on older versions as, if we don't, it causes issues with some holograms *randomly* becoming invisible.
// I *think* this is from despawning and spawning the entities (with the same ID) in the same tick.
S.sync(() -> showPageTo(player, page, pageIndex), 0L);
}

showPageTo(player, page, pageIndex);
return true;
}
return false;
}
}

private void showPageTo(@NonNull Player player, @NonNull HologramPage page, int pageIndex) {
if (page.getLines().stream().anyMatch(line -> !line.canShow(player))) {
return;
}

page.getLines().forEach(line -> line.show(player));
// Add player to viewers
viewerPages.put(player.getUniqueId(), pageIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public void show(Player... players) {
if (parent != null && parent.getParent().isHideState(player)) {
continue;
}

if (!isVisible(player) && canShow(player) && isInDisplayRange(player)) {
switch (type) {
case TEXT:
Expand Down Expand Up @@ -568,7 +569,7 @@ public boolean hasFlag(@NonNull EnumFlag flag) {

@Override
public boolean canShow(@NonNull Player player) {
return super.canShow(player) && (parent == null || parent.getParent().canShow(player));
return super.canShow(player) && (parent == null || parent.getParent().canShow(player)) && (type != HologramLineType.ICON || player.getTicksLived() > 40); // Could be considered hacky but it works?
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public PlayerListener(DecentHolograms decentHolograms) {
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
S.async(() -> decentHolograms.getHologramManager().updateVisibility(player));
decentHolograms.getPacketListener().hook(player);
if (decentHolograms.isUpdateAvailable() && player.hasPermission("dh.admin")) {
Lang.sendUpdateMessage(player);
Expand Down

0 comments on commit d1c26c6

Please sign in to comment.