From fb22ed40df5b1599aefce668e8ce6e1c43643544 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Tue, 15 Jun 2021 22:01:12 -0600 Subject: finally figured out how to edit player data. now how to save it... --- src/net/brysonsteck/Resurrection/Resurrection.java | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/net/brysonsteck/Resurrection/Resurrection.java') 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); + + } } -- cgit v1.2.3