diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/brysonsteck/Resurrection/Resurrection.java | 37 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/config.yml | 7 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/player/PlayerData.java | 12 |
3 files changed, 54 insertions, 2 deletions
diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index aa357aa..52e910b 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -2,12 +2,15 @@ package net.brysonsteck.Resurrection; import net.brysonsteck.Resurrection.commands.CommandAbout; import net.brysonsteck.Resurrection.commands.CommandResurrect; +import net.brysonsteck.Resurrection.player.PlayerData; import net.brysonsteck.Resurrection.player.PlayerListener; import net.brysonsteck.Resurrection.startup.CheckForUpdate; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +import java.util.Hashtable; + public class Resurrection extends JavaPlugin implements Listener { //spigot things @@ -62,6 +65,38 @@ public class Resurrection extends JavaPlugin implements Listener { System.out.println("[Resurrection] Successfully Started!"); } - public static void main(String[] args) { } + public static void main(String[] args) { + + // DO THISgit + PlayerData playerData = new PlayerData(); + System.out.println("--- Reading Player data file ---"); + playerData.readData(); + System.out.println(playerData.getPlayers()); + System.out.println(playerData.getRawData()); + System.out.println("--- Oh look! A new player joined. Adding them. ---"); + playerData.saveData("bryzinga,false,0"); + System.out.println(playerData.getPlayers()); + System.out.println(playerData.getRawData()); + System.out.println("--- A player has died! Update the data file! ---"); + String rawData = playerData.getRawData(); + String[] rawPlayers = rawData.split(";"); + String[] rawSinglePlayer = new String[3]; + int index = 0; + for (String players : rawPlayers) { + if (players.startsWith("bryzinga")) { + String[] playerSplit = players.split(","); + playerSplit[1] = "true"; + playerSplit[2] = "12345"; + + rawPlayers[index] = String.join(",", playerSplit); + break; + + } + index++; + } + rawData = String.join(";", rawPlayers); + System.out.println(rawData); + + } } diff --git a/src/net/brysonsteck/Resurrection/config.yml b/src/net/brysonsteck/Resurrection/config.yml new file mode 100644 index 0000000..825512d --- /dev/null +++ b/src/net/brysonsteck/Resurrection/config.yml @@ -0,0 +1,7 @@ +resurrect: + bryzinga: + dead: false + resurrectTime: 0 + jobuxx: + dead: true + resurrectTime: 8192734897563945
\ No newline at end of file diff --git a/src/net/brysonsteck/Resurrection/player/PlayerData.java b/src/net/brysonsteck/Resurrection/player/PlayerData.java index a8a1192..cc82952 100644 --- a/src/net/brysonsteck/Resurrection/player/PlayerData.java +++ b/src/net/brysonsteck/Resurrection/player/PlayerData.java @@ -1,16 +1,20 @@ package net.brysonsteck.Resurrection.player; +import net.brysonsteck.Resurrection.Resurrection; +import org.bukkit.plugin.java.JavaPlugin; + import java.io.*; import java.util.Arrays; import java.util.Hashtable; public class PlayerData { Hashtable<String, Hashtable<String, String>> playerData = new Hashtable<>(); + String rawData; public void saveData(String write) { try { FileWriter writer = new FileWriter("data/player.data"); - writer.write(write); + writer.write(rawData + ";" + write); writer.close(); readData(); } catch (IOException e) { @@ -20,6 +24,7 @@ public class PlayerData { public void readData() { try { + rawData = ""; BufferedReader reader = new BufferedReader(new FileReader("data/player.data")); String line = ""; String[] playerData; @@ -29,6 +34,7 @@ public class PlayerData { if (line == null) { break; } + rawData = rawData + line; playerData = line.split(","); Hashtable<String, String> playerHash = new Hashtable<>(); playerHash.put("dead", playerData[1]); @@ -43,4 +49,8 @@ public class PlayerData { public Hashtable<String, Hashtable<String, String>> getPlayers() { return playerData; } + + public String getRawData() { + return rawData; + } } |