mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Remove old spawn egg providers in favor of reflection-based implementation
This commit is contained in:
parent
827891f10a
commit
5eec83f726
@ -121,42 +121,6 @@
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_9_R1Provider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_9_R2Provider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_10_R1Provider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>ReflectionProvider</artifactId>
|
||||
|
@ -43,11 +43,8 @@ import net.ess3.nms.updatedmeta.BasePotionDataProvider;
|
||||
import net.ess3.nms.updatedmeta.BlockMetaSpawnerProvider;
|
||||
import net.ess3.nms.legacy.LegacySpawnEggProvider;
|
||||
import net.ess3.nms.legacy.LegacySpawnerProvider;
|
||||
import net.ess3.nms.v1_10_R1.v1_10_R1SpawnEggProvider;
|
||||
import net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider;
|
||||
import net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider;
|
||||
import net.ess3.nms.v1_9_R1.v1_9_R1SpawnEggProvider;
|
||||
import net.ess3.nms.v1_9_R2.v1_9_R2SpawnEggProvider;
|
||||
import net.ess3.providers.ProviderFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -218,9 +215,6 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
spawnEggProvider = new ProviderFactory<>(getLogger(),
|
||||
Arrays.asList(
|
||||
ReflSpawnEggProvider.class,
|
||||
v1_10_R1SpawnEggProvider.class,
|
||||
v1_9_R2SpawnEggProvider.class,
|
||||
v1_9_R1SpawnEggProvider.class,
|
||||
LegacySpawnEggProvider.class
|
||||
), "spawn egg").getProvider();
|
||||
potionMetaProvider = new ProviderFactory<>(getLogger(),
|
||||
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EssentialsXParent</artifactId>
|
||||
<groupId>net.ess3</groupId>
|
||||
<version>2.0.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>1_10_R1Provider</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>NMSProvider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,115 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of ASkyBlock.
|
||||
* <p>
|
||||
* ASkyBlock is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* ASkyBlock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ASkyBlock. If not, see <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
package net.ess3.nms.v1_10_R1;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Represents a spawn egg that can be used to spawn mobs. Only for V1.9 servers
|
||||
*
|
||||
* @author tastybento
|
||||
*/
|
||||
public class SpawnEgg1_10_R1 {
|
||||
private EntityType type;
|
||||
|
||||
public SpawnEgg1_10_R1(EntityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of entity this egg will spawn.
|
||||
*
|
||||
* @return The entity type.
|
||||
*/
|
||||
public EntityType getSpawnedType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of entity this egg will spawn.
|
||||
*
|
||||
* @param type The entity type.
|
||||
*/
|
||||
public void setSpawnedType(EntityType type) {
|
||||
if (type.isAlive()) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SPAWN EGG{" + getSpawnedType() + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an ItemStack of one spawn egg
|
||||
* @return ItemStack
|
||||
*/
|
||||
public ItemStack toItemStack() {
|
||||
return toItemStack(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an itemstack of spawn eggs
|
||||
* @param amount
|
||||
* @return ItemStack of spawn eggs
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
|
||||
net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound == null) {
|
||||
tagCompound = new NBTTagCompound();
|
||||
}
|
||||
NBTTagCompound id = new NBTTagCompound();
|
||||
id.setString("id", type.getName());
|
||||
tagCompound.set("EntityTag", id);
|
||||
stack.setTag(tagCompound);
|
||||
return CraftItemStack.asBukkitCopy(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from an item stack to a spawn egg 1.9
|
||||
* @param item - ItemStack, quantity is disregarded
|
||||
* @return SpawnEgg 1.9
|
||||
*/
|
||||
public static SpawnEgg1_10_R1 fromItemStack(ItemStack item) throws IllegalArgumentException {
|
||||
if (item == null)
|
||||
throw new IllegalArgumentException("Item cannot be null");
|
||||
if (item.getType() != Material.MONSTER_EGG)
|
||||
throw new IllegalArgumentException("Item is not a monster egg");
|
||||
net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
|
||||
if (type != null) {
|
||||
return new SpawnEgg1_10_R1(type);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to parse type from item");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Item is lacking tag compound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package net.ess3.nms.v1_10_R1;
|
||||
|
||||
import net.ess3.nms.SpawnEggProvider;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class v1_10_R1SpawnEggProvider extends SpawnEggProvider {
|
||||
@Override
|
||||
public ItemStack createEggItem(EntityType type) throws IllegalArgumentException {
|
||||
return new SpawnEgg1_10_R1(type).toItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getSpawnedType(ItemStack eggItem) throws IllegalArgumentException {
|
||||
return SpawnEgg1_10_R1.fromItemStack(eggItem).getSpawnedType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanName() {
|
||||
return "CraftBukkit 1.10 NMS-based provider";
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EssentialsXParent</artifactId>
|
||||
<groupId>net.ess3</groupId>
|
||||
<version>2.0.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>1_9_R1Provider</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>NMSProvider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,115 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of ASkyBlock.
|
||||
* <p>
|
||||
* ASkyBlock is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* ASkyBlock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ASkyBlock. If not, see <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
package net.ess3.nms.v1_9_R1.nms;
|
||||
|
||||
import net.minecraft.server.v1_9_R1.NBTTagCompound;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Represents a spawn egg that can be used to spawn mobs. Only for V1.9 servers
|
||||
*
|
||||
* @author tastybento
|
||||
*/
|
||||
public class SpawnEgg1_9 {
|
||||
private EntityType type;
|
||||
|
||||
public SpawnEgg1_9(EntityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of entity this egg will spawn.
|
||||
*
|
||||
* @return The entity type.
|
||||
*/
|
||||
public EntityType getSpawnedType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of entity this egg will spawn.
|
||||
*
|
||||
* @param type The entity type.
|
||||
*/
|
||||
public void setSpawnedType(EntityType type) {
|
||||
if (type.isAlive()) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SPAWN EGG{" + getSpawnedType() + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an ItemStack of one spawn egg
|
||||
* @return ItemStack
|
||||
*/
|
||||
public ItemStack toItemStack() {
|
||||
return toItemStack(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an itemstack of spawn eggs
|
||||
* @param amount
|
||||
* @return ItemStack of spawn eggs
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
|
||||
net.minecraft.server.v1_9_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound == null) {
|
||||
tagCompound = new NBTTagCompound();
|
||||
}
|
||||
NBTTagCompound id = new NBTTagCompound();
|
||||
id.setString("id", type.getName());
|
||||
tagCompound.set("EntityTag", id);
|
||||
stack.setTag(tagCompound);
|
||||
return CraftItemStack.asBukkitCopy(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from an item stack to a spawn egg 1.9
|
||||
* @param item - ItemStack, quantity is disregarded
|
||||
* @return SpawnEgg 1.9
|
||||
*/
|
||||
public static SpawnEgg1_9 fromItemStack(ItemStack item) throws IllegalArgumentException {
|
||||
if (item == null)
|
||||
throw new IllegalArgumentException("Item cannot be null");
|
||||
if (item.getType() != Material.MONSTER_EGG)
|
||||
throw new IllegalArgumentException("Item is not a monster egg");
|
||||
net.minecraft.server.v1_9_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
|
||||
if (type != null) {
|
||||
return new SpawnEgg1_9(type);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to parse type from item");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Item is lacking tag compound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
package net.ess3.nms.v1_9_R1;
|
||||
|
||||
import net.ess3.nms.SpawnEggProvider;
|
||||
import net.ess3.nms.v1_9_R1.nms.SpawnEgg1_9;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class v1_9_R1SpawnEggProvider extends SpawnEggProvider {
|
||||
@Override
|
||||
public ItemStack createEggItem(EntityType type) throws IllegalArgumentException {
|
||||
return new SpawnEgg1_9(type).toItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getSpawnedType(ItemStack eggItem) throws IllegalArgumentException {
|
||||
return SpawnEgg1_9.fromItemStack(eggItem).getSpawnedType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanName() {
|
||||
return "CraftBukkit 1.9 NMS-based provider";
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EssentialsXParent</artifactId>
|
||||
<groupId>net.ess3</groupId>
|
||||
<version>2.0.1</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>1_9_R2Provider</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>NMSProvider</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,115 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of ASkyBlock.
|
||||
* <p>
|
||||
* ASkyBlock is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* <p>
|
||||
* ASkyBlock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with ASkyBlock. If not, see <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
package net.ess3.nms.v1_9_R2;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.NBTTagCompound;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Represents a spawn egg that can be used to spawn mobs. Only for V1.9 servers
|
||||
*
|
||||
* @author tastybento
|
||||
*/
|
||||
public class SpawnEgg1_9_R2 {
|
||||
private EntityType type;
|
||||
|
||||
public SpawnEgg1_9_R2(EntityType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of entity this egg will spawn.
|
||||
*
|
||||
* @return The entity type.
|
||||
*/
|
||||
public EntityType getSpawnedType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of entity this egg will spawn.
|
||||
*
|
||||
* @param type The entity type.
|
||||
*/
|
||||
public void setSpawnedType(EntityType type) {
|
||||
if (type.isAlive()) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SPAWN EGG{" + getSpawnedType() + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an ItemStack of one spawn egg
|
||||
* @return ItemStack
|
||||
*/
|
||||
public ItemStack toItemStack() {
|
||||
return toItemStack(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an itemstack of spawn eggs
|
||||
* @param amount
|
||||
* @return ItemStack of spawn eggs
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
|
||||
net.minecraft.server.v1_9_R2.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound == null) {
|
||||
tagCompound = new NBTTagCompound();
|
||||
}
|
||||
NBTTagCompound id = new NBTTagCompound();
|
||||
id.setString("id", type.getName());
|
||||
tagCompound.set("EntityTag", id);
|
||||
stack.setTag(tagCompound);
|
||||
return CraftItemStack.asBukkitCopy(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from an item stack to a spawn egg 1.9
|
||||
* @param item - ItemStack, quantity is disregarded
|
||||
* @return SpawnEgg 1.9
|
||||
*/
|
||||
public static SpawnEgg1_9_R2 fromItemStack(ItemStack item) throws IllegalArgumentException {
|
||||
if (item == null)
|
||||
throw new IllegalArgumentException("Item cannot be null");
|
||||
if (item.getType() != Material.MONSTER_EGG)
|
||||
throw new IllegalArgumentException("Item is not a monster egg");
|
||||
net.minecraft.server.v1_9_R2.ItemStack stack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tagCompound = stack.getTag();
|
||||
if (tagCompound != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
EntityType type = EntityType.fromName(tagCompound.getCompound("EntityTag").getString("id"));
|
||||
if (type != null) {
|
||||
return new SpawnEgg1_9_R2(type);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to parse type from item");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Item is lacking tag compound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package net.ess3.nms.v1_9_R2;
|
||||
|
||||
import net.ess3.nms.SpawnEggProvider;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class v1_9_R2SpawnEggProvider extends SpawnEggProvider {
|
||||
@Override
|
||||
public ItemStack createEggItem(EntityType type) throws IllegalArgumentException {
|
||||
return new SpawnEgg1_9_R2(type).toItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getSpawnedType(ItemStack eggItem) throws IllegalArgumentException {
|
||||
return SpawnEgg1_9_R2.fromItemStack(eggItem).getSpawnedType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanName() {
|
||||
return "CraftBukkit 1.9.4 NMS-based provider";
|
||||
}
|
||||
}
|
3
pom.xml
3
pom.xml
@ -46,9 +46,6 @@
|
||||
<module>nms/1_8_R1Provider</module>
|
||||
<module>nms/1_8_R2Provider</module>
|
||||
<module>nms/LegacyProvider</module>
|
||||
<module>nms/1_9_R1Provider</module>
|
||||
<module>nms/1_9_R2Provider</module>
|
||||
<module>nms/1_10_R1Provider</module>
|
||||
<module>nms/ReflectionProvider</module>
|
||||
</modules>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user