snbt structure clean
This commit is contained in:
parent
d8c3bac31f
commit
d0044fa824
|
|
@ -14,6 +14,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import vip.fubuki.playersync.util.JDBCsetUp;
|
||||
import vip.fubuki.playersync.util.LocalJsonUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -46,7 +47,7 @@ public class MixinPCStore {
|
|||
ResultSet rs = qr.resultSet();
|
||||
if (rs.next()) {
|
||||
String serializedData = rs.getString("pc");
|
||||
loadedNbt = TagParser.parseTag(serializedData);
|
||||
loadedNbt = TagParser.parseTag(LocalJsonUtil.cleanSnbt(serializedData));
|
||||
}
|
||||
|
||||
rs.close();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import vip.fubuki.playersync.util.JDBCsetUp;
|
||||
import vip.fubuki.playersync.util.LocalJsonUtil;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -46,7 +47,7 @@ public class MixinPartyStore {
|
|||
ResultSet rs = qr.resultSet();
|
||||
if (rs.next()) {
|
||||
String serializedData = rs.getString("inv");
|
||||
loadedNbt = TagParser.parseTag(serializedData);
|
||||
loadedNbt = TagParser.parseTag(LocalJsonUtil.cleanSnbt(serializedData));
|
||||
}
|
||||
|
||||
rs.close();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import net.neoforged.fml.common.EventBusSubscriber;
|
|||
import net.neoforged.neoforge.event.OnDatapackSyncEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerNegotiationEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
||||
|
|
@ -379,7 +380,7 @@ public class VanillaSync {
|
|||
}
|
||||
|
||||
String nbtString = deserializeString(serializedNbt);
|
||||
CompoundTag compoundTag = TagParser.parseTag(nbtString);
|
||||
CompoundTag compoundTag = TagParser.parseTag(LocalJsonUtil.cleanSnbt(nbtString));
|
||||
|
||||
if (compoundTag.isEmpty() || !compoundTag.contains("id", Tag.TAG_STRING)) {
|
||||
return ItemStack.EMPTY; // Invalid or empty tag
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ModsSupport {
|
|||
if (rsBackpack.next()) {
|
||||
String serialized = rsBackpack.getString("backpack_nbt");
|
||||
String nbtString = VanillaSync.deserializeString(serialized);
|
||||
CompoundTag backpackNbt = TagParser.parseTag(nbtString);
|
||||
CompoundTag backpackNbt = TagParser.parseTag(LocalJsonUtil.cleanSnbt(nbtString));
|
||||
// Update BackpackStorage with the retrieved NBT
|
||||
net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackStorage.get().setBackpackContents(contentsUuid, backpackNbt);
|
||||
PlayerSync.LOGGER.info("Restored backpack data for UUID " + contentsUuid);
|
||||
|
|
@ -111,7 +111,7 @@ public class ModsSupport {
|
|||
String serialized = entry.getValue();
|
||||
try {
|
||||
String nbtString = VanillaSync.deserializeString(serialized);
|
||||
CompoundTag tag = TagParser.parseTag(nbtString);
|
||||
CompoundTag tag = TagParser.parseTag(LocalJsonUtil.cleanSnbt(nbtString));
|
||||
ItemStack stack = ItemStack.parse(ServerLifecycleHooks.getCurrentServer().registryAccess(),tag).get();
|
||||
if (handler.getCurios().containsKey(slotType)) {
|
||||
ICurioStacksHandler stacksHandler = handler.getCurios().get(slotType);
|
||||
|
|
|
|||
|
|
@ -42,4 +42,12 @@ public class LocalJsonUtil {
|
|||
public static Map<Integer, String> StringToEntryMap(String param) {
|
||||
return stringToGenericMap(param, Integer::parseInt);
|
||||
}
|
||||
|
||||
public static String cleanSnbt(String snbt) {
|
||||
if (snbt == null) return null;
|
||||
|
||||
return snbt.replaceAll(",\\s*\\{\"\":\"\"}", "")
|
||||
.replaceAll("\\{\"\":\"\"}\\s*,", "")
|
||||
.replaceAll("\\{\"\":\"\"}", "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user