[FIX] Исправление бага с работой runtime с ProGuard

This commit is contained in:
Gravit 2019-09-24 14:56:00 +07:00
parent 034e5c154e
commit 2cfcd7a964
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -2,6 +2,7 @@
import com.google.gson.Gson; import com.google.gson.Gson;
import pro.gravit.launcher.Launcher; import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherAPI;
import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.LogHelper;
@ -12,20 +13,21 @@
import java.nio.file.Path; import java.nio.file.Path;
public interface JsonConfigurableInterface<T> { public interface JsonConfigurableInterface<T> {
@LauncherAPI
default void saveConfig() throws IOException { default void saveConfig() throws IOException {
saveConfig(getPath()); saveConfig(getPath());
} }
@LauncherAPI
default void loadConfig() throws IOException { default void loadConfig() throws IOException {
loadConfig(getPath()); loadConfig(getPath());
} }
@LauncherAPI
default void saveConfig(Gson gson, Path configPath) throws IOException { default void saveConfig(Gson gson, Path configPath) throws IOException {
try (BufferedWriter writer = IOHelper.newWriter(configPath)) { try (BufferedWriter writer = IOHelper.newWriter(configPath)) {
gson.toJson(getConfig(), getType(), writer); gson.toJson(getConfig(), getType(), writer);
} }
} }
@LauncherAPI
default void loadConfig(Gson gson, Path configPath) throws IOException { default void loadConfig(Gson gson, Path configPath) throws IOException {
if (generateConfigIfNotExists(configPath)) return; if (generateConfigIfNotExists(configPath)) return;
try (BufferedReader reader = IOHelper.newReader(configPath)) { try (BufferedReader reader = IOHelper.newReader(configPath)) {
@ -36,45 +38,45 @@ default void loadConfig(Gson gson, Path configPath) throws IOException {
resetConfig(configPath); resetConfig(configPath);
} }
} }
@LauncherAPI
default void saveConfig(Path configPath) throws IOException { default void saveConfig(Path configPath) throws IOException {
saveConfig(Launcher.gsonManager.configGson, configPath); saveConfig(Launcher.gsonManager.configGson, configPath);
} }
@LauncherAPI
default void loadConfig(Path configPath) throws IOException { default void loadConfig(Path configPath) throws IOException {
loadConfig(Launcher.gsonManager.configGson, configPath); loadConfig(Launcher.gsonManager.configGson, configPath);
} }
@LauncherAPI
default void resetConfig() throws IOException { default void resetConfig() throws IOException {
setConfig(getDefaultConfig()); setConfig(getDefaultConfig());
saveConfig(); saveConfig();
} }
@LauncherAPI
default void resetConfig(Path newPath) throws IOException { default void resetConfig(Path newPath) throws IOException {
setConfig(getDefaultConfig()); setConfig(getDefaultConfig());
saveConfig(newPath); saveConfig(newPath);
} }
@LauncherAPI
default boolean generateConfigIfNotExists(Path path) throws IOException { default boolean generateConfigIfNotExists(Path path) throws IOException {
if (IOHelper.isFile(path)) if (IOHelper.isFile(path))
return false; return false;
resetConfig(path); resetConfig(path);
return true; return true;
} }
@LauncherAPI
default boolean generateConfigIfNotExists() throws IOException { default boolean generateConfigIfNotExists() throws IOException {
if (IOHelper.isFile(getPath())) if (IOHelper.isFile(getPath()))
return false; return false;
resetConfig(); resetConfig();
return true; return true;
} }
@LauncherAPI
T getConfig(); T getConfig();
@LauncherAPI
T getDefaultConfig(); T getDefaultConfig();
@LauncherAPI
void setConfig(T config); void setConfig(T config);
@LauncherAPI
Path getPath(); Path getPath();
Type getType(); Type getType();