-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Zalgo-Dev/main
Add new theme, add theme selection button and adjust titlescreen buttons positions
- Loading branch information
Showing
4 changed files
with
150 additions
and
5 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/io/github/spigotrce/paradiseclientfabric/ConfigManager.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,53 @@ | ||
package io.github.spigotrce.paradiseclientfabric; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
|
||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class ConfigManager { | ||
private static final File CONFIG_FILE = new File("config/paradiseclient.json"); | ||
private static JsonObject config; | ||
|
||
static { | ||
loadConfig(); | ||
} | ||
|
||
// Charger la configuration depuis le fichier | ||
private static void loadConfig() { | ||
try { | ||
if (CONFIG_FILE.exists()) { | ||
FileReader reader = new FileReader(CONFIG_FILE); | ||
config = JsonParser.parseReader(reader).getAsJsonObject(); | ||
reader.close(); | ||
} else { | ||
config = new JsonObject(); | ||
saveConfig(); | ||
} | ||
} catch (IOException e) { | ||
config = new JsonObject(); | ||
} | ||
} | ||
|
||
// Sauvegarder la configuration dans le fichier | ||
private static void saveConfig() { | ||
try (FileWriter writer = new FileWriter(CONFIG_FILE)) { | ||
writer.write(config.toString()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static String getTheme() { | ||
return config.has("theme") ? config.get("theme").getAsString() : "ParadiseHack"; // ParadiseHack par défaut | ||
} | ||
|
||
public static void setTheme(String theme) { | ||
config.addProperty("theme", theme); // Mise à jour | ||
saveConfig(); // Sauvegarde immédiate | ||
} | ||
|
||
} |
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