2021-06-15 18:43:25 -06:00
|
|
|
package net.brysonsteck.Resurrection.player;
|
2021-06-05 23:10:04 -06:00
|
|
|
|
2021-06-15 22:01:12 -06:00
|
|
|
|
2021-08-19 21:12:47 -06:00
|
|
|
import net.brysonsteck.Resurrection.Resurrection;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2021-06-05 23:10:04 -06:00
|
|
|
import java.io.*;
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
|
|
|
public class PlayerData {
|
|
|
|
Hashtable<String, Hashtable<String, String>> playerData = new Hashtable<>();
|
2021-06-15 22:01:12 -06:00
|
|
|
String rawData;
|
2021-06-05 23:10:04 -06:00
|
|
|
|
|
|
|
public void saveData(String write) {
|
|
|
|
try {
|
2021-07-04 21:23:50 -06:00
|
|
|
FileWriter writer = new FileWriter("plugins/playerData.resurrection");
|
2021-06-16 16:50:42 -06:00
|
|
|
writer.write(write);
|
2021-06-05 23:10:04 -06:00
|
|
|
writer.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2021-06-16 17:15:44 -06:00
|
|
|
readData();
|
2021-06-05 23:10:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public void readData() {
|
|
|
|
try {
|
2021-06-15 22:01:12 -06:00
|
|
|
rawData = "";
|
2021-07-04 21:23:50 -06:00
|
|
|
BufferedReader reader = new BufferedReader(new FileReader("plugins/playerData.resurrection"));
|
2021-07-04 21:56:15 -06:00
|
|
|
String line;
|
2021-06-05 23:10:04 -06:00
|
|
|
String[] playerData;
|
|
|
|
while (true) {
|
|
|
|
line = reader.readLine();
|
|
|
|
if (line == null) {
|
|
|
|
break;
|
|
|
|
}
|
2021-06-15 22:01:12 -06:00
|
|
|
rawData = rawData + line;
|
2021-06-05 23:10:04 -06:00
|
|
|
playerData = line.split(",");
|
|
|
|
Hashtable<String, String> playerHash = new Hashtable<>();
|
|
|
|
playerHash.put("dead", playerData[1]);
|
|
|
|
playerHash.put("timeLeft", playerData[2]);
|
|
|
|
this.playerData.put(playerData[0], playerHash);
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
2021-08-19 21:12:47 -06:00
|
|
|
System.out.println("[Resurrection] There was an issue reading the player data file.");
|
2021-06-05 23:10:04 -06:00
|
|
|
e.printStackTrace();
|
2021-08-19 21:12:47 -06:00
|
|
|
System.out.println("[Resurrection] This file is crucial to Resurrection. Since the file could not be read, the plugin will now stop.");
|
|
|
|
Bukkit.getPluginManager().disablePlugin(JavaPlugin.getProvidingPlugin(Resurrection.class));
|
2021-06-05 23:10:04 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-04 21:56:15 -06:00
|
|
|
// public Hashtable<String, Hashtable<String, String>> getPlayers() {
|
|
|
|
// return playerData;
|
|
|
|
// }
|
2021-06-15 22:01:12 -06:00
|
|
|
|
|
|
|
public String getRawData() {
|
|
|
|
return rawData;
|
|
|
|
}
|
2021-06-05 23:10:04 -06:00
|
|
|
}
|