Fixed Periodic Analysis not running (#523)

This commit is contained in:
Rsl1122 2018-02-19 11:08:34 +02:00
parent 207ed76a1e
commit 0270feef7a
2 changed files with 16 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.system.processing.Processor; import com.djrapitops.plan.system.processing.Processor;
import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor; import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import java.util.ArrayList; import java.util.ArrayList;
@ -20,7 +21,6 @@ public abstract class TPSCountTimer<T extends PlanPlugin> extends AbsRunnable {
protected final T plugin; protected final T plugin;
protected final List<TPS> history; protected final List<TPS> history;
protected int latestPlayersOnline = 0; protected int latestPlayersOnline = 0;
public TPSCountTimer(T plugin) { public TPSCountTimer(T plugin) {
@ -31,14 +31,20 @@ public abstract class TPSCountTimer<T extends PlanPlugin> extends AbsRunnable {
@Override @Override
public void run() { public void run() {
long nanoTime = System.nanoTime(); try {
long now = MiscUtils.getTime(); long nanoTime = System.nanoTime();
long now = MiscUtils.getTime();
addNewTPSEntry(nanoTime, now); addNewTPSEntry(nanoTime, now);
if (history.size() >= 60) { if (history.size() >= 60) {
Processor.queue(new TPSInsertProcessor(new ArrayList<>(history))); Processor.queue(new TPSInsertProcessor(new ArrayList<>(history)));
history.clear(); history.clear();
}
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
Log.error("TPS Count Task Disabled due to error, reload Plan to re-enable.");
Log.toLog(this.getClass(), e);
cancel();
} }
} }

View File

@ -27,7 +27,9 @@ public class PeriodicAnalysisTask extends AbsRunnable {
if (!PlanPlugin.getInstance().isReloading()) { if (!PlanPlugin.getInstance().isReloading()) {
Log.toLog(this.getClass(), e); Log.toLog(this.getClass(), e);
} }
} finally { } catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
Log.error("Periodic Analysis Task Disabled due to error, reload Plan to re-enable.");
Log.toLog(this.getClass(), e);
cancel(); cancel();
} }
} }