Fixed ReactHook registration and a bug with data collection

This commit is contained in:
Rsl1122 2018-05-26 10:58:42 +03:00
parent 90fd06194b
commit 818e93ac95
4 changed files with 32 additions and 22 deletions

View File

@ -71,20 +71,20 @@
<exclude>org.apache.logging.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>com.maxmind</pattern>
<shadedPattern>plan.com.maxmind</shadedPattern>
<excludes>
<exclude>org.apache.logging.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>plan.com.fasterxml</shadedPattern>
<excludes>
<exclude>org.apache.logging.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>com.maxmind</pattern>
<shadedPattern>plan.com.maxmind</shadedPattern>
<excludes>
<exclude>org.apache.logging.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>plan.com.fasterxml</shadedPattern>
<excludes>
<exclude>org.apache.logging.*</exclude>
</excludes>
</relocation>
</relocations>
</configuration>
</plugin>

View File

@ -17,8 +17,8 @@ import com.djrapitops.pluginbridge.plan.jobs.JobsHook;
import com.djrapitops.pluginbridge.plan.kingdoms.KingdomsHook;
import com.djrapitops.pluginbridge.plan.litebans.LiteBansHook;
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.react.ReactHook;
import com.djrapitops.pluginbridge.plan.redprotect.RedProtectHook;
import com.djrapitops.pluginbridge.plan.superbvote.SuperbVoteHook;
import com.djrapitops.pluginbridge.plan.towny.TownyHook;
@ -85,6 +85,7 @@ public class Bridge {
new McmmoHook(h),
new SuperbVoteHook(h),
new ProtocolSupportHook(h),
new ReactHook(h),
new RedProtectHook(h),
new TownyHook(h),
new VaultHook(h),

View File

@ -2,6 +2,7 @@ package com.djrapitops.pluginbridge.plan.react;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
import com.volmit.react.React;
import com.volmit.react.api.GraphSampleLine;
@ -19,7 +20,7 @@ import java.util.Map;
*
* @author Rsl1122
*/
public class DataCollectionTask extends AbsRunnable {
public class ReactDataTask extends AbsRunnable {
private static final SampledType[] STORED_TYPES = new SampledType[]{
SampledType.ENT,
@ -44,23 +45,31 @@ public class DataCollectionTask extends AbsRunnable {
private final ReactDataTable table;
private final Map<SampledType, List<ReactValue>> history;
public DataCollectionTask(ReactDataTable table) {
super(DataCollectionTask.class.getSimpleName());
public ReactDataTask(ReactDataTable table) {
super(ReactDataTask.class.getSimpleName());
this.table = table;
history = new EnumMap<>(SampledType.class);
}
@Override
public void run() {
GMap<SampledType, GraphSampleLine> samplers = React.instance.graphController.getG();
try {
GMap<SampledType, GraphSampleLine> samplers = React.instance.graphController.getG();
for (SampledType type : STORED_TYPES) {
processType(samplers, type);
for (SampledType type : STORED_TYPES) {
processType(samplers, type);
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
cancel();
}
}
private void processType(GMap<SampledType, GraphSampleLine> samplers, SampledType type) {
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<>());
values.entrySet().stream()
.map(entry -> new ReactValue(type, entry.getKey(), entry.getValue()))

View File

@ -43,7 +43,7 @@ public class ReactHook extends Hook {
table.createTable();
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);
setTask(task);
}