Interface FoodComponent

All Superinterfaces:
ConfigurationSerializable

@Experimental public interface FoodComponent extends ConfigurationSerializable
Represents a component which can turn any item into food.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An effect which may be applied by this item when eaten.
  • Method Summary

    Modifier and Type
    Method
    Description
    addEffect(PotionEffect effect, float probability)
    Adds an effect which may be applied by this item when eaten.
    boolean
    Gets if this item can be eaten even when not hungry.
    float
    Gets the time in seconds it will take for this item to be eaten.
    Gets the effects which may be applied by this item when eaten.
    int
    Gets the food restored by this item when eaten.
    float
    Gets the saturation restored by this item when eaten.
    void
    setCanAlwaysEat(boolean canAlwaysEat)
    Sets if this item can be eaten even when not hungry.
    void
    setEatSeconds(float eatSeconds)
    Sets the time in seconds it will take for this item to be eaten.
    void
    Sets the effects which may be applied by this item when eaten.
    void
    setNutrition(int nutrition)
    Sets the food restored by this item when eaten.
    void
    setSaturation(float saturation)
    Sets the saturation restored by this item when eaten.

    Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable

    serialize
  • Method Details

    • getNutrition

      int getNutrition()
      Gets the food restored by this item when eaten.
      Returns:
      nutrition value
    • setNutrition

      void setNutrition(int nutrition)
      Sets the food restored by this item when eaten.
      Parameters:
      nutrition - new nutrition value, must be non-negative
    • getSaturation

      float getSaturation()
      Gets the saturation restored by this item when eaten.
      Returns:
      saturation value
    • setSaturation

      void setSaturation(float saturation)
      Sets the saturation restored by this item when eaten.
      Parameters:
      saturation - new saturation value
    • canAlwaysEat

      boolean canAlwaysEat()
      Gets if this item can be eaten even when not hungry.
      Returns:
      true if always edible
    • setCanAlwaysEat

      void setCanAlwaysEat(boolean canAlwaysEat)
      Sets if this item can be eaten even when not hungry.
      Parameters:
      canAlwaysEat - whether always edible
    • getEatSeconds

      float getEatSeconds()
      Gets the time in seconds it will take for this item to be eaten.
      Returns:
      eat time
    • setEatSeconds

      void setEatSeconds(float eatSeconds)
      Sets the time in seconds it will take for this item to be eaten.
      Parameters:
      eatSeconds - new eat time
    • getEffects

      @NotNull List<FoodComponent.FoodEffect> getEffects()
      Gets the effects which may be applied by this item when eaten.
      Returns:
      food effects
    • setEffects

      void setEffects(@NotNull List<FoodComponent.FoodEffect> effects)
      Sets the effects which may be applied by this item when eaten.
      Parameters:
      effects - new effects
    • addEffect

      @NotNull FoodComponent.FoodEffect addEffect(@NotNull PotionEffect effect, float probability)
      Adds an effect which may be applied by this item when eaten.
      Parameters:
      effect - the effect
      probability - the probability of the effect being applied
      Returns:
      the added effect