Expand PotionMeta Api to allow getting effective potion colour and effects (#12390)
This commit is contained in:
@ -60,6 +60,27 @@ public interface PotionContents {
|
||||
@Contract(pure = true)
|
||||
@Nullable String customName();
|
||||
|
||||
/**
|
||||
* All effects that this component applies.
|
||||
* <p>
|
||||
* This is a combination of the base potion type and any custom effects.
|
||||
*
|
||||
* @return an unmodifiable list of all effects.
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
@Unmodifiable List<PotionEffect> allEffects();
|
||||
|
||||
/**
|
||||
* Computes the effective colour of this potion contents component.
|
||||
* <p>
|
||||
* This blends all custom effects, or uses a default fallback colour.
|
||||
* It may or may not have an alpha channel, used for tipped arrows.
|
||||
*
|
||||
* @return the effective colour this component would display with.
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
Color computeEffectiveColor();
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.NonExtendable
|
||||
interface Builder extends DataComponentBuilder<PotionContents> {
|
||||
|
||||
@ -8,6 +8,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
/**
|
||||
* Represents a potion or item that can have custom effects.
|
||||
@ -74,6 +75,16 @@ public interface PotionMeta extends ItemMeta {
|
||||
@NotNull
|
||||
List<PotionEffect> getCustomEffects();
|
||||
|
||||
/**
|
||||
* All effects that this potion meta holds.
|
||||
* <p>
|
||||
* This is a combination of the base potion type and any custom effects.
|
||||
*
|
||||
* @return an unmodifiable list of all effects.
|
||||
*/
|
||||
@NotNull
|
||||
@Unmodifiable List<PotionEffect> getAllEffects();
|
||||
|
||||
/**
|
||||
* Adds a custom potion effect to this potion.
|
||||
*
|
||||
@ -146,6 +157,16 @@ public interface PotionMeta extends ItemMeta {
|
||||
*/
|
||||
void setColor(@Nullable Color color);
|
||||
|
||||
/**
|
||||
* Computes the effective colour of this potion meta.
|
||||
* <p>
|
||||
* This blends all custom effects, or uses a default fallback color.
|
||||
*
|
||||
* @return the effective potion color
|
||||
*/
|
||||
@NotNull
|
||||
Color computeEffectiveColor();
|
||||
|
||||
/**
|
||||
* Checks for existence of a custom potion name translation suffix.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user