Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added actions #198

wants to merge 1 commit into from

Conversation

meteorOSS
Copy link

Added actions HOVER (when the mouse hovers over the hologram), HOVER_LEAVE (when the mouse leaves the hologram)

Copy link
Contributor

@Andre601 Andre601 left a 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;
Copy link
Contributor

@Andre601 Andre601 Mar 4, 2024

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.

Copy link
Author

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?

Copy link
Contributor

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...

Copy link
Author

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.

if(chunkListMap.isEmpty()) ref();

if((System.currentTimeMillis()-orDefault) >= 200L){
Optional.ofNullable(chunkListMap.get(player.getLocation().getChunk())).ifPresent(list->{
Copy link
Contributor

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.

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弧度
Copy link
Contributor

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.

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);
Copy link
Contributor

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.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants