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
ConstructorsConstructorDescriptionCustomFoodComponent
(int nutrition, float saturation, boolean canEatOnFull) Constructs a new CustomFoodComponent with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.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.
-
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 providessaturation
- the saturation modifier of the foodcanEatOnFull
- 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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.bukkit.inventory.meta.components.FoodComponent
- Parameters:
canAlwaysEat
- true if the food can be eaten on full hunger, false otherwise
-
serialize
Serializes the food component properties into a map.- Specified by:
serialize
in interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
- Returns:
- a map containing the serialized properties of the food component
-