resurrection/src/net/brysonsteck/Resurrection/player/PlayerData.java

47 lines
1.4 KiB
Java
Raw Normal View History

2021-06-15 18:43:25 -06:00
package net.brysonsteck.Resurrection.player;
2021-06-05 23:10:04 -06:00
import java.io.*;
import java.util.Arrays;
import java.util.Hashtable;
public class PlayerData {
Hashtable<String, Hashtable<String, String>> playerData = new Hashtable<>();
public void saveData(String write) {
try {
FileWriter writer = new FileWriter("data/player.data");
writer.write(write);
writer.close();
readData();
} catch (IOException e) {
e.printStackTrace();
}
}
public void readData() {
try {
BufferedReader reader = new BufferedReader(new FileReader("data/player.data"));
String line = "";
String[] playerData;
while (true) {
playerData = new String[3];
line = reader.readLine();
if (line == null) {
break;
}
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) {
e.printStackTrace();
}
}
public Hashtable<String, Hashtable<String, String>> getPlayers() {
return playerData;
}
}