Fix 1.14 support.

- Fixed addCompound for 1.14. New format requires an int.
This commit is contained in:
Pim van der Loos 2019-04-28 16:09:09 +02:00
parent da360b3d28
commit 45d5f90fef
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8
3 changed files with 34 additions and 12 deletions

22
pom.xml
View File

@ -34,13 +34,13 @@
<artifactId>spigot-1.10</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependency>-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-1.11</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency> -->
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-1.12</artifactId>
@ -53,12 +53,18 @@
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-1.13.1</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-1.13.1</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-1.14</artifactId>
<version>1.14-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--bStats -->
<dependency>

View File

@ -116,7 +116,15 @@ public class NBTEditor
setTag = NBTTagCompound.getMethod("set", String.class, NBTBase);
NBTTagList = getNMSClass("NBTTagList");
addCompound = NBTTagList.getMethod("add", NBTBase);
// Starting in 1.14, you also need to provide an int value when adding nbt tags.
try
{
addCompound = NBTTagList.getMethod("add", NBTBase);
}
catch (Exception e)
{
addCompound = NBTTagList.getMethod("add", int.class, NBTBase);
}
setCompoundTagList = NBTTagCompound.getMethod("set", String.class, NBTBase);
setCompoundByte = NBTTagCompound.getMethod("set", String.class, NBTBase);
@ -130,6 +138,14 @@ public class NBTEditor
}
}
private void addCompound(Object instance, Object nbtbase) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
if (addCompound.getParameterCount() == 2)
addCompound.invoke(instance, 0, nbtbase);
else
addCompound.invoke(instance, nbtbase);
}
// Add armor to the supplied item, based on the armorTier.
public ItemStack addArmorNBTTags(ItemStack item, ArmorTier armorTier, boolean unbreakable)
{
@ -155,7 +171,7 @@ public class NBTEditor
setTag.invoke (armor, "UUIDLeast", NBTTagIntCtor.newInstance(894654));
setTag.invoke (armor, "UUIDMost", NBTTagIntCtor.newInstance(2872));
setTag.invoke (armor, "Slot", NBTTagStringCtor.newInstance("chest"));
addCompound.invoke(modifiers, armor);
addCompound(modifiers, armor);
Object armorTough = NBTTagCompound.newInstance();
setTag.invoke (armorTough, "AttributeName", NBTTagStringCtor.newInstance("generic.armorToughness"));
@ -165,7 +181,7 @@ public class NBTEditor
setTag.invoke (armorTough, "UUIDLeast", NBTTagIntCtor.newInstance(894654));
setTag.invoke (armorTough, "UUIDMost", NBTTagIntCtor.newInstance(2872));
setTag.invoke (armorTough, "Slot", NBTTagStringCtor.newInstance("chest"));
addCompound.invoke(modifiers, armorTough);
addCompound(modifiers, armorTough);
if (unbreakable)
setCompoundByte.invoke(compound, "Unbreakable", NBTTagByteCtor.newInstance((byte) 1));

View File

@ -1,7 +1,7 @@
name: ArmoredElytra
main: nl.pim16aap2.armoredElytra.ArmoredElytra
version: 2.4.8
author: Pim
author: pim16aap2
commands:
ArmoredElytra:
description: Give an armored elytra of the specified tier.