mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-23 16:49:19 +00:00
feat: Minecraft 1.20.5/6 support (#295)
* feat: start 1.20.5 update testing nbt-api seems to work great already :) * feat: add DFU support for legacy upgrade Adds an optional overload to `deserialize` to support passing the MC Version of the snapshot data * refactor: `clone` ItemStack[] bukkit data arrays, close #294 Don't perform async operations on mutable player data
This commit is contained in:
@@ -392,7 +392,7 @@ public class DataSnapshot {
|
||||
private Map<Identifier, Data> deserializeData(@NotNull HuskSync plugin) {
|
||||
return data.entrySet().stream()
|
||||
.map((entry) -> plugin.getIdentifier(entry.getKey()).map(id -> Map.entry(
|
||||
id, plugin.getSerializers().get(id).deserialize(entry.getValue())
|
||||
id, plugin.getSerializers().get(id).deserialize(entry.getValue(), getMinecraftVersion())
|
||||
)).orElse(null))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
@@ -19,22 +19,27 @@
|
||||
|
||||
package net.william278.husksync.data;
|
||||
|
||||
import net.william278.desertwell.util.Version;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Serializer<T extends Data> {
|
||||
|
||||
T deserialize(@NotNull String serialized) throws DeserializationException;
|
||||
T deserialize(@NotNull String serialized);
|
||||
|
||||
default T deserialize(@NotNull String serialized, @NotNull Version dataMcVersion) throws DeserializationException {
|
||||
return deserialize(serialized);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String serialize(@NotNull T element) throws SerializationException;
|
||||
|
||||
static final class DeserializationException extends IllegalStateException {
|
||||
final class DeserializationException extends IllegalStateException {
|
||||
DeserializationException(@NotNull String message, @NotNull Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
static final class SerializationException extends IllegalStateException {
|
||||
final class SerializationException extends IllegalStateException {
|
||||
SerializationException(@NotNull String message, @NotNull Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user