Updater should not be running on the main thread

Fixes #1957
This commit is contained in:
TfT_02 2014-04-05 12:10:02 +02:00
parent 3390a31cc6
commit f0ee708710
3 changed files with 43 additions and 19 deletions

View File

@ -8,6 +8,7 @@ Key:
- Removal
Version 1.5.01-dev
= Fixed bug where the Updater was running on the main thread.
Version 1.5.00
+ Added Podzol & Red Sand to Excavation

View File

@ -29,11 +29,11 @@ import com.gmail.nossr50.listeners.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.SelfListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.CheckDateTask;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.database.UserPurgeTask;
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
@ -57,9 +57,6 @@ import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import net.gravitydevelopment.updater.mcmmo.Updater;
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
import net.shatteredlands.shatt.backup.ZipLibrary;
public class mcMMO extends JavaPlugin {
@ -258,6 +255,10 @@ public class mcMMO extends JavaPlugin {
return updateAvailable;
}
public void setUpdateAvailable(boolean available) {
this.updateAvailable = available;
}
public boolean isXPEventEnabled() {
return xpEventEnabled;
}
@ -377,21 +378,7 @@ public class mcMMO extends JavaPlugin {
return;
}
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
this.updateAvailable = false;
return;
}
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
this.updateAvailable = false;
return;
}
this.updateAvailable = true;
getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
new UpdaterResultAsyncTask(this).runTaskAsynchronously(mcMMO.p);
}
private void loadConfigFiles() {

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.runnables;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import net.gravitydevelopment.updater.mcmmo.Updater;
public class UpdaterResultAsyncTask extends BukkitRunnable {
private mcMMO plugin;
public UpdaterResultAsyncTask(mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
Updater updater = new Updater(plugin, 31030, plugin.mcmmo, Updater.UpdateType.NO_DOWNLOAD, false);
if (updater.getResult() != Updater.UpdateResult.UPDATE_AVAILABLE) {
plugin.setUpdateAvailable(false);
return;
}
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
plugin.setUpdateAvailable(false);
return;
}
plugin.setUpdateAvailable(true);
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
}