diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index e74564bc..3eeb4f51 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -747,7 +747,7 @@ public class JobsPlayer { */ public void save() { // synchronized (saveLock) { - if (!isSaved()) { + if (!isSaved) { JobsDAO dao = Jobs.getJobsDAO(); dao.save(this); dao.saveLog(this); @@ -787,6 +787,7 @@ public class JobsPlayer { one.getBar().removeAll(); one.cancel(); } + barMap.clear(); } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index bc9557dc..e36c904f 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -1794,69 +1794,15 @@ public abstract class JobsDAO { jPlayer.reloadMaxExperience(); jPlayer.reloadLimits(); jPlayer.setUserId(Jobs.getPlayerManager().getPlayerId(jPlayer.getUniqueId())); - loadPoints(jPlayer); return jPlayer; } public JobsPlayer loadFromDao(OfflinePlayer player) { JobsPlayer jPlayer = new JobsPlayer(player.getName()); jPlayer.setPlayerUUID(player.getUniqueId()); - - List list = getAllJobs(player); - jPlayer.progression.clear(); - for (JobsDAOData jobdata : list) { - if (!plugin.isEnabled()) - return null; - - // add the job - Job job = Jobs.getJob(jobdata.getJobName()); - if (job == null) - continue; - - // create the progression object - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience()); - // calculate the max level - // add the progression level. - jPlayer.progression.add(jobProgression); - } - jPlayer.reloadMaxExperience(); - jPlayer.reloadLimits(); - jPlayer.setUserId(Jobs.getPlayerManager().getPlayerId(player.getUniqueId())); - loadPoints(jPlayer); - return jPlayer; + return loadFromDao(jPlayer); } -// public void loadAllData() { -// Jobs.getPlayerManager().clearMaps(); -// JobsConnection conn = getConnection(); -// if (conn == null) -// return; -// PreparedStatement prest = null; -// ResultSet res = null; -// try { -// prest = conn.prepareStatement("SELECT * FROM `" + prefix + "users`;"); -// res = prest.executeQuery(); -// while (res.next()) { -// try { -// Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo( -// res.getString("username"), -// res.getInt("id"), -// UUID.fromString(res.getString("player_uuid")), -// res.getLong("seen"), -// res.getInt("donequests"), -// res.getString("quests"))); -// } catch (Exception e) { -// } -// } -// } catch (SQLException e) { -// e.printStackTrace(); -// } finally { -// close(res); -// close(prest); -// } -// return; -// } - /** * Delete job from archive * @param player - player that wishes to quit the job diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 99b8f425..abb51b8d 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -188,12 +188,8 @@ public class JobsListener implements Listener { if (!Jobs.getGCManager().MultiServerCompatability()) Jobs.getPlayerManager().playerJoin(event.getPlayer()); else { - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - Jobs.getPlayerManager().playerJoin(event.getPlayer()); - } - }, 10L); + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> + Jobs.getPlayerManager().playerJoin(event.getPlayer()), 10L); } }