Use MONSTER_EGG in SpawnEggRefl

This commit is contained in:
md678685 2018-08-19 21:16:16 +01:00
parent cdba518bae
commit 692e0adde4
2 changed files with 7 additions and 3 deletions

View File

@ -18,5 +18,10 @@
<artifactId>NMSProvider</artifactId> <artifactId>NMSProvider</artifactId>
<version>2.15.0</version> <version>2.15.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -79,8 +79,7 @@ public class SpawnEggRefl {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public ItemStack toItemStack(int amount) throws Exception { public ItemStack toItemStack(int amount) throws Exception {
// TODO: Get off of the deprecated LEGACY material. ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
ItemStack item = new ItemStack(Material.LEGACY_MONSTER_EGG, amount);
Class<?> craftItemStackClass = ReflUtil.getOBCClass("inventory.CraftItemStack"); Class<?> craftItemStackClass = ReflUtil.getOBCClass("inventory.CraftItemStack");
Method asNMSCopyMethod = ReflUtil.getMethodCached(craftItemStackClass, "asNMSCopy", ItemStack.class); Method asNMSCopyMethod = ReflUtil.getMethodCached(craftItemStackClass, "asNMSCopy", ItemStack.class);
@ -123,7 +122,7 @@ public class SpawnEggRefl {
public static SpawnEggRefl fromItemStack(ItemStack item) throws Exception { public static SpawnEggRefl fromItemStack(ItemStack item) throws Exception {
if (item == null) if (item == null)
throw new IllegalArgumentException("Item cannot be null"); throw new IllegalArgumentException("Item cannot be null");
if (item.getType() != Material.LEGACY_MONSTER_EGG) if (item.getType() != Material.MONSTER_EGG)
throw new IllegalArgumentException("Item is not a monster egg"); throw new IllegalArgumentException("Item is not a monster egg");
Class<?> NMSItemStackClass = ReflUtil.getNMSClass("ItemStack"); Class<?> NMSItemStackClass = ReflUtil.getNMSClass("ItemStack");