Skip to content

Guidebook send event#22

Open
Drayz64 wants to merge 4 commits intoMCME:developmentfrom
Drayz64:guidebook-send-event
Open

Guidebook send event#22
Drayz64 wants to merge 4 commits intoMCME:developmentfrom
Drayz64:guidebook-send-event

Conversation

@Drayz64
Copy link

@Drayz64 Drayz64 commented Apr 21, 2025

No description provided.

@Drayz64 Drayz64 force-pushed the guidebook-send-event branch from 8a8f036 to a3940e4 Compare April 21, 2025 16:03
@Drayz64 Drayz64 force-pushed the guidebook-send-event branch from a3940e4 to 59c4224 Compare April 21, 2025 16:15
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class GuidebookSendEvent extends Event implements Cancellable {
Copy link
Author

Choose a reason for hiding this comment

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

I'm thinking this should be GuidebookEnterEvent instead

}

private boolean getMatchingSegments(String input, String searchTerm) {
private boolean matchesAnySegment(String input, String searchTerm) {
Copy link
Author

@Drayz64 Drayz64 Apr 21, 2025

Choose a reason for hiding this comment

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

The current name was misleading

InfoArea area = PluginData.getInfoAreas().get(key);
if (area.isInside(playerLocation) && !area.isInformed(player)
&& area.isEnable() && !PluginData.isExcluded(player)) {
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
Copy link
Author

@Drayz64 Drayz64 Apr 21, 2025

Choose a reason for hiding this comment

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

Minor optimisations

  • Storing the filtered info areas before the Player loop
  • Only doing the isNear check if the player is known to be inside the area

Other than that the main change is moving PluginData.isExcluded(player) to be inside onRegionEnter

private List<String> description = new ArrayList<>();

protected InfoArea() {
protected InfoArea(String areaName) {
Copy link
Author

@Drayz64 Drayz64 Apr 21, 2025

Choose a reason for hiding this comment

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

Since the GuidebookSendEvent is called inside InfoArea the area needed to know its own name - I've then been able to use the areaName in a few unrelated places

@Drayz64 Drayz64 marked this pull request as ready for review April 21, 2025 16:25
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.

1 participant