9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-03 14:22:10 +00:00
This commit is contained in:
Xiao-MoMi
2023-01-13 16:25:47 +08:00
parent 97fd04b017
commit 515e2d13b5
11 changed files with 239 additions and 61 deletions

View File

@@ -19,6 +19,7 @@ package net.momirealms.customfishing.util;
import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBTListCompound;
import org.bukkit.configuration.MemorySection;
import org.bukkit.inventory.ItemStack;
@@ -41,10 +42,12 @@ public class NBTUtil {
NBTCompound newCompound = nbtCompound.addCompound(key);
setTags(memorySection.getValues(false), newCompound);
}
else if (map.get(key) instanceof List list){
else if (map.get(key) instanceof List<?> list){
for (Object o : list) {
if (o instanceof String value) {
setListValue(key, value, nbtCompound);
} else if (o instanceof Map<?,?> map1) {
setCompoundList(key, map1, nbtCompound);
}
}
}
@@ -54,6 +57,11 @@ public class NBTUtil {
}
}
private static void setCompoundList(String key, Map<?,?> map, NBTCompound nbtCompound) {
NBTListCompound nbtListCompound = nbtCompound.getCompoundList(key).addCompound();
setTags((Map<String, Object>) map, nbtListCompound);
}
private static void setListValue(String key, String value, NBTCompound nbtCompound) {
if (value.startsWith("(String) ")) {
nbtCompound.getStringList(key).add(value.substring(9));