mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
fix CarbonPlayerCommon nullability issues
This commit is contained in:
1 parent
272c269c4a
commit
eeb06f404b
1 file changed
+10
-2
@@ -293,7 +293,11 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ChatChannel selectedChannel() {
|
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() {
|
public @Nullable Key selectedChannelKey() {
|
||||||
@@ -302,10 +306,14 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectedChannel(final @Nullable ChatChannel chatChannel) {
|
public void selectedChannel(final @Nullable ChatChannel chatChannel) {
|
||||||
|
if (chatChannel == null) {
|
||||||
|
this.selectedChannel = null;
|
||||||
|
} else {
|
||||||
this.selectedChannel = chatChannel.key();
|
this.selectedChannel = chatChannel.key();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.carbonChat.server().userManager() instanceof SaveOnChange userManager) {
|
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