From 9dfc351ebef4785be28f80a8fa68cbdf6ae7283f Mon Sep 17 00:00:00 2001 From: spacerocket62 Date: Tue, 27 Oct 2020 14:30:57 -0700 Subject: [PATCH] lol i forgot to add coins to player data --- .../java/me/totalfreedom/plex/cache/MongoPlayerData.java | 1 + .../java/me/totalfreedom/plex/cache/SQLPlayerData.java | 9 ++++++--- .../java/me/totalfreedom/plex/player/PlexPlayer.java | 4 ++++ .../java/me/totalfreedom/plex/storage/SQLConnection.java | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/totalfreedom/plex/cache/MongoPlayerData.java b/src/main/java/me/totalfreedom/plex/cache/MongoPlayerData.java index 2c3e7fa..7d84592 100644 --- a/src/main/java/me/totalfreedom/plex/cache/MongoPlayerData.java +++ b/src/main/java/me/totalfreedom/plex/cache/MongoPlayerData.java @@ -50,6 +50,7 @@ public class MongoPlayerData updateOps.set("prefix", player.getPrefix()); updateOps.set("rank", player.getRank() == null ? "" : player.getRank().name().toLowerCase()); updateOps.set("ips", player.getIps()); + updateOps.set("coins", player.getCoins()); plexPlayerDAO.update(filter, updateOps); } diff --git a/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java b/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java index 582ba00..16fe837 100644 --- a/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java +++ b/src/main/java/me/totalfreedom/plex/cache/SQLPlayerData.java @@ -17,8 +17,8 @@ public class SQLPlayerData { private final String SELECT = "SELECT * FROM `players` WHERE uuid=?"; - private final String UPDATE = "UPDATE `players` SET name=?, login_msg=?, prefix=?, rank=?, ips=? WHERE uuid=?"; - private final String INSERT = "INSERT INTO `players` (`uuid`, `name`, `login_msg`, `prefix`, `rank`, `ips`) VALUES (?, ?, ?, ?, ?, ?);"; + private final String UPDATE = "UPDATE `players` SET name=?, login_msg=?, prefix=?, rank=?, ips=?, coins=? WHERE uuid=?"; + private final String INSERT = "INSERT INTO `players` (`uuid`, `name`, `login_msg`, `prefix`, `rank`, `ips`, `coins`) VALUES (?, ?, ?, ?, ?, ?, ?);"; public boolean exists(UUID uuid) { @@ -54,6 +54,7 @@ public class SQLPlayerData String loginMSG = set.getString("login_msg"); String prefix = set.getString("prefix"); String rankName = set.getString("rank").toUpperCase(); + long coins = set.getLong("coins"); Rank rank = Rank.valueOf(rankName); List ips = new Gson().fromJson(set.getString("ips"), new TypeToken>(){}.getType()); plexPlayer.setName(name); @@ -61,6 +62,7 @@ public class SQLPlayerData plexPlayer.setPrefix(prefix); plexPlayer.setRank(rankName.isEmpty() ? null : rank); plexPlayer.setIps(ips); + plexPlayer.setCoins(coins); } return plexPlayer; } @@ -80,7 +82,8 @@ public class SQLPlayerData statement.setString(3, player.getPrefix()); statement.setString(4, player.getRank() == null ? "" : player.getRank().name().toLowerCase()); statement.setString(5, new Gson().toJson(player.getIps())); - statement.setString(6, player.getUuid()); + statement.setLong(6, player.getCoins()); + statement.setString(7, player.getUuid()); statement.executeUpdate(); } catch (SQLException throwables) { diff --git a/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java b/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java index 37efa3f..63962b6 100644 --- a/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java +++ b/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java @@ -33,6 +33,8 @@ public class PlexPlayer private String loginMSG; private String prefix; + private long coins; + private Rank rank; private List ips; @@ -50,6 +52,8 @@ public class PlexPlayer this.loginMSG = ""; this.prefix = ""; + this.coins = 0; + this.ips = new ArrayList<>(); this.rank = null; diff --git a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java index 1dc0000..61904af 100644 --- a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java +++ b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java @@ -44,6 +44,7 @@ public class SQLConnection "\t`prefix` VARCHAR(30),\n" + "\t`rank` VARCHAR(256),\n" + "\t`ips` VARCHAR(65535),\n" + + "\t`coins` BIGINT,\n" + "\tPRIMARY KEY (`uuid`)\n" + ");").execute(); } catch (SQLException throwables) {