Skip to content

Commit

Permalink
Bump core.version from 4.4.3 to 4.5.0 (#112)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: hsgamer <[email protected]>
  • Loading branch information
dependabot[bot] and HSGamer authored Jun 24, 2024
1 parent d17c77d commit 5141200
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.hsgamer.topper.agent.storage.simple.supplier;

import me.hsgamer.hscore.config.Config;
import me.hsgamer.hscore.config.PathString;
import me.hsgamer.topper.agent.storage.simple.converter.FlatEntryConverter;
import me.hsgamer.topper.agent.storage.simple.util.AutoSaveConfig;
import me.hsgamer.topper.agent.storage.supplier.DataStorage;
Expand Down Expand Up @@ -48,13 +47,13 @@ public DataStorage<K, V> getStorage(DataHolder<K, V> holder) {

@Override
public CompletableFuture<Map<K, V>> load() {
Map<PathString, Object> values = config.getValues(false);
Map<String[], Object> values = config.getValues(false);
return CompletableFuture.supplyAsync(() -> {
Map<K, V> map = new HashMap<>();
values.forEach((path, value) -> {
V finalValue = converter.toValue(value);
if (finalValue != null) {
K finalKey = converter.toKey(path.getLastPath());
K finalKey = converter.toKey(path[0]);
map.put(finalKey, finalValue);
}
});
Expand All @@ -66,7 +65,7 @@ public CompletableFuture<Map<K, V>> load() {
public CompletableFuture<Void> save(K key, V value, boolean urgent) {
CompletableFuture<Void> future = new CompletableFuture<>();
Runnable runnable = () -> {
config.set(new PathString(converter.toRawKey(key)), converter.toRawValue(value));
config.set(converter.toRawValue(value), converter.toRawKey(key));
future.complete(null);
};
if (urgent) {
Expand All @@ -81,7 +80,7 @@ public CompletableFuture<Void> save(K key, V value, boolean urgent) {
public CompletableFuture<Optional<V>> load(K key, boolean urgent) {
CompletableFuture<Optional<V>> future = new CompletableFuture<>();
Runnable runnable = () -> {
Optional<V> optional = Optional.ofNullable(config.get(new PathString(converter.toRawKey(key)))).map(converter::toValue);
Optional<V> optional = Optional.ofNullable(config.get(converter.toRawKey(key))).map(converter::toValue);
future.complete(optional);
};
if (urgent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import me.hsgamer.hscore.config.Config;
import me.hsgamer.hscore.config.DecorativeConfig;
import me.hsgamer.hscore.config.PathString;

import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -20,8 +19,8 @@ public AutoSaveConfig(Config config, UnaryOperator<Runnable> runTaskFunction) {
}

@Override
public void set(PathString path, Object value) {
super.set(path, value);
public void set(Object value, String... path) {
super.set(value, path);
if (!isSaving.get()) {
isSaving.set(true);
Runnable cancelRunnable = runTaskFunction.apply(() -> {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<minelib.version>1.2.1</minelib.version>
<core.version>4.4.3</core.version>
<core.version>4.5.0</core.version>
<java.version>1.8</java.version>
</properties>

Expand Down

0 comments on commit 5141200

Please sign in to comment.