1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

Fixed issue when the points are not loaded on join

Fixes #848
This commit is contained in:
montlikadani 2020-07-14 19:38:33 +02:00
parent dcbe4f706a
commit 0a6a2648c8
3 changed files with 5 additions and 62 deletions

View File

@ -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();
}

View File

@ -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<JobsDAOData> 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

View File

@ -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);
}
}