Some more sounds functionality

This commit is contained in:
libraryaddict 2020-05-24 13:10:48 +12:00
parent 6de71e4fd3
commit e853d02c7e
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
6 changed files with 32 additions and 10 deletions

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.commands.libsdisguises; package me.libraryaddict.disguise.commands.libsdisguises;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg; import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -24,6 +25,7 @@ public class LDReload implements LDCommand {
@Override @Override
public void onCommand(CommandSender sender, String[] args) { public void onCommand(CommandSender sender, String[] args) {
DisguiseConfig.loadConfig(); DisguiseConfig.loadConfig();
new SoundManager().load();
sender.sendMessage(LibsMsg.RELOADED_CONFIG.get()); sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
} }

View File

@ -37,7 +37,7 @@ public abstract class ParamInfo {
public ParamInfo(Class paramClass, String name, String descriptiveName, String description, Enum[] possibleValues) { public ParamInfo(Class paramClass, String name, String descriptiveName, String description, Enum[] possibleValues) {
this(paramClass, name, descriptiveName, description); this(paramClass, name, descriptiveName, description);
this.possibleValues = new HashMap<>(); this.possibleValues = new LinkedHashMap<>();
for (Enum anEnum : possibleValues) { for (Enum anEnum : possibleValues) {
this.getValues().put(anEnum.name(), anEnum); this.getValues().put(anEnum.name(), anEnum);
@ -52,7 +52,7 @@ public abstract class ParamInfo {
Map<String, Object> possibleValues) { Map<String, Object> possibleValues) {
this(paramClass, name, descriptiveName, description); this(paramClass, name, descriptiveName, description);
this.possibleValues = new HashMap<>(); this.possibleValues = new LinkedHashMap<>();
this.possibleValues.putAll(possibleValues); this.possibleValues.putAll(possibleValues);
} }

View File

@ -35,11 +35,7 @@ public class ParamInfoTypes {
} }
public ParamInfoSoundGroup getParamInfoSoundGroup() { public ParamInfoSoundGroup getParamInfoSoundGroup() {
HashMap<String, Object> possibleSoundGroups = new HashMap<>(); return new ParamInfoSoundGroup();
SoundGroup.getGroups().keySet().forEach(key -> possibleSoundGroups.put(key, key));
return new ParamInfoSoundGroup(possibleSoundGroups);
} }
/** /**

View File

@ -1,14 +1,35 @@
package me.libraryaddict.disguise.utilities.params.types.custom; package me.libraryaddict.disguise.utilities.params.types.custom;
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum; import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
import me.libraryaddict.disguise.utilities.sounds.SoundGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
* Created by libraryaddict on 23/05/2020. * Created by libraryaddict on 23/05/2020.
*/ */
public class ParamInfoSoundGroup extends ParamInfoEnum { public class ParamInfoSoundGroup extends ParamInfoEnum {
public ParamInfoSoundGroup(Map<String, Object> possibleValues) { public ParamInfoSoundGroup() {
super(String.class, "SoundGroup", "A group of sounds", possibleValues); super(String.class, "SoundGroup", "A group of sounds", new HashMap<>());
recalculate();
}
public void recalculate() {
LinkedHashMap<String, Object> possibleSoundGroups = new LinkedHashMap<>();
ArrayList<String> list = new ArrayList<>(SoundGroup.getGroups().keySet());
list.sort(String.CASE_INSENSITIVE_ORDER);
for (String s : list) {
possibleSoundGroups.put(s, SoundGroup.getGroup(s));
}
getValues().clear();
getValues().putAll(possibleSoundGroups);
} }
} }

View File

@ -25,7 +25,7 @@ public class SoundGroup {
} }
@Getter @Getter
private final static HashMap<String, SoundGroup> groups = new HashMap<>(); private final static LinkedHashMap<String, SoundGroup> groups = new LinkedHashMap<>();
private float damageSoundVolume = 1F; private float damageSoundVolume = 1F;
@Getter @Getter
private final LinkedHashMap<Object, SoundType> disguiseSounds = new LinkedHashMap<>(); private final LinkedHashMap<Object, SoundType> disguiseSounds = new LinkedHashMap<>();

View File

@ -2,6 +2,7 @@ package me.libraryaddict.disguise.utilities.sounds;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -16,8 +17,10 @@ import java.util.stream.Collectors;
*/ */
public class SoundManager { public class SoundManager {
public void load() { public void load() {
SoundGroup.getGroups().clear();
loadSounds(); loadSounds();
loadCustomSounds(); loadCustomSounds();
ParamInfoManager.getParamInfoSoundGroup().recalculate();
} }
private void loadCustomSounds() { private void loadCustomSounds() {