blob: f63a359957d5becaa8605df3b9e0d39c7376fbae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package net.brysonsteck.Resurrection;
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;
}
}
|