Skip to content

Commit

Permalink
Do not track player if the pre-track event was cancelled (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptite authored Feb 28, 2024
1 parent cb63472 commit 36e6dc6
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 36e6dc6

Please sign in to comment.