Created
April 22, 2017 12:43
-
-
Save brcdev/b1b508902d969c36627508f1e9c1d606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.brcdev.shopgui.provider.spawner; | |
import org.bukkit.entity.EntityType; | |
import org.bukkit.inventory.ItemStack; | |
public abstract class SpawnerProvider { | |
/** | |
* Gets the spawner item stack | |
* | |
* @param entityId Name of the entity | |
* @param customName Spawner's display name | |
* @return spawner item stack | |
*/ | |
public abstract ItemStack getSpawnerItem(String entityId, String customName); | |
/** | |
* Gets the entity ID (one of {@link EntityType}) | |
* | |
* @param itemStack Spawner item stack | |
* @return entity ID | |
*/ | |
public abstract String getSpawnerEntityId(ItemStack itemStack); | |
/** | |
* Gets a neatly formatted entity name | |
* | |
* @param itemStack Spawner item stack | |
* @return entity name | |
*/ | |
public abstract String getSpawnerEntityName(ItemStack itemStack); | |
/** | |
* Converts the entity name to numeric ID | |
* | |
* @param entityId Name of the entity | |
* @return numeric ID of an entity | |
*/ | |
@SuppressWarnings("deprecation") | |
protected short getNumericEntityId(String entityId) { | |
short entity = 0; | |
try { | |
entity = EntityType.fromName(entityId).getTypeId(); | |
} catch(NullPointerException ex) { | |
} | |
return entity; | |
} | |
/** | |
* Converts the numeric entity ID to entity name | |
* | |
* @param entityId numeric ID of an entity | |
* @return name of an entity | |
*/ | |
@SuppressWarnings("deprecation") | |
protected String getStringEntityId(short entityId) { | |
String entity = ""; | |
try { | |
entity = EntityType.fromId(entityId).getName(); | |
} catch(NullPointerException ex) { | |
} | |
return entity; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment