Skip to content

Commit

Permalink
Click detection for holograms with no actions
Browse files Browse the repository at this point in the history
  • Loading branch information
d0by1 committed Nov 24, 2022
1 parent 65372f5 commit f5d8708
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public void hideAll() {

public void showClickableEntities(@NonNull Player player) {
HologramPage page = getPage(player);
if (page == null || !page.isClickable()) {
if (page == null) {
return;
}

Expand All @@ -593,7 +593,11 @@ public void showClickableEntitiesAll() {

public void hideClickableEntities(@NonNull Player player) {
HologramPage page = getPage(player);
if (page == null || !page.isClickable()) return;
if (page == null) {
return;
}

// Despawn clickable entities
NMS nms = NMS.getInstance();
page.getClickableEntityIds().forEach(id -> nms.hideFakeEntities(player, id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,6 @@ public CommandHandler getCommandHandler() {
page.clearActions(clickType);
hologram.save();
Lang.ACTION_CLEARED.send(sender);
if (!page.isClickable()) {
hologram.hideAll();
hologram.showAll();
}
return true;
};
}
Expand Down Expand Up @@ -475,7 +471,6 @@ public CommandHandler getCommandHandler() {
Lang.PAGE_DOES_NOT_EXIST.send(sender);
return true;
}
boolean wasClickable = page.isClickable();
ClickType clickType = ClickType.fromString(args[2]);
if (clickType == null) {
Lang.CLICK_TYPE_DOES_NOT_EXIST.send(sender, args[2]);
Expand All @@ -490,10 +485,6 @@ public CommandHandler getCommandHandler() {
page.addAction(clickType, action);
hologram.save();
Lang.ACTION_ADDED.send(sender);
if (!wasClickable) {
hologram.hideAll();
hologram.showAll();
}
return true;
};
}
Expand Down Expand Up @@ -536,10 +527,6 @@ public CommandHandler getCommandHandler() {
page.removeAction(clickType, index - 1);
hologram.save();
Lang.ACTION_REMOVED.send(sender);
if (!page.isClickable()) {
hologram.hideAll();
hologram.showAll();
}
return true;
};
}
Expand Down

0 comments on commit f5d8708

Please sign in to comment.