Class CustomFoodComponent

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomFoodComponent
All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.inventory.meta.components.FoodComponent

public class CustomFoodComponent extends Object implements org.bukkit.inventory.meta.components.FoodComponent
Represents a custom implementation of the FoodComponent. This class allows defining custom food properties such as nutrition, saturation, and whether the item can be eaten when the player is not hungry.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomFoodComponent(int nutrition, float saturation, boolean canEatOnFull)
    Constructs a new CustomFoodComponent with the specified properties.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the food can be eaten when the player is not hungry.
    int
    Gets the nutrition value of the food.
    float
    Gets the saturation value of the food.
    @NotNull Map<String,Object>
    Serializes the food component properties into a map.
    void
    setCanAlwaysEat(boolean canAlwaysEat)
    Sets whether the food can be eaten when the player is not hungry.
    void
    setNutrition(int nutrition)
    Sets the nutrition value of the food.
    void
    setSaturation(float saturation)
    Sets the saturation value of the food.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomFoodComponent

      public CustomFoodComponent(int nutrition, float saturation, boolean canEatOnFull)
      Constructs a new CustomFoodComponent with the specified properties.
      Parameters:
      nutrition - the amount of nutrition the food provides
      saturation - the saturation modifier of the food
      canEatOnFull - whether the food can be eaten even if the player is not hungry
  • Method Details

    • getNutrition

      public int getNutrition()
      Gets the nutrition value of the food.
      Specified by:
      getNutrition in interface org.bukkit.inventory.meta.components.FoodComponent
      Returns:
      the nutrition value
    • setNutrition

      public void setNutrition(int nutrition)
      Sets the nutrition value of the food.
      Specified by:
      setNutrition in interface org.bukkit.inventory.meta.components.FoodComponent
      Parameters:
      nutrition - the new nutrition value
    • getSaturation

      public float getSaturation()
      Gets the saturation value of the food.
      Specified by:
      getSaturation in interface org.bukkit.inventory.meta.components.FoodComponent
      Returns:
      the saturation value
    • setSaturation

      public void setSaturation(float saturation)
      Sets the saturation value of the food.
      Specified by:
      setSaturation in interface org.bukkit.inventory.meta.components.FoodComponent
      Parameters:
      saturation - the new saturation value
    • canAlwaysEat

      public boolean canAlwaysEat()
      Checks if the food can be eaten when the player is not hungry.
      Specified by:
      canAlwaysEat in interface org.bukkit.inventory.meta.components.FoodComponent
      Returns:
      true if the food can be eaten on full hunger, false otherwise
    • setCanAlwaysEat

      public void setCanAlwaysEat(boolean canAlwaysEat)
      Sets whether the food can be eaten when the player is not hungry.
      Specified by:
      setCanAlwaysEat in interface org.bukkit.inventory.meta.components.FoodComponent
      Parameters:
      canAlwaysEat - true if the food can be eaten on full hunger, false otherwise
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serializes the food component properties into a map.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Returns:
      a map containing the serialized properties of the food component