Adding CHAT_AND_ACTION type and Sounds (#114)

* Added CHAT_AND_ACTION to MessageType

* Implement command denied sounds

* Add feature to play sounds on denied commands

* Added comment to command_denied_sound

* Added comment to command_denied_sound

* Added Sounds and CHAT_AND_ACTION to Waterfall

* minor qol changes
do not show configs for features on platforms that don't benefit from them
make the new message type enum more clear

---------

Co-authored-by: YouHaveTrouble <youhavetrouble@youhavetrouble.me>
This commit is contained in:
iM7mD :)
2026-10-11 13:47:52 +02:00
committed by GitHub
co-authored by YouHaveTrouble
parent 55ee46e167
commit e75ef8aa3f
8 changed files with 91 additions and 14 deletions
@@ -62,7 +62,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
public void loadConfig() {
if (configCache == null)
configCache = new ConfigCache(new File(getDataFolder(), "config.yml"), false, getLogger());
configCache = new ConfigCache(new File(getDataFolder(), "config.yml"), false, true, getLogger());
else
configCache.reloadConfig();
}
@@ -5,7 +5,9 @@ import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent;
@@ -45,6 +47,21 @@ public class BungeeChatEventListener implements Listener {
case ACTIONBAR:
audiences.player(player).sendActionBar(message);
break;
case CHAT_AND_ACTIONBAR:
audiences.player(player).sendMessage(message);
audiences.player(player).sendActionBar(message);
break;
}
if(configCache.command_denied_sound_enabled) {
try {
String soundKey = configCache.command_denied_sound_key;
Key sound = Key.key(soundKey);
float soundVolume = configCache.command_denied_sound_volume;
float soundPitch = configCache.command_denied_sound_pitch;
audiences.player(player).playSound(Sound.sound(sound, Sound.Source.UI, soundVolume, soundPitch));
} catch (Exception e) {
configCache.warn("Invalid sound. unable to play sound!");
}
}
return;
}