From 20bc76a76816573ba9ac0e10ffc945775f6168ab Mon Sep 17 00:00:00 2001 From: William278 Date: Mon, 26 May 2025 20:13:23 +0100 Subject: [PATCH] fix: `/enderchest` command not working --- bukkit/build.gradle | 4 +++ .../husksync/data/DataSnapshot.java | 27 ++++++++++++++----- .../husksync/data/UserDataHolder.java | 3 +-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 673c18d7..8432a55c 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -93,5 +93,9 @@ shadowJar { tasks { runServer { minecraftVersion(project.name) + + downloadPlugins { + github("plan-player-analytics", "Plan", "5.6.2965", "Plan-5.6-build-2965.jar") + } } } \ No newline at end of file diff --git a/common/src/main/java/net/william278/husksync/data/DataSnapshot.java b/common/src/main/java/net/william278/husksync/data/DataSnapshot.java index 5d11719a..da96e4a7 100644 --- a/common/src/main/java/net/william278/husksync/data/DataSnapshot.java +++ b/common/src/main/java/net/william278/husksync/data/DataSnapshot.java @@ -370,7 +370,7 @@ public class DataSnapshot { public static class Unpacked extends DataSnapshot implements DataHolder { @Expose(serialize = false, deserialize = false) - private final TreeMap deserialized; + private final Map deserialized; private Unpacked(@NotNull UUID id, boolean pinned, @NotNull OffsetDateTime timestamp, @NotNull String saveCause, @NotNull String serverName, @NotNull Map data, @@ -381,7 +381,7 @@ public class DataSnapshot { } private Unpacked(@NotNull UUID id, boolean pinned, @NotNull OffsetDateTime timestamp, - @NotNull String saveCause, @NotNull String serverName, @NotNull TreeMap data, + @NotNull String saveCause, @NotNull String serverName, @NotNull Map data, @NotNull Version minecraftVersion, @NotNull String platformType, int formatVersion) { super(id, pinned, timestamp, saveCause, serverName, Map.of(), minecraftVersion, platformType, formatVersion); this.deserialized = data; @@ -389,14 +389,15 @@ public class DataSnapshot { @NotNull @ApiStatus.Internal - private TreeMap deserializeData(@NotNull HuskSync plugin) { + private Map deserializeData(@NotNull HuskSync plugin) { return data.entrySet().stream() .filter(e -> plugin.getIdentifier(e.getKey()).isPresent()) .map(entry -> Map.entry(plugin.getIdentifier(entry.getKey()).orElseThrow(), entry.getValue())) .collect(Collectors.toMap( Map.Entry::getKey, entry -> plugin.deserializeData(entry.getKey(), entry.getValue(), getMinecraftVersion()), - (a, b) -> b, () -> Maps.newTreeMap(SerializerRegistry.DEPENDENCY_ORDER_COMPARATOR) + (a, b) -> a, + HashMap::new )); } @@ -423,6 +424,20 @@ public class DataSnapshot { return deserialized; } + /** + * Get a sorted iterable of the snapshots the snapshot is holding + * + * @return The data map + * @since 3.8.2 + */ + @NotNull + @ApiStatus.Internal + public Iterable> getSortedIterable() { + final TreeMap tree = Maps.newTreeMap(SerializerRegistry.DEPENDENCY_ORDER_COMPARATOR); + tree.putAll(deserialized); + return tree.entrySet(); + } + /** * Pack the {@link DataSnapshot} into a {@link DataSnapshot.Packed packed} snapshot * @@ -455,12 +470,12 @@ public class DataSnapshot { private String serverName; private boolean pinned; private OffsetDateTime timestamp; - private final TreeMap data; + private final Map data; private Builder(@NotNull HuskSync plugin) { this.plugin = plugin; this.pinned = false; - this.data = Maps.newTreeMap(SerializerRegistry.DEPENDENCY_ORDER_COMPARATOR); + this.data = Maps.newHashMap(); this.timestamp = OffsetDateTime.now(); this.id = UUID.randomUUID(); this.serverName = plugin.getServerName(); diff --git a/common/src/main/java/net/william278/husksync/data/UserDataHolder.java b/common/src/main/java/net/william278/husksync/data/UserDataHolder.java index 408b47d7..2afef600 100644 --- a/common/src/main/java/net/william278/husksync/data/UserDataHolder.java +++ b/common/src/main/java/net/william278/husksync/data/UserDataHolder.java @@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; -import java.util.TreeMap; import java.util.logging.Level; import java.util.stream.Collectors; @@ -127,7 +126,7 @@ public interface UserDataHolder extends DataHolder { } try { - for (Map.Entry entry : unpacked.getData().entrySet()) { + for (Map.Entry entry : unpacked.getSortedIterable()) { final Identifier identifier = entry.getKey(); if (!identifier.isEnabled()) { continue;