9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-19 14:59:21 +00:00

fix: /enderchest command not working

This commit is contained in:
William278
2025-05-26 20:13:23 +01:00
parent 6928f97dff
commit 20bc76a768
3 changed files with 26 additions and 8 deletions

View File

@@ -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")
}
}
}

View File

@@ -370,7 +370,7 @@ public class DataSnapshot {
public static class Unpacked extends DataSnapshot implements DataHolder {
@Expose(serialize = false, deserialize = false)
private final TreeMap<Identifier, Data> deserialized;
private final Map<Identifier, Data> deserialized;
private Unpacked(@NotNull UUID id, boolean pinned, @NotNull OffsetDateTime timestamp,
@NotNull String saveCause, @NotNull String serverName, @NotNull Map<String, String> 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<Identifier, Data> data,
@NotNull String saveCause, @NotNull String serverName, @NotNull Map<Identifier, Data> 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<Identifier, Data> deserializeData(@NotNull HuskSync plugin) {
private Map<Identifier, Data> 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<Map.Entry<Identifier, Data>> getSortedIterable() {
final TreeMap<Identifier, Data> 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<Identifier, Data> data;
private final Map<Identifier, Data> 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();

View File

@@ -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<Identifier, Data> entry : unpacked.getData().entrySet()) {
for (Map.Entry<Identifier, Data> entry : unpacked.getSortedIterable()) {
final Identifier identifier = entry.getKey();
if (!identifier.isEnabled()) {
continue;