All checks were successful
KnarCraft/BlacksmithVisuals/pipeline/head This commit looks good
79 lines
2.7 KiB
Java
79 lines
2.7 KiB
Java
package net.knarcraft.blacksmithvisuals.manager;
|
|
|
|
import net.knarcraft.blacksmithvisuals.container.AnimationData;
|
|
import net.knarcraft.blacksmithvisuals.container.SoundData;
|
|
import net.knarcraft.blacksmithvisuals.property.SoundIdentifier;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* A manager keeping track of configuration options
|
|
*/
|
|
public class ConfigurationManager {
|
|
|
|
private Map<SoundIdentifier, SoundData> soundSettings;
|
|
private AnimationData scrapperAnimationData;
|
|
private AnimationData blacksmithAnimationData;
|
|
|
|
/**
|
|
* Instantiates a new configuration manager
|
|
*
|
|
* @param fileConfiguration <p>The file configuration to load values from</p>
|
|
* @throws InvalidConfigurationException <p>If the configuration file has missing or invalid values</p>
|
|
*/
|
|
public ConfigurationManager(@NotNull FileConfiguration fileConfiguration) throws InvalidConfigurationException {
|
|
load(fileConfiguration);
|
|
}
|
|
|
|
/**
|
|
* Loads the configuration from disk
|
|
*
|
|
* @param fileConfiguration <p>The file configuration to get values from</p>
|
|
* @throws InvalidConfigurationException <p>If the configuration file has missing or invalid values</p>
|
|
*/
|
|
public void load(@NotNull FileConfiguration fileConfiguration) throws InvalidConfigurationException {
|
|
soundSettings = new HashMap<>();
|
|
for (SoundIdentifier identifier : SoundIdentifier.values()) {
|
|
soundSettings.put(identifier, SoundData.load(fileConfiguration, identifier.getConfigNode()));
|
|
}
|
|
scrapperAnimationData = AnimationData.load(fileConfiguration, "scrapper.animation");
|
|
blacksmithAnimationData = AnimationData.load(fileConfiguration, "blacksmith.animation");
|
|
}
|
|
|
|
/**
|
|
* Gets the animation data for the scrapper's working animation
|
|
*
|
|
* @return <p>Scrapper animation data</p>
|
|
*/
|
|
@NotNull
|
|
public AnimationData getScrapperAnimationData() {
|
|
return this.scrapperAnimationData;
|
|
}
|
|
|
|
/**
|
|
* Gets the animation data for the blacksmith's working animation
|
|
*
|
|
* @return <p>Blacksmith animation data</p>
|
|
*/
|
|
@NotNull
|
|
public AnimationData getBlacksmithAnimationData() {
|
|
return this.blacksmithAnimationData;
|
|
}
|
|
|
|
/**
|
|
* Gets the sound data for the given identifier
|
|
*
|
|
* @param identifier <p>The identifier of the sound</p>
|
|
* @return <p>The sound's sound data</p>
|
|
*/
|
|
@NotNull
|
|
public SoundData getSoundData(@NotNull SoundIdentifier identifier) {
|
|
return soundSettings.get(identifier);
|
|
}
|
|
|
|
}
|