package luckyblock.configurations; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import luckyblock.Main; import luckyblock.action.LuckyActionHolder; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; public class Settings { public String section = "LuckyBlock"; public Map events = new HashMap<>(); public Settings() { try (InputStream input = Main.class.getResourceAsStream("/settings.json")) { if (input != null) { Gson gson = new Gson(); JsonObject root = JsonParser.parseReader(new InputStreamReader(input, StandardCharsets.UTF_8)).getAsJsonObject(); Main.getLOGGER().info(root.toString()); if (root.has(this.section)) { JsonObject sectionJson = root.getAsJsonObject(this.section); for (Map.Entry entry : sectionJson.entrySet()) { String k = entry.getKey().replace("-", "_"); LuckyActionHolder holder = gson.fromJson(entry.getValue(), LuckyActionHolder.class); this.events.put(k, holder); } } } } catch (Exception e) { throw new RuntimeException(e); } } }