Skip to content

Commit

Permalink
reorder the storage agent to load the data before the update task
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Nov 5, 2024
1 parent 02ad3bf commit a67737f
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
public class NumberTopHolder extends AgentDataHolder<UUID, Double> {
private final ValueProvider valueProvider;
private final ValueDisplay valueDisplay;
private final UpdateAgent<UUID, Double> updateAgent;
private final StorageAgent<UUID, Double> storageAgent;
private final UpdateAgent<UUID, Double> updateAgent;
private final SnapshotAgent<UUID, Double> snapshotAgent;

public NumberTopHolder(TopperPlugin instance, String name, Map<String, Object> map) {
Expand All @@ -39,14 +39,14 @@ public NumberTopHolder(TopperPlugin instance, String name, Map<String, Object> m
});
this.valueDisplay = new ValueDisplay(map);

this.updateAgent = new UpdateAgent<>(instance.getLogger(), this, valueProvider::getValue);
updateAgent.setMaxEntryPerCall(instance.get(MainConfig.class).getTaskUpdateEntryPerTick());
addAgent(new SpigotRunnableAgent<>(updateAgent, AsyncScheduler.get(instance), instance.get(MainConfig.class).getTaskUpdateDelay()));

this.storageAgent = new StorageAgent<>(instance.getLogger(), this, instance.get(TopManager.class).getStorageSupplier().getStorage(name));
storageAgent.setMaxEntryPerCall(instance.get(MainConfig.class).getTaskSaveEntryPerTick());
addAgent(new SpigotRunnableAgent<>(storageAgent, AsyncScheduler.get(instance), instance.get(MainConfig.class).getTaskSaveDelay()));

this.updateAgent = new UpdateAgent<>(instance.getLogger(), this, valueProvider::getValue);
updateAgent.setMaxEntryPerCall(instance.get(MainConfig.class).getTaskUpdateEntryPerTick());
addAgent(new SpigotRunnableAgent<>(updateAgent, AsyncScheduler.get(instance), instance.get(MainConfig.class).getTaskUpdateDelay()));

this.snapshotAgent = new SnapshotAgent<>(this);
boolean reverseOrder = Optional.ofNullable(map.get("reverse")).map(String::valueOf).map(Boolean::parseBoolean).orElse(true);
snapshotAgent.setComparator(reverseOrder ? Comparator.reverseOrder() : Comparator.naturalOrder());
Expand Down Expand Up @@ -76,14 +76,14 @@ public Double getDefaultValue() {
return valueProvider.getDefaultValue();
}

public UpdateAgent<UUID, Double> getUpdateAgent() {
return updateAgent;
}

public StorageAgent<UUID, Double> getStorageAgent() {
return storageAgent;
}

public UpdateAgent<UUID, Double> getUpdateAgent() {
return updateAgent;
}

public SnapshotAgent<UUID, Double> getSnapshotAgent() {
return snapshotAgent;
}
Expand Down

0 comments on commit a67737f

Please sign in to comment.