From 8db9ccdf642ed81f585e900a843c411b973ce6da Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Tue, 15 Jun 2021 18:43:25 -0600 Subject: starting to test timer --- .../Resurrection/player/PlayerData.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/net/brysonsteck/Resurrection/player/PlayerData.java (limited to 'src/net/brysonsteck/Resurrection/player/PlayerData.java') diff --git a/src/net/brysonsteck/Resurrection/player/PlayerData.java b/src/net/brysonsteck/Resurrection/player/PlayerData.java new file mode 100644 index 0000000..a8a1192 --- /dev/null +++ b/src/net/brysonsteck/Resurrection/player/PlayerData.java @@ -0,0 +1,46 @@ +package net.brysonsteck.Resurrection.player; + +import java.io.*; +import java.util.Arrays; +import java.util.Hashtable; + +public class PlayerData { + Hashtable> 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 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> getPlayers() { + return playerData; + } +} -- cgit v1.2.3