mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-08 16:31:37 +01:00
Fix some database loading issues
For example if we have set up auto cleaning users, the time is already exceed and the users will not get removed from database. Somehow the database always closed on reloading plugin that caused to not perform database actions Fixes #1007
This commit is contained in:
parent
e8eae4d4e2
commit
073192c3b0
@ -453,20 +453,17 @@ public class Jobs extends JavaPlugin {
|
||||
return jobsIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes startup
|
||||
* @throws IOException
|
||||
*/
|
||||
public void startup() {
|
||||
private void startup() {
|
||||
reload(true);
|
||||
loadAllPlayersData();
|
||||
|
||||
// add all online players
|
||||
Bukkit.getServer().getOnlinePlayers().forEach(getPlayerManager()::playerJoin);
|
||||
CompletableFuture<Void> pd = loadAllPlayersData();
|
||||
|
||||
// attempt to add all online players to cache
|
||||
pd.thenAccept(e -> Bukkit.getServer().getOnlinePlayers().forEach(getPlayerManager()::playerJoin));
|
||||
}
|
||||
|
||||
public static void loadAllPlayersData() {
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
public static CompletableFuture<Void> loadAllPlayersData() {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
long time = System.currentTimeMillis();
|
||||
// Cloning to avoid issues
|
||||
HashMap<UUID, PlayerInfo> temp = new HashMap<>(getPlayerManager().getPlayersInfoUUIDMap());
|
||||
@ -768,10 +765,8 @@ public class Jobs extends JavaPlugin {
|
||||
paymentThread.shutdown();
|
||||
paymentThread = null;
|
||||
}
|
||||
|
||||
smanager = new SelectionManager();
|
||||
if (dao != null) {
|
||||
dao.closeConnections();
|
||||
}
|
||||
|
||||
getGCManager().reload();
|
||||
getLanguage().reload();
|
||||
|
@ -330,6 +330,7 @@ public class JobsPlayer {
|
||||
int TotalLevel = getTotalLevels();
|
||||
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
|
||||
eq.setVariable("totallevel", TotalLevel);
|
||||
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
|
||||
limits.put(type, (int) eq.getValue());
|
||||
setSaved(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user