diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 11:49:01 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 11:49:01 -0600 |
commit | db5c24bc26e4d6a34ecd1ab9118f0f098eee3581 (patch) | |
tree | bfd1fa99cab5e90c5cd3e4555dc06d0a82164fe1 /src/net/brysonsteck/Resurrection/PlayerData.java | |
parent | a6193c66185c069db9a8f9f7a7aca570ae55994b (diff) | |
download | resurrection-db5c24bc26e4d6a34ecd1ab9118f0f098eee3581.tar resurrection-db5c24bc26e4d6a34ecd1ab9118f0f098eee3581.tar.gz resurrection-db5c24bc26e4d6a34ecd1ab9118f0f098eee3581.tar.bz2 |
death event works, working on commands
Diffstat (limited to 'src/net/brysonsteck/Resurrection/PlayerData.java')
-rw-r--r-- | src/net/brysonsteck/Resurrection/PlayerData.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/net/brysonsteck/Resurrection/PlayerData.java b/src/net/brysonsteck/Resurrection/PlayerData.java new file mode 100644 index 0000000..f63a359 --- /dev/null +++ b/src/net/brysonsteck/Resurrection/PlayerData.java @@ -0,0 +1,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; + } +} |