From fce57537a04329591475d5e9c8eb6e2349520df0 Mon Sep 17 00:00:00 2001 From: Olzie-12 Date: Thu, 15 Dec 2022 16:45:06 +0000 Subject: [PATCH] changed to Adventure's sound object --- .../command/commands/ContinueCommand.java | 2 +- .../common/command/commands/ReplyCommand.java | 2 +- .../command/commands/WhisperCommand.java | 2 +- .../carbon/common/config/PingSettings.java | 28 +++++++++- .../carbon/common/config/PrimaryConfig.java | 10 +++- .../carbon/common/config/SoundSettings.java | 53 ------------------- 6 files changed, 38 insertions(+), 59 deletions(-) delete mode 100644 common/src/main/java/net/draycia/carbon/common/config/SoundSettings.java diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java index 761e108a..efad7940 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java @@ -132,7 +132,7 @@ 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); - recipient.playSound(this.configFactory.primaryConfig().messageSounds().sound()); + recipient.playSound(this.configFactory.primaryConfig().messageSounds()); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); recipient.whisperReplyTarget(sender.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java index 1a073e19..f27e25e8 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java @@ -132,7 +132,7 @@ 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); - recipient.playSound(this.configFactory.primaryConfig().messageSounds().sound()); + recipient.playSound(this.configFactory.primaryConfig().messageSounds()); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); recipient.whisperReplyTarget(sender.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java index 28bdbdd6..fa44e90e 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java @@ -126,7 +126,7 @@ 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); - recipient.playSound(this.configFactory.primaryConfig().messageSounds().sound()); + recipient.playSound(this.configFactory.primaryConfig().messageSounds()); sender.lastWhisperTarget(recipient.uuid()); sender.whisperReplyTarget(recipient.uuid()); recipient.whisperReplyTarget(sender.uuid()); diff --git a/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java b/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java index 0e8359be..615e531f 100644 --- a/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java +++ b/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java @@ -19,13 +19,15 @@ */ package net.draycia.carbon.common.config; +import net.kyori.adventure.key.Key; +import net.kyori.adventure.sound.Sound; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.meta.Comment; @ConfigSerializable -public class PingSettings extends SoundSettings { +public class PingSettings { @Comment("The color your name will be when another player mentions you.") private TextColor highlightTextColor = NamedTextColor.YELLOW; @@ -33,6 +35,10 @@ public class PingSettings extends SoundSettings { private String prefix = "@"; private boolean playSound = false; + private Key name = Key.key("block.anvil.use"); + private Sound.Source source = Sound.Source.MASTER; + private float volume = 1.0f; // 0.0 -> infinity + private float pitch = 1.0f; // 0.0 -> 2.0 public TextColor highlightTextColor() { return this.highlightTextColor; @@ -42,8 +48,28 @@ public class PingSettings extends SoundSettings { return this.playSound; } + public Key name() { + return this.name; + } + public String prefix() { return this.prefix; } + public Sound.Source source() { + return this.source; + } + + public float volume() { + return this.volume; + } + + public float pitch() { + return this.pitch; + } + + public Sound sound() { + return Sound.sound(this.name, this.source, this.volume, this.pitch); + } + } diff --git a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java index ef7e3f98..69ed0344 100644 --- a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java +++ b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java @@ -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; @@ -70,7 +71,12 @@ public class PrimaryConfig { private PingSettings pingSettings = new PingSettings(); @Comment("Various sound settings for messages.") - private SoundSettings messageSounds = new SoundSettings(); + private Sound messageSounds = Sound.sound( + Key.key("entity.experience_orb.pickup"), + Sound.Source.MASTER, + 1.0F, + 1.0F + ); private MessagingSettings messagingSettings = new MessagingSettings(); @@ -114,7 +120,7 @@ public class PrimaryConfig { return this.messagingSettings; } - public SoundSettings messageSounds() { + public Sound messageSounds() { return this.messageSounds; } diff --git a/common/src/main/java/net/draycia/carbon/common/config/SoundSettings.java b/common/src/main/java/net/draycia/carbon/common/config/SoundSettings.java deleted file mode 100644 index 23d1b99a..00000000 --- a/common/src/main/java/net/draycia/carbon/common/config/SoundSettings.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * CarbonChat - * - * Copyright (c) 2021 Josua Parks (Vicarious) - * Contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package net.draycia.carbon.common.config; - -import net.kyori.adventure.key.Key; -import net.kyori.adventure.sound.Sound; -import org.spongepowered.configurate.objectmapping.ConfigSerializable; - -@ConfigSerializable -public class SoundSettings { - - private Key name = Key.key("entity.arrow.hit_player"); - private Sound.Source source = Sound.Source.MASTER; - private float volume = 1.0f; // 0.0 -> infinity - private float pitch = 1.0f; // 0.0 -> 2.0 - - public Key name() { - return this.name; - } - - public Sound.Source source() { - return this.source; - } - - public float volume() { - return this.volume; - } - - public float pitch() { - return this.pitch; - } - - public Sound sound() { - return Sound.sound(this.name, this.source, this.volume, this.pitch); - } -}