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.processors.TPSInsertProcessor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import java.util.ArrayList;
@ -20,7 +21,6 @@ public abstract class TPSCountTimer<T extends PlanPlugin> extends AbsRunnable {
protected final T plugin;
protected final List<TPS> history;
protected int latestPlayersOnline = 0;
public TPSCountTimer(T plugin) {
@ -31,14 +31,20 @@ public abstract class TPSCountTimer<T extends PlanPlugin> extends AbsRunnable {
@Override
public void run() {
long nanoTime = System.nanoTime();
long now = MiscUtils.getTime();
try {
long nanoTime = System.nanoTime();
long now = MiscUtils.getTime();
addNewTPSEntry(nanoTime, now);
addNewTPSEntry(nanoTime, now);
if (history.size() >= 60) {
Processor.queue(new TPSInsertProcessor(new ArrayList<>(history)));
history.clear();
if (history.size() >= 60) {
Processor.queue(new TPSInsertProcessor(new ArrayList<>(history)));
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()) {
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();
}
}