mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Fixed ReactHook registration and a bug with data collection
This commit is contained in:
parent
90fd06194b
commit
818e93ac95
@ -17,8 +17,8 @@ import com.djrapitops.pluginbridge.plan.jobs.JobsHook;
|
|||||||
import com.djrapitops.pluginbridge.plan.kingdoms.KingdomsHook;
|
import com.djrapitops.pluginbridge.plan.kingdoms.KingdomsHook;
|
||||||
import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook;
|
import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook;
|
||||||
import com.djrapitops.pluginbridge.plan.mcmmo.McmmoHook;
|
import com.djrapitops.pluginbridge.plan.mcmmo.McmmoHook;
|
||||||
import com.djrapitops.pluginbridge.plan.placeholderapi.PlaceholderAPIHook;
|
|
||||||
import com.djrapitops.pluginbridge.plan.protocolsupport.ProtocolSupportHook;
|
import com.djrapitops.pluginbridge.plan.protocolsupport.ProtocolSupportHook;
|
||||||
|
import com.djrapitops.pluginbridge.plan.react.ReactHook;
|
||||||
import com.djrapitops.pluginbridge.plan.redprotect.RedProtectHook;
|
import com.djrapitops.pluginbridge.plan.redprotect.RedProtectHook;
|
||||||
import com.djrapitops.pluginbridge.plan.superbvote.SuperbVoteHook;
|
import com.djrapitops.pluginbridge.plan.superbvote.SuperbVoteHook;
|
||||||
import com.djrapitops.pluginbridge.plan.towny.TownyHook;
|
import com.djrapitops.pluginbridge.plan.towny.TownyHook;
|
||||||
@ -85,6 +85,7 @@ public class Bridge {
|
|||||||
new McmmoHook(h),
|
new McmmoHook(h),
|
||||||
new SuperbVoteHook(h),
|
new SuperbVoteHook(h),
|
||||||
new ProtocolSupportHook(h),
|
new ProtocolSupportHook(h),
|
||||||
|
new ReactHook(h),
|
||||||
new RedProtectHook(h),
|
new RedProtectHook(h),
|
||||||
new TownyHook(h),
|
new TownyHook(h),
|
||||||
new VaultHook(h),
|
new VaultHook(h),
|
||||||
|
@ -2,6 +2,7 @@ package com.djrapitops.pluginbridge.plan.react;
|
|||||||
|
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.volmit.react.React;
|
import com.volmit.react.React;
|
||||||
import com.volmit.react.api.GraphSampleLine;
|
import com.volmit.react.api.GraphSampleLine;
|
||||||
@ -19,7 +20,7 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class DataCollectionTask extends AbsRunnable {
|
public class ReactDataTask extends AbsRunnable {
|
||||||
|
|
||||||
private static final SampledType[] STORED_TYPES = new SampledType[]{
|
private static final SampledType[] STORED_TYPES = new SampledType[]{
|
||||||
SampledType.ENT,
|
SampledType.ENT,
|
||||||
@ -44,23 +45,31 @@ public class DataCollectionTask extends AbsRunnable {
|
|||||||
private final ReactDataTable table;
|
private final ReactDataTable table;
|
||||||
private final Map<SampledType, List<ReactValue>> history;
|
private final Map<SampledType, List<ReactValue>> history;
|
||||||
|
|
||||||
public DataCollectionTask(ReactDataTable table) {
|
public ReactDataTask(ReactDataTable table) {
|
||||||
super(DataCollectionTask.class.getSimpleName());
|
super(ReactDataTask.class.getSimpleName());
|
||||||
this.table = table;
|
this.table = table;
|
||||||
history = new EnumMap<>(SampledType.class);
|
history = new EnumMap<>(SampledType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
try {
|
||||||
GMap<SampledType, GraphSampleLine> samplers = React.instance.graphController.getG();
|
GMap<SampledType, GraphSampleLine> samplers = React.instance.graphController.getG();
|
||||||
|
|
||||||
for (SampledType type : STORED_TYPES) {
|
for (SampledType type : STORED_TYPES) {
|
||||||
processType(samplers, type);
|
processType(samplers, type);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.toLog(this.getClass(), e);
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processType(GMap<SampledType, GraphSampleLine> samplers, SampledType type) {
|
private void processType(GMap<SampledType, GraphSampleLine> samplers, SampledType type) {
|
||||||
GMap<Long, Double> values = samplers.get(type).getPlotBoard().getBetween(M.ms() - 10000, M.ms());
|
GMap<Long, Double> values = samplers.get(type).getPlotBoard().getBetween(M.ms() - 10000, M.ms());
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<ReactValue> storedValues = history.getOrDefault(type, new ArrayList<>());
|
List<ReactValue> storedValues = history.getOrDefault(type, new ArrayList<>());
|
||||||
values.entrySet().stream()
|
values.entrySet().stream()
|
||||||
.map(entry -> new ReactValue(type, entry.getKey(), entry.getValue()))
|
.map(entry -> new ReactValue(type, entry.getKey(), entry.getValue()))
|
@ -43,7 +43,7 @@ public class ReactHook extends Hook {
|
|||||||
table.createTable();
|
table.createTable();
|
||||||
table.clean();
|
table.clean();
|
||||||
|
|
||||||
ITask task = RunnableFactory.createNew(new DataCollectionTask(table))
|
ITask task = RunnableFactory.createNew(new ReactDataTask(table))
|
||||||
.runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 10L, TimeAmount.SECOND.ticks() * 10L);
|
.runTaskTimerAsynchronously(TimeAmount.SECOND.ticks() * 10L, TimeAmount.SECOND.ticks() * 10L);
|
||||||
setTask(task);
|
setTask(task);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user