Merge pull request #221 from Olzie-12/msgsounds

Added message sounds
This commit is contained in:
Josua Parks authored and GitHub committed 2022-12-15 13:16:59 -08:00
commit c4148e86fc
4 files changed
+45 -3

No files matched your search

@@ -34,12 +34,15 @@ import net.draycia.carbon.common.command.CommandSettings;
import net.draycia.carbon.common.command.Commander;
import net.draycia.carbon.common.command.PlayerCommander;
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
@@ -48,16 +51,19 @@ public class ContinueCommand extends CarbonCommand {
final CarbonChat carbonChat;
final CommandManager<Commander> commandManager;
final CarbonMessages carbonMessages;
final ConfigFactory configFactory;
@Inject
public ContinueCommand(
final CarbonChat carbonChat,
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages
final CarbonMessages carbonMessages,
final ConfigFactory configFactory
) {
this.carbonChat = carbonChat;
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.configFactory = configFactory;
}
@Override
@@ -128,6 +134,10 @@ public class ContinueCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid());
@@ -34,9 +34,11 @@ import net.draycia.carbon.common.command.CommandSettings;
import net.draycia.carbon.common.command.Commander;
import net.draycia.carbon.common.command.PlayerCommander;
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -49,16 +51,19 @@ public class ReplyCommand extends CarbonCommand {
final CarbonChat carbonChat;
final CommandManager<Commander> commandManager;
final CarbonMessages carbonMessages;
final ConfigFactory configFactory;
@Inject
public ReplyCommand(
final CarbonChat carbonChat,
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages
final CarbonMessages carbonMessages,
final ConfigFactory configFactory
) {
this.carbonChat = carbonChat;
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.configFactory = configFactory;
}
@Override
@@ -128,6 +133,10 @@ public class ReplyCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid());
@@ -33,11 +33,14 @@ import net.draycia.carbon.common.command.Commander;
import net.draycia.carbon.common.command.PlayerCommander;
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
import net.draycia.carbon.common.config.ConfigFactory;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.util.CloudUtils;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
@@ -47,18 +50,21 @@ public class WhisperCommand extends CarbonCommand {
final CommandManager<Commander> commandManager;
final CarbonMessages carbonMessages;
final PlayerSuggestions playerSuggestions;
final ConfigFactory configFactory;
@Inject
public WhisperCommand(
final CarbonChat carbonChat,
final CommandManager<Commander> commandManager,
final CarbonMessages carbonMessages,
final PlayerSuggestions playerSuggestions
final PlayerSuggestions playerSuggestions,
final ConfigFactory configFactory
) {
this.carbonChat = carbonChat;
this.commandManager = commandManager;
this.carbonMessages = carbonMessages;
this.playerSuggestions = playerSuggestions;
this.configFactory = configFactory;
}
@Override
@@ -122,6 +128,10 @@ public class WhisperCommand extends CarbonCommand {
this.carbonMessages.whisperRecipient(new SourcedAudience(sender, recipient), senderName, recipientName, message);
this.carbonMessages.whisperConsoleLog(this.carbonChat.server().console(), senderName, recipientName, message);
final @Nullable Sound messageSound = this.configFactory.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
}
sender.lastWhisperTarget(recipient.uuid());
sender.whisperReplyTarget(recipient.uuid());
recipient.whisperReplyTarget(sender.uuid());
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
@@ -69,6 +70,14 @@ public class PrimaryConfig {
@Comment("Various settings related to pinging players in channels.")
private PingSettings pingSettings = new PingSettings();
@Comment("Various sound settings for messages.")
private @Nullable Sound messageSound = Sound.sound(
Key.key("entity.experience_orb.pickup"),
Sound.Source.MASTER,
1.0F,
1.0F
);
private MessagingSettings messagingSettings = new MessagingSettings();
public Locale defaultLocale() {
@@ -111,6 +120,10 @@ public class PrimaryConfig {
return this.messagingSettings;
}
public @Nullable Sound messageSound() {
return this.messageSound;
}
public enum StorageType {
JSON,
MYSQL,