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
@@ -72,9 +72,9 @@ public class CommandWhitelistBukkit extends JavaPlugin {
File configFile = new File("plugins/CommandWhitelist/config.yml");
if (configCache == null) {
try {
configCache = new ConfigCache(configFile, true, getSLF4JLogger());
configCache = new ConfigCache(configFile, true, true, getSLF4JLogger());
} catch (NoSuchMethodError e) {
configCache = new ConfigCache(configFile, true, null);
configCache = new ConfigCache(configFile, true, true, null);
}
return;
}
@@ -5,7 +5,9 @@ import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -41,6 +43,22 @@ public class PlayerCommandPreProcessListener 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(config.command_denied_sound_enabled) {
try {
String soundKey = config.command_denied_sound_key;
Key sound = Key.key(soundKey);
float soundVolume = config.command_denied_sound_volume;
float soundPitch = config.command_denied_sound_pitch;
audiences.player(player).playSound(Sound.sound(sound, Sound.Source.UI, soundVolume, soundPitch));
} catch (Exception e) {
config.warn("Invalid sound. unable to play sound!");
}
}
return;
}