Skip to content

Instantly share code, notes, and snippets.

@DarkSeraphim
Created January 28, 2014 18:52
Show Gist options
  • Save DarkSeraphim/8673760 to your computer and use it in GitHub Desktop.
Save DarkSeraphim/8673760 to your computer and use it in GitHub Desktop.
import java.util.List;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
/**
*
* @author DarkSeraphim
*/
public class PotionUtil
{
public static ItemStack createPotion(PotionEffect effect, PotionType effectColour, boolean effectIsSplash)
{
return createPotion(null, null, effect, effectColour, effectIsSplash);
}
public static ItemStack createPotion(String name, PotionEffect effect, PotionType effectColour, boolean effectIsSplash)
{
return createPotion(name, null, effect, effectColour, effectIsSplash);
}
public static ItemStack createPotion(List<String> lore, PotionEffect effect, PotionType effectColour, boolean effectIsSplash)
{
return createPotion(null, lore, effect, effectColour, effectIsSplash);
}
public static ItemStack createPotion(String name, List<String> lore, PotionEffect effect, PotionType effectColour, boolean effectIsSplash)
{
Potion pot = new Potion(effectColour, 1);
if(effectIsSplash)
pot.splash();
ItemStack stack = pot.toItemStack(1);
PotionMeta meta = (PotionMeta)stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
meta.clearCustomEffects();
if(effect != null)
{
meta.addCustomEffect(effect, true);
meta.setMainEffect(effect.getType());
}
stack.setItemMeta(meta);
return stack;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment