added interaction sounds to settings

This commit is contained in:
2025-07-19 16:36:31 +02:00
parent 977f4ff4ec
commit ef6f34c2b2
3 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.datatypes.Setting; import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.datatypes.Setting;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.listeners.OpenSettingsShortcutListener; import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.listeners.OpenSettingsShortcutListener;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.listeners.SettingsInventoryListener; import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.listeners.SettingsInventoryListener;
import eu.mhsl.craftattack.spawn.core.util.world.InteractSounds;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -136,6 +137,7 @@ public class Settings extends Appliance {
} }
player.openInventory(inventory); player.openInventory(inventory);
InteractSounds.of(player).open();
this.openSettingsInventories.put(player, new OpenSettingsInventory(inventory, settings)); this.openSettingsInventories.put(player, new OpenSettingsInventory(inventory, settings));
} }
@ -166,6 +168,7 @@ public class Settings extends Appliance {
if(!this.openSettingsInventories.containsKey(player)) return; if(!this.openSettingsInventories.containsKey(player)) return;
this.openSettingsInventories.remove(player); this.openSettingsInventories.remove(player);
player.updateInventory(); player.updateInventory();
InteractSounds.of(player).close();
} }
public boolean hasSettingsNotOpen(Player player) { public boolean hasSettingsNotOpen(Player player) {

View File

@ -3,6 +3,7 @@ package eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.dataty
import eu.mhsl.craftattack.spawn.core.Main; import eu.mhsl.craftattack.spawn.core.Main;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.Settings; import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.settings.Settings;
import eu.mhsl.craftattack.spawn.core.util.text.ComponentUtil; import eu.mhsl.craftattack.spawn.core.util.text.ComponentUtil;
import eu.mhsl.craftattack.spawn.core.util.world.InteractSounds;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -37,7 +38,9 @@ public abstract class Setting<TDataType> {
} }
public void triggerChange(Player p, ClickType clickType) { public void triggerChange(Player p, ClickType clickType) {
if(clickType.equals(ClickType.DOUBLE_CLICK)) return;
this.change(p, clickType); this.change(p, clickType);
InteractSounds.of(p).click();
this.toStorage(p.getPersistentDataContainer(), this.state()); this.toStorage(p.getPersistentDataContainer(), this.state());
} }

View File

@ -34,4 +34,12 @@ public class InteractSounds {
public void delete() { public void delete() {
this.playSound(SoundEventKeys.ENTITY_SILVERFISH_DEATH); this.playSound(SoundEventKeys.ENTITY_SILVERFISH_DEATH);
} }
public void open() {
this.playSound(SoundEventKeys.BLOCK_BARREL_OPEN);
}
public void close() {
this.playSound(SoundEventKeys.BLOCK_BARREL_CLOSE);
}
} }