Got rid of deprecated methods.

This commit is contained in:
tastybento 2017-08-30 16:00:00 -07:00
parent 3b604058da
commit 6314f1377e

View File

@ -8,8 +8,9 @@ import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.SpawnEgg; import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion; import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import us.tastybento.bskyblock.util.nms.NMSAbstraction; import us.tastybento.bskyblock.util.nms.NMSAbstraction;
@ -48,8 +49,11 @@ public class NMSHandler implements NMSAbstraction{
*/ */
@Override @Override
public ItemStack getSpawnEgg(EntityType type, int amount) { public ItemStack getSpawnEgg(EntityType type, int amount) {
SpawnEgg egg = new SpawnEgg(type); ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
return egg.toItemStack(amount); SpawnEggMeta spm = (SpawnEggMeta)egg.getItemMeta();
spm.setSpawnedType(type);
egg.setItemMeta(spm);
return egg;
} }
@Override @Override
@ -82,7 +86,6 @@ public class NMSHandler implements NMSAbstraction{
} }
@SuppressWarnings("deprecation")
@Override @Override
public ItemStack setPotion(Material itemMaterial, Tag itemTags, public ItemStack setPotion(Material itemMaterial, Tag itemTags,
ItemStack chestItem) { ItemStack chestItem) {
@ -126,10 +129,11 @@ public class NMSHandler implements NMSAbstraction{
}else{ }else{
return chestItem; return chestItem;
} }
Potion potion = new Potion(type); chestItem = new ItemStack(Material.POTION, chestItem.getAmount());
potion.setHasExtendedDuration(_long); PotionMeta pm = (PotionMeta)chestItem.getItemMeta();
potion.setLevel(strong ? 2 : 1); PotionData pd = new PotionData(type, _long, strong);
chestItem = potion.toItemStack(chestItem.getAmount()); pm.setBasePotionData(pd);
chestItem.setItemMeta(pm);
} }
return chestItem; return chestItem;