From 2cfcd7a964b1c6586819fcd569d0e1cddb6d4c7e Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 24 Sep 2019 14:56:00 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=B0=20?= =?UTF-8?q?=D1=81=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D0=B9=20runtime?= =?UTF-8?q?=20=D1=81=20ProGuard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/JsonConfigurableInterface.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java b/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java index dc02c2cc..7b80756e 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/config/JsonConfigurableInterface.java @@ -2,6 +2,7 @@ import com.google.gson.Gson; import pro.gravit.launcher.Launcher; +import pro.gravit.launcher.LauncherAPI; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.LogHelper; @@ -12,20 +13,21 @@ import java.nio.file.Path; public interface JsonConfigurableInterface { + @LauncherAPI default void saveConfig() throws IOException { saveConfig(getPath()); } - + @LauncherAPI default void loadConfig() throws IOException { loadConfig(getPath()); } - + @LauncherAPI default void saveConfig(Gson gson, Path configPath) throws IOException { try (BufferedWriter writer = IOHelper.newWriter(configPath)) { gson.toJson(getConfig(), getType(), writer); } } - + @LauncherAPI default void loadConfig(Gson gson, Path configPath) throws IOException { if (generateConfigIfNotExists(configPath)) return; try (BufferedReader reader = IOHelper.newReader(configPath)) { @@ -36,45 +38,45 @@ default void loadConfig(Gson gson, Path configPath) throws IOException { resetConfig(configPath); } } - + @LauncherAPI default void saveConfig(Path configPath) throws IOException { saveConfig(Launcher.gsonManager.configGson, configPath); } - + @LauncherAPI default void loadConfig(Path configPath) throws IOException { loadConfig(Launcher.gsonManager.configGson, configPath); } - + @LauncherAPI default void resetConfig() throws IOException { setConfig(getDefaultConfig()); saveConfig(); } - + @LauncherAPI default void resetConfig(Path newPath) throws IOException { setConfig(getDefaultConfig()); saveConfig(newPath); } - + @LauncherAPI default boolean generateConfigIfNotExists(Path path) throws IOException { if (IOHelper.isFile(path)) return false; resetConfig(path); return true; } - + @LauncherAPI default boolean generateConfigIfNotExists() throws IOException { if (IOHelper.isFile(getPath())) return false; resetConfig(); return true; } - + @LauncherAPI T getConfig(); - + @LauncherAPI T getDefaultConfig(); - + @LauncherAPI void setConfig(T config); - + @LauncherAPI Path getPath(); Type getType();