mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +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
|
||||
*/
|
||||
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.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;
|
||||
@@ -48,16 +49,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 +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());
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.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.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;
|
||||
@@ -49,16 +50,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 +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());
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.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.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;
|
||||
@@ -47,18 +48,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 +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());
|
||||
sender.lastWhisperTarget(recipient.uuid());
|
||||
sender.whisperReplyTarget(recipient.uuid());
|
||||
recipient.whisperReplyTarget(sender.uuid());
|
||||
|
||||
@@ -19,15 +19,13 @@
|
||||
*/
|
||||
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 {
|
||||
public class PingSettings extends SoundSettings {
|
||||
|
||||
@Comment("The color your name will be when another player mentions you.")
|
||||
private TextColor highlightTextColor = NamedTextColor.YELLOW;
|
||||
@@ -35,10 +33,6 @@ public class PingSettings {
|
||||
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;
|
||||
@@ -48,28 +42,8 @@ public class PingSettings {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,6 +69,9 @@ public class PrimaryConfig {
|
||||
@Comment("Various settings related to pinging players in channels.")
|
||||
private PingSettings pingSettings = new PingSettings();
|
||||
|
||||
@Comment("Various sound settings for messages.")
|
||||
private SoundSettings messageSounds = new SoundSettings();
|
||||
|
||||
private MessagingSettings messagingSettings = new MessagingSettings();
|
||||
|
||||
public Locale defaultLocale() {
|
||||
@@ -111,6 +114,10 @@ public class PrimaryConfig {
|
||||
return this.messagingSettings;
|
||||
}
|
||||
|
||||
public SoundSettings messageSounds() {
|
||||
return this.messageSounds;
|
||||
}
|
||||
|
||||
public enum StorageType {
|
||||
JSON,
|
||||
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
|
||||
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) -> {
|
||||
if (!(recipient instanceof CarbonPlayer recipientPlayer)) {
|
||||
return new RenderedMessage(message, MessageType.CHAT);
|
||||
|
||||
@@ -233,5 +233,4 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
public boolean vanished() {
|
||||
return this.carbonPlayerCommon().vanished();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user