package net.knarcraft.minigames.config; import net.knarcraft.minigames.util.MaterialHelper; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * A configuration for a mini-game */ public abstract class MiniGameConfiguration { protected FileConfiguration configuration; /** * Instantiates a new mini-game configuration * * @param configuration

The YAML configuration to use internally

*/ public MiniGameConfiguration(@NotNull FileConfiguration configuration) { this.configuration = configuration; this.load(); } /** * Loads all configuration values from disk * * @param configuration

The configuration to load

*/ public void load(FileConfiguration configuration) { this.configuration = configuration; this.load(); } /** * Loads all configuration values from disk, using the current file configuration */ protected abstract void load(); /** * Loads the materials specified in the block whitelist */ public @NotNull Set loadMaterialList(@NotNull String path) { List blockWhitelist = configuration.getList(path, new ArrayList<>()); return MaterialHelper.loadMaterialList(blockWhitelist); } }