mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 19:47:55 +01:00
Make UpdateChecker run asynchronously and not block startup
Closes #1049
This commit is contained in:
parent
de46277bea
commit
a4a1ba4331
@ -35,6 +35,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.UpdateCheckerTask;
|
||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
@ -47,7 +48,6 @@ import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.UpdateChecker;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
||||
@ -266,13 +266,11 @@ public class mcMMO extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
updateAvailable = UpdateChecker.updateAvailable();
|
||||
}
|
||||
catch (Exception e) {
|
||||
updateAvailable = false;
|
||||
}
|
||||
getServer().getScheduler().runTaskAsynchronously(this, new UpdateCheckerTask());
|
||||
}
|
||||
|
||||
public void updateCheckerCallback(boolean updateAvailable) {
|
||||
this.updateAvailable = updateAvailable;
|
||||
if (updateAvailable) {
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.UpdateChecker;
|
||||
|
||||
/**
|
||||
* Async task
|
||||
*/
|
||||
public class UpdateCheckerTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mcMMO.p.updateCheckerCallback(UpdateChecker.updateAvailable());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.updateCheckerCallback(false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user