[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 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<T> {
@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();