playerData rewrite

This commit is contained in:
Tyler Murphy 2021-08-13 22:44:00 -04:00
parent 4503bbe022
commit 294fd6d7df
2 changed files with 6 additions and 20 deletions

View file

@ -26,7 +26,7 @@ public class Store {
public static int worldborderSize,worldborderDelay,currentWorldborderSize; public static int worldborderSize,worldborderDelay,currentWorldborderSize;
public static boolean worldborderEnabled = false, decreaseBorder = false; public static boolean worldborderEnabled = false, decreaseBorder = false;
public static String tauntPlayer = ""; public static String tauntPlayer = "";
public static HashMap<String,HashMap<String,Integer>> playerData = new HashMap<String,HashMap<String,Integer>>(); public static HashMap<String,Integer> playerData = new HashMap<String,Integer>();
public static int startTaskId; public static int startTaskId;
public static int gameId = 0; public static int gameId = 0;
@ -39,29 +39,15 @@ public class Store {
} }
public static int getPlayerData(String playerName, String key) { public static int getPlayerData(String playerName, String key) {
HashMap<String,Integer> data = playerData.get(playerName); return playerData.get(playerName + " " + key) == null ? 0 : playerData.get(playerName + "" + key);
if(data == null) {
return 0;
}
if(data.get(key) == null) {
return 0;
}
return data.get(key);
} }
public static void setPlayerData(String playerName, String key, int value) { public static void setPlayerData(String playerName, String key, int value) {
HashMap<String,Integer> data = playerData.get(playerName); playerData.put(playerName + " " + key, value);
if(data == null) {
data = new HashMap<String,Integer>();
}
data.put(key, value);
playerData.put(playerName, data);
} }
public static void resetPlayerData(String playerName, boolean giveItems) { public static void resetPlayerData(String playerName, boolean giveItems) {
HashMap<String,Integer> data = new HashMap<String,Integer>(); playerData.put(playerName+" Death", 0);
data.put("Death", 0); playerData.put(playerName+" GiveStatus", (giveItems) ? 1 : 0);
data.put("GiveStatus", (giveItems) ? 1 : 0);
playerData.put(playerName, data);
} }
} }

View file

@ -41,7 +41,7 @@ public class Start implements ICommand {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule doImmediateRespawn true");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule logAdminCommands false");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false"); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "gamerule naturalRegeneration false");
playerData = new HashMap<String,HashMap<String,Integer>>(); playerData = new HashMap<String,Integer>();
for(Player player : playerList.values()) { for(Player player : playerList.values()) {
resetPlayerData(player.getName(),true); resetPlayerData(player.getName(),true);
player.getInventory().clear(); player.getInventory().clear();