mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
Add support for deserializing manually deserialized items, also add caller note
This commit is contained in:
parent
c0bd5688b5
commit
a55345f991
@ -1,6 +1,7 @@
|
||||
package org.bukkit.configuration.serialization;
|
||||
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -30,8 +31,12 @@ public interface ConfigurationSerializable {
|
||||
* This class must provide a method to restore this class, as defined in
|
||||
* the {@link ConfigurationSerializable} interface javadocs.
|
||||
*
|
||||
* nb: It is not intended for this method to be called directly, this will
|
||||
* be called by the {@link ConfigurationSerialization} class.
|
||||
*
|
||||
* @return Map containing the current state of this class
|
||||
*/
|
||||
@NotNull
|
||||
@ApiStatus.OverrideOnly
|
||||
public Map<String, Object> serialize();
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
@ -565,7 +566,17 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
}
|
||||
case "components" -> {
|
||||
if (version == 1) {
|
||||
final Map<String, String> componentMap = (Map<String, String>) value;
|
||||
Map<String, String> componentMap;
|
||||
if (value instanceof Map) {
|
||||
componentMap = (Map<String, String>) value;
|
||||
} else if (value instanceof MemorySection memory) {
|
||||
componentMap = new HashMap<>();
|
||||
for (final String memoryKey : memory.getKeys(false)) {
|
||||
componentMap.put(memoryKey, memory.getString(memoryKey));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("components must be a Map");
|
||||
}
|
||||
final CompoundTag componentsTag = new CompoundTag();
|
||||
componentMap.forEach((componentKey, componentString) -> {
|
||||
final Tag componentTag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user