mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Replace Bukkit schedulers in SaveTimerTask.java
This commit is contained in:
parent
0603faff33
commit
7f64987585
@ -644,7 +644,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
long saveIntervalTicks = Math.max(minute, generalConfig.getSaveInterval() * minute);
|
||||
|
||||
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
||||
new SaveTimerTask().runTaskTimer(saveIntervalTicks, saveIntervalTicks);
|
||||
|
||||
// Cleanup the backups folder
|
||||
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
|
||||
|
@ -5,22 +5,26 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.tcoded.folialib.wrapper.WrappedTask;
|
||||
|
||||
public class SaveTimerTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
public class SaveTimerTask {
|
||||
public WrappedTask runTaskTimer(long delay, long period) {
|
||||
return mcMMO.p.getFoliaLib().getImpl().runTimer(() -> {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving...");
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
PartyManager.saveParties();
|
||||
PartyManager.saveParties();
|
||||
}, delay * Misc.TICK_CONVERSION_FACTOR, period * Misc.TICK_CONVERSION_FACTOR, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user