perf(bukkit): 优化 gui 按钮声音播放代码
This commit is contained in:
@@ -54,13 +54,22 @@ public abstract class PageHandler implements InventoryHolder {
|
||||
}
|
||||
|
||||
public void onPlayButtonSound(@NotNull ClickType clickType, @NotNull InventoryAction action, int index) {
|
||||
PageConfig config = getPageConfig();
|
||||
Sound sound = config.getButtonSound(getButtonGroup().getButtonName(index));
|
||||
sound = sound == null ? config.getButtonSound("default") : sound;
|
||||
if (sound == null) {
|
||||
if (!(player instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(player instanceof Player)) {
|
||||
PageConfig config = getPageConfig();
|
||||
String buttonName = getButtonGroup().getButtonName(index);
|
||||
Sound sound = config.getButtonSound(buttonName);
|
||||
if (sound == null) {
|
||||
switch (buttonName) {
|
||||
case "empty":
|
||||
case "barrier":
|
||||
break;
|
||||
default:
|
||||
sound = config.getButtonSound("default");
|
||||
}
|
||||
}
|
||||
if (sound == null) {
|
||||
return;
|
||||
}
|
||||
((Player) player).playSound(player.getLocation(), sound, 1, 1);
|
||||
|
Reference in New Issue
Block a user