From 8cd5061eced23fc4615a0d34c1ed7e534193d4c1 Mon Sep 17 00:00:00 2001 From: Zrips Date: Thu, 17 Dec 2020 17:58:57 +0200 Subject: [PATCH] Lets load points too when changing servers --- .../com/gamingmesh/jobs/PlayerManager.java | 3 ++- .../java/com/gamingmesh/jobs/dao/JobsDAO.java | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 8ce24af5..4755754c 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -195,7 +195,8 @@ public class PlayerManager { } jPlayer.setPaymentLimit(Jobs.getJobsDAO().getPlayersLimits(jPlayer)); - + + jPlayer.setPoints(Jobs.getJobsDAO().getPlayerPoints(jPlayer)); } // Lets load quest progression PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId()); diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 2b46324f..b1f7763d 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -703,6 +703,29 @@ public abstract class JobsDAO { return map; } + public PlayerPoints getPlayerPoints(JobsPlayer player) { + PlayerPoints points = new PlayerPoints(); + JobsConnection conn = getConnection(); + if (conn == null) + return points; + PreparedStatement prest = null; + ResultSet res = null; + try { + prest = conn.prepareStatement("SELECT * FROM `" + DBTables.PointsTable.getTableName() + "` WHERE `" + PointsTableFields.userid.getCollumn() + "` = ?;"); + prest.setInt(1, player.getUserId()); + res = prest.executeQuery(); + while (res.next()) { + points = new PlayerPoints(res.getDouble(PointsTableFields.currentpoints.getCollumn()), res.getDouble(PointsTableFields.totalpoints.getCollumn())); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + close(res); + close(prest); + } + return points; + } + public HashMap getAllArchivedJobs() { HashMap map = new HashMap<>(); JobsConnection conn = getConnection();