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

Do not keep player in trackedPlayers if the Pre track event was cance… #119

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ public boolean tracksPlayer(@NotNull P player) {
@Override
public @NotNull Npc<W, P, I, E> forceTrackPlayer(@NotNull P player) {
// check if the player is not already tracked
if (this.trackedPlayers.add(player)) {
if (!this.trackedPlayers.contains(player)) {
// break early if the add is not wanted by plugin
if (this.platform.eventManager().post(DefaultShowNpcEvent.pre(this, player)).cancelled()) {
return this;
}

// add the player
this.trackedPlayers.add(player);

// send the player info packet
this.platform.packetFactory().createPlayerInfoPacket(PlayerInfoAction.ADD_PLAYER).schedule(player, this);

Expand Down