-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2b433d
commit b7b00ca
Showing
5 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/io/github/wynncraft_overhaul/notifier/Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.wynncraft_overhaul.notifier; | ||
|
||
import com.google.gson.Gson; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
|
||
public class Config { | ||
private static final Gson gson = new Gson(); | ||
private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("notifier.json"); | ||
public ArrayList<String> ignoredVersions = new ArrayList<>(); | ||
|
||
public static Config load() throws IOException { | ||
Config config; | ||
if (Files.isRegularFile(PATH)) { | ||
config = gson.fromJson(new String(Files.readAllBytes(PATH)), Config.class); | ||
} else { | ||
config = new Config(); | ||
Files.createDirectories(PATH.getParent()); | ||
Files.createFile(PATH); | ||
Files.write(PATH, gson.toJson(config).getBytes()); | ||
} | ||
return config; | ||
} | ||
|
||
public void save() throws IOException { | ||
Files.write(PATH, gson.toJson(this).getBytes()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters