From f37ff93f66936dc32c5fbcb1566abca7ccde24cd Mon Sep 17 00:00:00 2001 From: LT_Name <572413378@qq.com> Date: Sat, 30 Dec 2023 19:28:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPlayerDataUtils=E5=9C=A8NKMOT?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=89=A9=E5=93=81=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/cn/lanink/gamecore/utils/PlayerDataUtils.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 24a0aa0..a4a7b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -274,7 +274,7 @@ cn.nukkit Nukkit - PM1E_1.20.40.3355 + MOT-java8-SNAPSHOT provided diff --git a/src/main/java/cn/lanink/gamecore/utils/PlayerDataUtils.java b/src/main/java/cn/lanink/gamecore/utils/PlayerDataUtils.java index 24200c3..1aa1fd3 100644 --- a/src/main/java/cn/lanink/gamecore/utils/PlayerDataUtils.java +++ b/src/main/java/cn/lanink/gamecore/utils/PlayerDataUtils.java @@ -53,9 +53,14 @@ public static LinkedHashMap> inventoryToLinkedHashMap(@NotNull M for (Map.Entry entry : inventoryContents.entrySet()) { LinkedList list = new LinkedList<>(); if (entry.getValue() != null) { - list.add(entry.getValue().getId() + ":" + entry.getValue().getDamage()); //0 + if (NukkitTypeUtils.getNukkitType() == NukkitTypeUtils.NukkitType.MOT) { + list.add(entry.getValue().getNamespaceId()); //0 + } else { + list.add(entry.getValue().getId() + ":" + entry.getValue().getDamage()); //0 + } list.add(String.valueOf(entry.getValue().getCount())); //1 list.add(bytesToBase64(entry.getValue().getCompoundTag())); //2 + list.add(String.valueOf(entry.getValue().getDamage())); //3 为了兼容之前的版本放在后面 } linkedHashMap.put(entry.getKey() + "", list); @@ -89,6 +94,9 @@ public static Map linkedHashMapToInventory(Map> i if (!"not".equals(String.valueOf(list.get(2)))) { item.setNamedTag(Item.parseCompoundTag(base64ToBytes(list.get(2)))); } + if (list.size() >= 4) { + item.setDamage(Integer.parseInt(list.get(3))); + } map.put(Integer.parseInt(entry.getKey()), item); } return map;