src/main/java/de/mviper/adventskalender/PlayerData.java gelöscht
This commit is contained in:
@@ -1,75 +0,0 @@
|
|||||||
package de.mviper.adventskalender;
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verwaltet die Spielerdaten in einer separaten YAML-Datei.
|
|
||||||
* Speichert, welcher Spieler an welchem Tag sein Geschenk bereits geholt hat.
|
|
||||||
*/
|
|
||||||
public class PlayerData {
|
|
||||||
|
|
||||||
private static File file;
|
|
||||||
private static FileConfiguration customFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstellt die playerdata.yml-Datei, falls sie nicht existiert.
|
|
||||||
*/
|
|
||||||
public static void setup() {
|
|
||||||
file = new File(Adventskalender.getInstance().getDataFolder(), "playerdata.yml");
|
|
||||||
if (!file.exists()) {
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Adventskalender.getInstance().getLogger().severe("Konnte playerdata.yml nicht erstellen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
customFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FileConfiguration get() {
|
|
||||||
return customFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void save() {
|
|
||||||
try {
|
|
||||||
customFile.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Adventskalender.getInstance().getLogger().severe("Konnte playerdata.yml nicht speichern: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reload() {
|
|
||||||
customFile = YamlConfiguration.loadConfiguration(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft, ob ein Spieler ein Geschenk für einen bestimmten Tag bereits geholt hat.
|
|
||||||
* @param uuid Die UUID des Spielers
|
|
||||||
* @param day Der Tag (1-24)
|
|
||||||
* @return true, wenn bereits geholt, sonst false
|
|
||||||
*/
|
|
||||||
public static boolean hasClaimed(UUID uuid, int day) {
|
|
||||||
// Wir speichern eine Liste der geöffneten Tage für jeden Spieler
|
|
||||||
List<Integer> claimedDays = customFile.getIntegerList(uuid.toString());
|
|
||||||
return claimedDays.contains(day);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Markiert einen Tag für einen Spieler als geholt.
|
|
||||||
* @param uuid Die UUID des Spielers
|
|
||||||
* @param day Der Tag (1-24)
|
|
||||||
*/
|
|
||||||
public static void setClaimed(UUID uuid, int day) {
|
|
||||||
List<Integer> claimedDays = customFile.getIntegerList(uuid.toString());
|
|
||||||
claimedDays.add(day);
|
|
||||||
customFile.set(uuid.toString(), claimedDays);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user