Java Code Examples for org.bukkit.inventory.meta.PotionMeta#setColor()

The following examples show how to use org.bukkit.inventory.meta.PotionMeta#setColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LugolsIodinePotion.java    From CraftserveRadiation with Apache License 2.0 6 votes vote down vote up
public PotionMeta convert(PotionMeta potionMeta) {
    Objects.requireNonNull(potionMeta, "potionMeta");

    Duration duration = this.config.duration();
    String formattedDuration = this.formatDuration(this.config.duration());

    if (this.config.color != null) {
        potionMeta.setColor(this.config.color);
    }
    potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
    potionMeta.setDisplayName(ChatColor.AQUA + this.config.name());
    potionMeta.setLore(Collections.singletonList(ChatColor.BLUE + MessageFormat.format(this.config.description(), formattedDuration)));

    PersistentDataContainer container = potionMeta.getPersistentDataContainer();
    container.set(this.potionKey, PersistentDataType.BYTE, TRUE);
    container.set(this.durationSecondsKey, PersistentDataType.INTEGER, (int) duration.getSeconds());
    return potionMeta;
}
 
Example 2
Source File: CustomPotion.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public CustomPotion(String name, Color color, PotionEffect effect, String... lore) {
	super(Material.POTION, name, lore);
	PotionMeta meta = (PotionMeta) getItemMeta();
	meta.setColor(color);
	meta.addCustomEffect(effect, true);
	setItemMeta(meta);
}
 
Example 3
Source File: VersionUtils_1_13.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PotionMeta setPotionColor(PotionMeta potionMeta, Color color){
    potionMeta.setColor(color);
    return potionMeta;
}
 
Example 4
Source File: VersionUtils_1_12.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PotionMeta setPotionColor(PotionMeta potionMeta, Color color){
    potionMeta.setColor(color);
    return potionMeta;
}