mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
parent
3d74697e24
commit
c6409a81fd
@ -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();
|
||||
}
|
||||
|
@ -0,0 +1,76 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Stores all data related to the bartering interaction with a piglin.
|
||||
*
|
||||
* This event can be triggered by a piglin picking up an item that's on its
|
||||
* bartering list.
|
||||
*/
|
||||
public class PiglinBarterEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final List<ItemStack> outcome;
|
||||
private final ItemStack input;
|
||||
|
||||
public PiglinBarterEvent(@NotNull Piglin what, @NotNull ItemStack input, @NotNull List<ItemStack> outcome) {
|
||||
super(what);
|
||||
|
||||
this.input = input;
|
||||
this.outcome = outcome;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Piglin getEntity() {
|
||||
return (Piglin) super.getEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input of the barter.
|
||||
*
|
||||
* @return The item that was used to barter with
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getInput() {
|
||||
return input.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable list representing the outcome of the barter.
|
||||
*
|
||||
* @return A mutable list of the item the player will receive
|
||||
*/
|
||||
@NotNull
|
||||
public List<ItemStack> getOutcome() {
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user