From a67737f30ccd02128473f30efcfa7383fb06454f Mon Sep 17 00:00:00 2001 From: hsgamer Date: Tue, 5 Nov 2024 23:25:16 +0700 Subject: [PATCH] reorder the storage agent to load the data before the update task --- .../spigot/plugin/holder/NumberTopHolder.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spigot/plugin/src/main/java/me/hsgamer/topper/spigot/plugin/holder/NumberTopHolder.java b/spigot/plugin/src/main/java/me/hsgamer/topper/spigot/plugin/holder/NumberTopHolder.java index e47a44c..79c3651 100644 --- a/spigot/plugin/src/main/java/me/hsgamer/topper/spigot/plugin/holder/NumberTopHolder.java +++ b/spigot/plugin/src/main/java/me/hsgamer/topper/spigot/plugin/holder/NumberTopHolder.java @@ -27,8 +27,8 @@ public class NumberTopHolder extends AgentDataHolder { private final ValueProvider valueProvider; private final ValueDisplay valueDisplay; - private final UpdateAgent updateAgent; private final StorageAgent storageAgent; + private final UpdateAgent updateAgent; private final SnapshotAgent snapshotAgent; public NumberTopHolder(TopperPlugin instance, String name, Map map) { @@ -39,14 +39,14 @@ public NumberTopHolder(TopperPlugin instance, String name, Map 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()); @@ -76,14 +76,14 @@ public Double getDefaultValue() { return valueProvider.getDefaultValue(); } - public UpdateAgent getUpdateAgent() { - return updateAgent; - } - public StorageAgent getStorageAgent() { return storageAgent; } + public UpdateAgent getUpdateAgent() { + return updateAgent; + } + public SnapshotAgent getSnapshotAgent() { return snapshotAgent; }