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());