-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added actions #198
base: main
Are you sure you want to change the base?
Added actions #198
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea, but has a few things that imo need adressing.
I leave it up to d0by on what needs changes tho. This is just suggestions on my end.
@@ -3,7 +3,7 @@ | |||
import org.bukkit.event.block.Action; | |||
|
|||
public enum ClickType { | |||
LEFT, RIGHT, SHIFT_LEFT, SHIFT_RIGHT; | |||
LEFT, RIGHT, SHIFT_LEFT, SHIFT_RIGHT,HOVER,HOVER_LEAVE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of a non-click action (just looking at a page/line) being in a enum specifically for click types.
Given this would only be looking and not looking at a hologram can this be just some lists of actions or similar in the Hologram itself, rather than dedicate an entire type to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply,But I think hovering the mouse over the hologram should also be considered a ClickType. If we put them into actions, it would lose its meaning, as it would be triggered by LEFT_CLICK or RIGHT_CLICK instead of when the mouse hovers over the hologram.
While I acknowledge that my programming skills may have room for improvement, I am open to further discussion and finding a solution that best aligns with the project's needs. What are your thoughts on this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mixed feelings on this to be honest.
On one hand is it nice that you want to add hover support, but on the other hand do I feel like this may not be as good in terms of performance...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it does indeed have performance issues; perhaps it's an immature submission. I hope this PR can remain open for others to see, maybe there are better approaches from others.
src/main/java/eu/decentsoftware/holograms/api/listeners/PlayerListener.java
Show resolved
Hide resolved
if(chunkListMap.isEmpty()) ref(); | ||
|
||
if((System.currentTimeMillis()-orDefault) >= 200L){ | ||
Optional.ofNullable(chunkListMap.get(player.getLocation().getChunk())).ifPresent(list->{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the use of Optionals is needed here. A simple getting and later null check does the same.
src/main/java/eu/decentsoftware/holograms/api/listeners/PlayerListener.java
Show resolved
Hide resolved
Optional.ofNullable(chunkListMap.get(player.getLocation().getChunk())).ifPresent(list->{ | ||
List<Hologram> holograms = list.stream().collect(Collectors.toList()); | ||
Vector playerDirection = player.getEyeLocation().getDirection(); | ||
double threshold = 0.2; // 0.2弧度 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with other comment, use english.
src/main/java/eu/decentsoftware/holograms/api/listeners/PlayerListener.java
Show resolved
Hide resolved
Hologram fromHologram = decentHolograms.getHologramManager().getHologram(currentViewHd); | ||
List<Integer> clickableEntityIds = fromHologram.getPage(player).getClickableEntityIds(); | ||
if(clickableEntityIds.size()>0){ | ||
fromHologram.onClick(player,clickableEntityIds.get(0),ClickType.HOVER_LEAVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have dedicated onHover methods.
Maybe with a boolean to set whether they look on it or not (i.e. onHover(id, boolean)
). The click type feels wrong here.
src/main/java/eu/decentsoftware/holograms/api/listeners/PlayerListener.java
Show resolved
Hide resolved
Hologram fromHologram = decentHolograms.getHologramManager().getHologram(currentViewHd); | ||
List<Integer> clickableEntityIds = fromHologram.getPage(player).getClickableEntityIds(); | ||
if(clickableEntityIds.size()>0){ | ||
fromHologram.onClick(player,clickableEntityIds.get(0),ClickType.HOVER_LEAVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment before.
Added actions HOVER (when the mouse hovers over the hologram), HOVER_LEAVE (when the mouse leaves the hologram)