Add ping permissions, play sounds on velocity

This commit is contained in:
Draycia committed 2026-01-25 23:47:46 -08:00
1 parent 0b4c2c9f99
commit 3e0487ba1f
4 files changed
+17 -8

No files matched your search

@@ -242,8 +242,8 @@ public final class WhisperCommand extends CarbonCommand {
recipientUsername, recipientDisplayName, privateChatEvent.message());
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
if (localRecipient && messageSound != null) {
recipient.playSound(messageSound);
if (localRecipient && messageSound != null && recipient.hasPermission("carbon.whisper.ping_sounds")) {
recipient.playSound(messageSound, Sound.Emitter.self());
}
sender.lastWhisperTarget(recipient.uuid());
@@ -289,8 +289,8 @@ public final class WhisperCommand extends CarbonCommand {
WhisperCommand.broadcastWhisperSpy(this.server, this.messages, senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, privateChatEvent.message());
this.messages.whisperConsoleLog(this.server.console(), senderUsername, senderDisplayName, recipientUsername, recipientDisplayName, privateChatEvent.message());
final @Nullable Sound messageSound = this.configManager.primaryConfig().messageSound();
if (messageSound != null) {
recipient.playSound(messageSound);
if (messageSound != null && recipient.hasPermission("carbon.whisper.ping_sounds")) {
recipient.playSound(messageSound, Sound.Emitter.self());
}
}).exceptionally(ex -> {
this.logger.warn("Failed to handle whisper packet {}", packet, ex);
@@ -22,6 +22,7 @@ package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.channels.PartyChatChannel;
import net.draycia.carbon.common.config.ConfigManager;
import net.kyori.adventure.audience.Audience;
@@ -50,7 +51,11 @@ public class PartyPingHandler implements Listener {
continue;
}
recipient.playSound(sound);
if (recipient instanceof CarbonPlayer player && !player.hasPermission("carbon.parties.ping_sound")) {
continue;
}
recipient.playSound(sound, Sound.Emitter.self());
}
}
});
@@ -28,6 +28,7 @@ import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.config.ConfigManager;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
@@ -75,8 +76,8 @@ public class PingHandler implements Listener {
Pattern.quote(plainDisplayName)),
Pattern.CASE_INSENSITIVE))
.replacement(matchedText -> {
if (this.configManager.primaryConfig().pings().playSound()) {
recipient.playSound(this.configManager.primaryConfig().pings().sound());
if (this.configManager.primaryConfig().pings().playSound() && recipient.hasPermission("carbon.ping_sounds")) {
recipient.playSound(this.configManager.primaryConfig().pings().sound(), Sound.Emitter.self());
}
return Component.text(matchedText.content()).color(this.configManager.primaryConfig().pings().highlightTextColor());
@@ -13,6 +13,8 @@ carbon.ignore.unignore: "Removes the player from the sender's ignore list."
carbon.itemlink: "Shows the player's held or equipped item in chat."
carbon.crossserver: "Allows cross server messages to be received by the player."
carbon.parties: "Allows the creation and use of chat parties."
carbon.parties.ping_sound: "Allows the ping sound to play when receiving party messages."
carbon.ping_sounds: "Allows the ping sound to play when receiving pings."
carbon.mute: "Mutes the player, preventing them from sending messages or whispers."
carbon.mute.exempt: "Prevents the player from being muted."
carbon.mute.info: "Shows if the player is muted or now."
@@ -27,6 +29,7 @@ carbon.whisper: "Sends private messages to other players."
carbon.whisper.continue: "Sends a message to the last player you whispered."
carbon.whisper.reply: "Sends a message to the last player who messaged you."
carbon.whisper.vanished: "Allows the player to send messages to vanished players."
carbon.whisper.ping_sounds: "Allows the ping sound to play when receiving whispers."
# Nickname tag permissions
carbon.nickname.tags.color: "Allows the use of colors in nicknames."
@@ -92,4 +95,4 @@ carbon.messagetags.reset: "Allows the use of the reset tag in messages."
carbon.messagetags.newline: "Allows the use of the newline tag in messages."
carbon.messagetags.pride: "Allows the use of the pride tag in messages."
carbon.messagetags.shadow_color: "Allows the use of the shadow tag in messages."
carbon.messagetags.transition: "Allows the use of the transition tag in messages."
carbon.messagetags.transition: "Allows the use of the transition tag in messages."