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

Set whisper targets to persist #622

Merged
merged 1 commit into from
Feb 23, 2025
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 @@ -75,8 +75,8 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
protected final PersistentUserProperty<Component> displayName;

// Whispers
protected transient @Nullable UUID lastWhisperTarget = null;
protected transient @Nullable UUID whisperReplyTarget = null;
protected final PersistentUserProperty<UUID> lastWhisperTarget;
protected final PersistentUserProperty<UUID> whisperReplyTarget;
protected final PersistentUserProperty<Boolean> ignoringDirectMessages;

// Administrative
Expand Down Expand Up @@ -112,8 +112,8 @@ public CarbonPlayerCommon(
this.username = username;
this.uuid = uuid;
this.displayName = PersistentUserProperty.of(displayName);
this.lastWhisperTarget = lastWhisperTarget;
this.whisperReplyTarget = whisperReplyTarget;
this.lastWhisperTarget = PersistentUserProperty.of(lastWhisperTarget);
this.whisperReplyTarget = PersistentUserProperty.of(whisperReplyTarget);
this.spying = PersistentUserProperty.of(spying);
this.ignoredPlayers = PersistentUserProperty.of(Collections.emptySet());
this.leftChannels = PersistentUserProperty.of(Collections.emptySet());
Expand All @@ -131,6 +131,8 @@ public CarbonPlayerCommon(
this.deafened = PersistentUserProperty.of(false);
this.selectedChannel = PersistentUserProperty.empty();
this.displayName = PersistentUserProperty.empty();
this.lastWhisperTarget = PersistentUserProperty.empty();
this.whisperReplyTarget = PersistentUserProperty.empty();
this.spying = PersistentUserProperty.of(false);
this.ignoredPlayers = PersistentUserProperty.of(Collections.emptySet());
this.leftChannels = PersistentUserProperty.of(Collections.emptySet());
Expand All @@ -147,6 +149,8 @@ public CarbonPlayerCommon() {
this.deafened = PersistentUserProperty.of(false);
this.selectedChannel = PersistentUserProperty.empty();
this.displayName = PersistentUserProperty.empty();
this.lastWhisperTarget = PersistentUserProperty.empty();
this.whisperReplyTarget = PersistentUserProperty.empty();
this.spying = PersistentUserProperty.of(false);
this.applyOptionalChatFilters = PersistentUserProperty.of(false);
this.ignoredPlayers = PersistentUserProperty.of(Collections.emptySet());
Expand All @@ -166,6 +170,8 @@ private Stream<PersistentUserProperty<?>> properties() {
this.deafened,
this.selectedChannel,
this.displayName,
this.lastWhisperTarget,
this.whisperReplyTarget,
this.spying,
this.applyOptionalChatFilters,
this.ignoredPlayers,
Expand Down Expand Up @@ -334,22 +340,22 @@ public boolean online() {

@Override
public @Nullable UUID whisperReplyTarget() {
return this.whisperReplyTarget;
return this.whisperReplyTarget.orNull();
}

@Override
public void whisperReplyTarget(final @Nullable UUID whisperReplyTarget) {
this.whisperReplyTarget = whisperReplyTarget;
this.whisperReplyTarget.set(whisperReplyTarget);
}

@Override
public @Nullable UUID lastWhisperTarget() {
return this.lastWhisperTarget;
return this.lastWhisperTarget.orNull();
}

@Override
public void lastWhisperTarget(final @Nullable UUID lastWhisperTarget) {
this.lastWhisperTarget = lastWhisperTarget;
this.lastWhisperTarget.set(lastWhisperTarget);
}

@Override
Expand Down
Loading