feat(bukkit): 允许设置某些特定按钮没有点击音效

This commit is contained in:
2023-01-22 02:01:50 +08:00
parent 7797a95d89
commit 74ea265f31
2 changed files with 7 additions and 1 deletions

View File

@@ -90,8 +90,13 @@ public class PageConfig implements InventoryHolder {
ConfigurationSection buttonSoundConfig = rawConfig.getConfigurationSection("sounds"); ConfigurationSection buttonSoundConfig = rawConfig.getConfigurationSection("sounds");
if (buttonSoundConfig != null) { if (buttonSoundConfig != null) {
for (String key : buttonSoundConfig.getKeys(false)) { for (String key : buttonSoundConfig.getKeys(false)) {
String soundName = buttonSoundConfig.getString(key, "");
if (soundName.isEmpty() || soundName.equalsIgnoreCase("null")) {
buttonSounds.put(key, null);
continue;
}
try { try {
buttonSounds.put(key, Sound.valueOf(buttonSoundConfig.getString(key))); buttonSounds.put(key, Sound.valueOf(soundName));
} catch (Exception e) { } catch (Exception e) {
HamsterCorePlugin.getInstance().getLogger().warning("初始化 PageConfig 时遇到了一个异常:"); HamsterCorePlugin.getInstance().getLogger().warning("初始化 PageConfig 时遇到了一个异常:");
e.printStackTrace(); e.printStackTrace();

View File

@@ -14,6 +14,7 @@ groups:
'!': "info" '!': "info"
sounds: sounds:
"empty": ""
"default": "UI_BUTTON_CLICK" "default": "UI_BUTTON_CLICK"
"accept": "ENTITY_PLAYER_LEVELUP" "accept": "ENTITY_PLAYER_LEVELUP"
"deny": "BLOCK_ANVIL_HIT" "deny": "BLOCK_ANVIL_HIT"