#522: Add piglin bartering API

By: Lars Dormans <lars.dormans@live.nl>
This commit is contained in:
Bukkit/Spigot
2021-05-28 08:59:13 +10:00
parent 3d74697e24
commit c6409a81fd
2 changed files with 149 additions and 1 deletions

View File

@@ -1,9 +1,14 @@
package org.bukkit.entity;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Piglin.
*/
public interface Piglin extends PiglinAbstract {
public interface Piglin extends PiglinAbstract, InventoryHolder {
/**
* Get whether the piglin is able to hunt hoglins.
@@ -18,4 +23,71 @@ public interface Piglin extends PiglinAbstract {
* @param flag Whether the piglin is able to hunt hoglins.
*/
public void setIsAbleToHunt(boolean flag);
/**
* Adds a material to the allowed list of materials to barter with.
*
* @param material The material to add
*
* @return true if the item has been added successfully, false otherwise
*/
public boolean addBarterMaterial(@NotNull Material material);
/**
* Removes a material from the allowed list of materials to barter with.
*
* <strong>Note:</strong> It's not possible to override the default
* bartering item gold_ingots as payment. To block gold_ingots see
* {@link org.bukkit.event.entity.PiglinBarterEvent}.
*
* @param material The material to remove
*
* @return true if the item has been removed successfully, false otherwise
*/
public boolean removeBarterMaterial(@NotNull Material material);
/**
* Adds a material the piglin will pickup and store in his inventory.
*
* @param material The material you want the piglin to be interested in
*
* @return true if the item has been added successfully, false otherwise
*/
public boolean addMaterialOfInterest(@NotNull Material material);
/**
* Removes a material from the list of materials the piglin will pickup.
*
* <strong>Note:</strong> It's not possible to override the default list of
* item the piglin will pickup. To cancel pickup see
* {@link org.bukkit.event.entity.EntityPickupItemEvent}.
*
* @param material The material you want removed from the interest list
* @return true if the item has been removed successfully, false otherwise
*/
public boolean removeMaterialOfInterest(@NotNull Material material);
/**
* Returns a immutable set of materials the piglins will pickup.
* <br>
* <strong>Note:</strong> This set will not include the items that are set
* by default. To interact with those items see
* {@link org.bukkit.event.entity.EntityPickupItemEvent}.
*
* @return An immutable materials set
*/
@NotNull
public Set<Material> getInterestList();
/**
* Returns a immutable set of materials the piglins will barter with.
*
* <strong>Note:</strong> This set will not include the items that are set
* by default. To interact with those items see
* {@link org.bukkit.event.entity.PiglinBarterEvent}.
*
* @return An immutable materials set
*/
@NotNull
public Set<Material> getBarterList();
}