mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
fix CarbonPlayerCommon nullability issues
This commit is contained in:
1 parent
272c269c4a
commit
eeb06f404b
1 file changed
+11
-3
@@ -293,7 +293,11 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
|
||||
@Override
|
||||
public @Nullable ChatChannel selectedChannel() {
|
||||
return CarbonChatProvider.carbonChat().channelRegistry().get(this.selectedChannel);
|
||||
if (this.selectedChannel == null) {
|
||||
return this.carbonChat.channelRegistry().defaultValue();
|
||||
}
|
||||
|
||||
return this.carbonChat.channelRegistry().get(this.selectedChannel);
|
||||
}
|
||||
|
||||
public @Nullable Key selectedChannelKey() {
|
||||
@@ -302,10 +306,14 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
|
||||
@Override
|
||||
public void selectedChannel(final @Nullable ChatChannel chatChannel) {
|
||||
this.selectedChannel = chatChannel.key();
|
||||
if (chatChannel == null) {
|
||||
this.selectedChannel = null;
|
||||
} else {
|
||||
this.selectedChannel = chatChannel.key();
|
||||
}
|
||||
|
||||
if (this.carbonChat.server().userManager() instanceof SaveOnChange userManager) {
|
||||
userManager.saveSelectedChannel(this.uuid(), chatChannel.key());
|
||||
userManager.saveSelectedChannel(this.uuid(), this.selectedChannel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user