mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-07 00:38:42 +01:00
Properly loading archived jobs when running network
This commit is contained in:
parent
c97beba83d
commit
7544eea2ac
@ -1174,7 +1174,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((time < System.currentTimeMillis()) && (bp.getAction() != DBAction.DELETE)) {
|
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
|
||||||
getBpManager().remove(block);
|
getBpManager().remove(block);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,12 @@ public class PlayerManager {
|
|||||||
else
|
else
|
||||||
jPlayer = Jobs.getJobsDAO().loadFromDao(player);
|
jPlayer = Jobs.getJobsDAO().loadFromDao(player);
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().MultiServerCompatability()) {
|
||||||
|
ArchivedJobs archivedJobs = Jobs.getJobsDAO().getArchivedJobs(jPlayer);
|
||||||
|
if (archivedJobs != null) {
|
||||||
|
jPlayer.setArchivedJobs(archivedJobs);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Lets load quest progression
|
// Lets load quest progression
|
||||||
PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId());
|
PlayerInfo info = Jobs.getJobsDAO().loadPlayerData(player.getUniqueId());
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
@ -384,8 +390,7 @@ public class PlayerManager {
|
|||||||
if (jobsjoinevent.isCancelled())
|
if (jobsjoinevent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () ->
|
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job)));
|
||||||
Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job)));
|
|
||||||
jPlayer.setLeftTime(job);
|
jPlayer.setLeftTime(job);
|
||||||
|
|
||||||
PerformCommands.performCommandsOnJoin(jPlayer, job);
|
PerformCommands.performCommandsOnJoin(jPlayer, job);
|
||||||
|
@ -752,6 +752,51 @@ public abstract class JobsDAO {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArchivedJobs getArchivedJobs(JobsPlayer player) {
|
||||||
|
ArchivedJobs jobs = new ArchivedJobs();
|
||||||
|
JobsConnection conn = getConnection();
|
||||||
|
if (conn == null || player == null)
|
||||||
|
return jobs;
|
||||||
|
PreparedStatement prest = null;
|
||||||
|
ResultSet res = null;
|
||||||
|
try {
|
||||||
|
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.ArchiveTable.getTableName() + "` WHERE `" + ArchiveTableFields.userid.getCollumn() + "` = ?;");
|
||||||
|
prest.setInt(1, player.getUserId());
|
||||||
|
res = prest.executeQuery();
|
||||||
|
while (res.next()) {
|
||||||
|
|
||||||
|
String jobName = res.getString(ArchiveTableFields.job.getCollumn());
|
||||||
|
Double exp = res.getDouble(ArchiveTableFields.experience.getCollumn());
|
||||||
|
int lvl = res.getInt(ArchiveTableFields.level.getCollumn());
|
||||||
|
Long left = res.getLong(ArchiveTableFields.left.getCollumn());
|
||||||
|
int jobid = res.getInt(ArchiveTableFields.jobid.getCollumn());
|
||||||
|
|
||||||
|
Job job = null;
|
||||||
|
if (jobid != 0) {
|
||||||
|
job = Jobs.getJob(jobid);
|
||||||
|
} else {
|
||||||
|
job = Jobs.getJob(jobName);
|
||||||
|
converted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (job == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
JobProgression jp = new JobProgression(job, player, lvl, exp);
|
||||||
|
if (left != 0L)
|
||||||
|
jp.setLeftOn(left);
|
||||||
|
jobs.addArchivedJob(jp);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
close(res);
|
||||||
|
close(prest);
|
||||||
|
} finally {
|
||||||
|
close(res);
|
||||||
|
close(prest);
|
||||||
|
}
|
||||||
|
return jobs;
|
||||||
|
}
|
||||||
|
|
||||||
public HashMap<Integer, HashMap<String, Log>> getAllLogs() {
|
public HashMap<Integer, HashMap<String, Log>> getAllLogs() {
|
||||||
HashMap<Integer, HashMap<String, Log>> map = new HashMap<>();
|
HashMap<Integer, HashMap<String, Log>> map = new HashMap<>();
|
||||||
JobsConnection conn = getConnection();
|
JobsConnection conn = getConnection();
|
||||||
|
Loading…
Reference in New Issue
Block a user