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

Add "/hologram search" command #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Seshpenguin
Copy link
Contributor

@Seshpenguin Seshpenguin commented Nov 14, 2023

Adds a new command that allows filtering of the hologram list. The code is mostly identical to the ListCMD code, the most relevant addition being .filter(holo -> holo.getData().getName().contains(search)) and the pages calculation.

image

MessageHelper.info(player, "<b>Search results:</b>");
MessageHelper.info(player, "<b>Page %s/%s</b>".formatted(page, pages));
holograms.stream()
.filter(holo -> holo.getData().getName().contains(search))
Copy link
Contributor

Choose a reason for hiding this comment

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

It could be worth making the filter not case sensitive to increase returned searches.

Suggested change
.filter(holo -> holo.getData().getName().contains(search))
.filter(holo -> holo.getData().getName().toLowerCase().contains(search.toLowerCase()))

page = index;
}

var pages = holograms.stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of running 2 streams on holograms it could be worth moving the stream from line 52 here and creating an unmodifiable list with toList(). To check if the page exists you can then just run List#isEmpty.

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.

None yet

2 participants