From 3eeab6a62000874f19313ee184779b5f2468cd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Tue, 25 Jun 2019 22:24:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=A7=E6=80=A5=E4=BF=AE=E5=A4=8D=20NBT=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=85=BC=E5=AE=B9=E6=BC=8F=E6=B4=9E=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=89=A9=E5=93=81=E6=8F=8F=E8=BF=B0=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/skymc/taboolib/common/nms/NMSHandlerImpl.java | 11 +++++++++-- .../scala/me/skymc/taboolib/inventory/ItemUtils.java | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java b/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java index 078d16f..1126f35 100644 --- a/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java +++ b/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java @@ -192,7 +192,7 @@ public class NMSHandlerImpl extends NMSHandler { } catch (Throwable t) { t.printStackTrace(); } - return CraftItemStack.asBukkitCopy((net.minecraft.server.v1_8_R3.ItemStack) nmsItem); + return CraftItemStack.asBukkitCopy((net.minecraft.server.v1_8_R3.ItemStack) nmsItem); } @Override @@ -229,7 +229,14 @@ public class NMSHandlerImpl extends NMSHandler { case 9: Object nmsList = new NBTTagList(); for (me.skymc.taboolib.common.nms.nbt.NBTBase value : base.asList()) { - ((List) SimpleReflection.getFieldValue(NBTTagList.class, nmsList, "list")).add(toNBTBase(value)); + // 1.14+ + if (TabooLib.getVersionNumber() >= 11400) { + ((net.minecraft.server.v1_14_R1.NBTTagList) nmsList).add(((net.minecraft.server.v1_14_R1.NBTTagList) nmsList).size(), (net.minecraft.server.v1_14_R1.NBTBase) toNBTBase(value)); + } + // 1.13- + else { + ((NBTTagList) nmsList).add((NBTBase) toNBTBase(value)); + } } return nmsList; case 10: diff --git a/src/main/scala/me/skymc/taboolib/inventory/ItemUtils.java b/src/main/scala/me/skymc/taboolib/inventory/ItemUtils.java index 428e52c..4e2e131 100644 --- a/src/main/scala/me/skymc/taboolib/inventory/ItemUtils.java +++ b/src/main/scala/me/skymc/taboolib/inventory/ItemUtils.java @@ -160,7 +160,9 @@ public class ItemUtils { } public static List asString(List args, Player placeholderPlayer) { - IntStream.range(0, args.size()).forEach(i -> args.set(i, asString(args.get(i), placeholderPlayer))); + for (int i = 0; i < args.size(); i++) { + args.set(i, asString(args.get(i), placeholderPlayer)); + } return args; } @@ -392,7 +394,7 @@ public class ItemUtils { a.put("Amount", new NBTBase(NumberConversions.toDouble(num.substring(0, num.length() - 1)) / 100D)); a.put("Operation", new NBTBase(1)); } else { - a.put("Amount", new NBTBase(NumberConversions.toDouble(num) / 100D)); + a.put("Amount", new NBTBase(NumberConversions.toDouble(num))); a.put("Operation", new NBTBase(0)); } a.put("AttributeName", new NBTBase(asAttribute(name)));