Sound is now Nullable

messageSound is now singular not plural
Removed ToDo
This commit is contained in:
Olzie-12 committed 2022-12-15 20:33:10 +00:00
1 parent c00e614abf
commit 2d194bbb3e
5 files changed
+21 -7

No files matched your search

@@ -38,9 +38,11 @@ import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages; import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils; import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier; import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class) @DefaultQualifier(NonNull.class)
@@ -132,7 +134,10 @@ public class ContinueCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message); this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
recipient.playSound(this.configFactory.primaryConfig().messageSounds()); final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid()); sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid()); recipient.whisperReplyTarget(sender.uuid());
@@ -38,6 +38,7 @@ import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages; import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils; import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@@ -132,7 +133,10 @@ public class ReplyCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message); this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
recipient.playSound(this.configFactory.primaryConfig().messageSounds()); final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid()); sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid()); recipient.whisperReplyTarget(sender.uuid());
@@ -37,8 +37,10 @@ import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages; import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils; import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier; import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class) @DefaultQualifier(NonNull.class)
@@ -126,7 +128,10 @@ public class WhisperCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message); this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message); this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
recipient.playSound(this.configFactory.primaryConfig().messageSounds()); final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid()); sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid()); recipient.whisperReplyTarget(sender.uuid());
@@ -71,7 +71,7 @@ public class PrimaryConfig {
private PingSettings pingSettings = new PingSettings(); private PingSettings pingSettings = new PingSettings();
@Comment("Various sound settings for messages.") @Comment("Various sound settings for messages.")
private Sound messageSounds = Sound.sound( private Sound messageSound = Sound.sound(
Key.key("entity.experience_orb.pickup"), Key.key("entity.experience_orb.pickup"),
Sound.Source.MASTER, Sound.Source.MASTER,
1.0F, 1.0F,
@@ -120,8 +120,9 @@ public class PrimaryConfig {
return this.messagingSettings; return this.messagingSettings;
} }
public Sound messageSounds() { @Nullable
return this.messageSounds; public Sound messageSound() {
return this.messageSound;
} }
public enum StorageType { public enum StorageType {
@@ -45,7 +45,6 @@ public class PingHandler {
@Inject @Inject
public PingHandler(final CarbonChat carbonChat, final ConfigFactory configFactory) { public PingHandler(final CarbonChat carbonChat, final ConfigFactory configFactory) {
//TODO: there is an issue with this, it only works if the player is sending the message pings themself
this.renderer = keyedRenderer(this.muteKey, (sender, recipient, message, originalMessage) -> { this.renderer = keyedRenderer(this.muteKey, (sender, recipient, message, originalMessage) -> {
if (!(recipient instanceof CarbonPlayer recipientPlayer)) { if (!(recipient instanceof CarbonPlayer recipientPlayer)) {
return new RenderedMessage(message, MessageType.CHAT); return new RenderedMessage(message, MessageType.CHAT);