mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
added message sounds
This commit is contained in:
1 parent
a71511abc8
commit
bc960cb16c
9 files changed
+80
-32
No files matched your search
@@ -334,5 +334,4 @@ public interface CarbonPlayer extends Audience, Identified {
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
boolean awareOf(final CarbonPlayer other);
|
boolean awareOf(final CarbonPlayer other);
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-1
@@ -34,6 +34,7 @@ import net.draycia.carbon.common.command.CommandSettings;
|
|||||||
import net.draycia.carbon.common.command.Commander;
|
import net.draycia.carbon.common.command.Commander;
|
||||||
import net.draycia.carbon.common.command.PlayerCommander;
|
import net.draycia.carbon.common.command.PlayerCommander;
|
||||||
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
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.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;
|
||||||
@@ -48,16 +49,19 @@ public class ContinueCommand extends CarbonCommand {
|
|||||||
final CarbonChat carbonChat;
|
final CarbonChat carbonChat;
|
||||||
final CommandManager<Commander> commandManager;
|
final CommandManager<Commander> commandManager;
|
||||||
final CarbonMessages carbonMessages;
|
final CarbonMessages carbonMessages;
|
||||||
|
final ConfigFactory configFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ContinueCommand(
|
public ContinueCommand(
|
||||||
final CarbonChat carbonChat,
|
final CarbonChat carbonChat,
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages
|
final CarbonMessages carbonMessages,
|
||||||
|
final ConfigFactory configFactory
|
||||||
) {
|
) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.carbonMessages = carbonMessages;
|
||||||
|
this.configFactory = configFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,6 +132,7 @@ 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().sound());
|
||||||
sender.lastWhisperTarget(recipient.uuid());
|
sender.lastWhisperTarget(recipient.uuid());
|
||||||
sender.whisperReplyTarget(recipient.uuid());
|
sender.whisperReplyTarget(recipient.uuid());
|
||||||
recipient.whisperReplyTarget(sender.uuid());
|
recipient.whisperReplyTarget(sender.uuid());
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import net.draycia.carbon.common.command.CommandSettings;
|
|||||||
import net.draycia.carbon.common.command.Commander;
|
import net.draycia.carbon.common.command.Commander;
|
||||||
import net.draycia.carbon.common.command.PlayerCommander;
|
import net.draycia.carbon.common.command.PlayerCommander;
|
||||||
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
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.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;
|
||||||
@@ -49,16 +50,19 @@ public class ReplyCommand extends CarbonCommand {
|
|||||||
final CarbonChat carbonChat;
|
final CarbonChat carbonChat;
|
||||||
final CommandManager<Commander> commandManager;
|
final CommandManager<Commander> commandManager;
|
||||||
final CarbonMessages carbonMessages;
|
final CarbonMessages carbonMessages;
|
||||||
|
final ConfigFactory configFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ReplyCommand(
|
public ReplyCommand(
|
||||||
final CarbonChat carbonChat,
|
final CarbonChat carbonChat,
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages
|
final CarbonMessages carbonMessages,
|
||||||
|
final ConfigFactory configFactory
|
||||||
) {
|
) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.carbonMessages = carbonMessages;
|
||||||
|
this.configFactory = configFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,6 +132,7 @@ 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().sound());
|
||||||
sender.lastWhisperTarget(recipient.uuid());
|
sender.lastWhisperTarget(recipient.uuid());
|
||||||
sender.whisperReplyTarget(recipient.uuid());
|
sender.whisperReplyTarget(recipient.uuid());
|
||||||
recipient.whisperReplyTarget(sender.uuid());
|
recipient.whisperReplyTarget(sender.uuid());
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import net.draycia.carbon.common.command.Commander;
|
|||||||
import net.draycia.carbon.common.command.PlayerCommander;
|
import net.draycia.carbon.common.command.PlayerCommander;
|
||||||
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
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.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;
|
||||||
@@ -47,18 +48,21 @@ public class WhisperCommand extends CarbonCommand {
|
|||||||
final CommandManager<Commander> commandManager;
|
final CommandManager<Commander> commandManager;
|
||||||
final CarbonMessages carbonMessages;
|
final CarbonMessages carbonMessages;
|
||||||
final PlayerSuggestions playerSuggestions;
|
final PlayerSuggestions playerSuggestions;
|
||||||
|
final ConfigFactory configFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WhisperCommand(
|
public WhisperCommand(
|
||||||
final CarbonChat carbonChat,
|
final CarbonChat carbonChat,
|
||||||
final CommandManager<Commander> commandManager,
|
final CommandManager<Commander> commandManager,
|
||||||
final CarbonMessages carbonMessages,
|
final CarbonMessages carbonMessages,
|
||||||
final PlayerSuggestions playerSuggestions
|
final PlayerSuggestions playerSuggestions,
|
||||||
|
final ConfigFactory configFactory
|
||||||
) {
|
) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.carbonMessages = carbonMessages;
|
this.carbonMessages = carbonMessages;
|
||||||
this.playerSuggestions = playerSuggestions;
|
this.playerSuggestions = playerSuggestions;
|
||||||
|
this.configFactory = configFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -122,6 +126,7 @@ 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().sound());
|
||||||
sender.lastWhisperTarget(recipient.uuid());
|
sender.lastWhisperTarget(recipient.uuid());
|
||||||
sender.whisperReplyTarget(recipient.uuid());
|
sender.whisperReplyTarget(recipient.uuid());
|
||||||
recipient.whisperReplyTarget(sender.uuid());
|
recipient.whisperReplyTarget(sender.uuid());
|
||||||
|
|||||||
@@ -19,15 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
package net.draycia.carbon.common.config;
|
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.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class PingSettings {
|
public class PingSettings extends SoundSettings {
|
||||||
|
|
||||||
@Comment("The color your name will be when another player mentions you.")
|
@Comment("The color your name will be when another player mentions you.")
|
||||||
private TextColor highlightTextColor = NamedTextColor.YELLOW;
|
private TextColor highlightTextColor = NamedTextColor.YELLOW;
|
||||||
@@ -35,10 +33,6 @@ public class PingSettings {
|
|||||||
private String prefix = "@";
|
private String prefix = "@";
|
||||||
|
|
||||||
private boolean playSound = false;
|
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() {
|
public TextColor highlightTextColor() {
|
||||||
return this.highlightTextColor;
|
return this.highlightTextColor;
|
||||||
@@ -48,28 +42,8 @@ public class PingSettings {
|
|||||||
return this.playSound;
|
return this.playSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key name() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String prefix() {
|
public String prefix() {
|
||||||
return this.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,9 @@ public class PrimaryConfig {
|
|||||||
@Comment("Various settings related to pinging players in channels.")
|
@Comment("Various settings related to pinging players in channels.")
|
||||||
private PingSettings pingSettings = new PingSettings();
|
private PingSettings pingSettings = new PingSettings();
|
||||||
|
|
||||||
|
@Comment("Various sound settings for messages.")
|
||||||
|
private SoundSettings messageSounds = new SoundSettings();
|
||||||
|
|
||||||
private MessagingSettings messagingSettings = new MessagingSettings();
|
private MessagingSettings messagingSettings = new MessagingSettings();
|
||||||
|
|
||||||
public Locale defaultLocale() {
|
public Locale defaultLocale() {
|
||||||
@@ -111,6 +114,10 @@ public class PrimaryConfig {
|
|||||||
return this.messagingSettings;
|
return this.messagingSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SoundSettings messageSounds() {
|
||||||
|
return this.messageSounds;
|
||||||
|
}
|
||||||
|
|
||||||
public enum StorageType {
|
public enum StorageType {
|
||||||
JSON,
|
JSON,
|
||||||
MYSQL,
|
MYSQL,
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@ 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);
|
||||||
|
|||||||
@@ -233,5 +233,4 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
|||||||
public boolean vanished() {
|
public boolean vanished() {
|
||||||
return this.carbonPlayerCommon().vanished();
|
return this.carbonPlayerCommon().vanished();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user