Package de.jeff_media.chestsort.api
Class ChestSortEvent
java.lang.Object
org.bukkit.event.Event
de.jeff_media.chestsort.api.ChestSortEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
public class ChestSortEvent
extends org.bukkit.event.Event
implements org.bukkit.event.Cancellable
This event is called whenever ChestSort attempts to sort an
Inventory
. Can be cancelled to prevent ChestSort from manipulating this Inventory
.
You can also mark certain slots or items as unmovable or change the final sorting result.
The inventory will only be sorted AFTER this event has been called, and only if it wasn't cancelled. To check whether an inventory was actually sorted, see ChestSortPostSortEvent
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result
-
Constructor Summary
ConstructorDescriptionChestSortEvent(@NotNull org.bukkit.inventory.Inventory inv)
Creates a new ChestSortEvent -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.event.HandlerList
@NotNull org.bukkit.event.HandlerList
@NotNull org.bukkit.inventory.Inventory
Returns theInventory
associated with this event@Nullable org.bukkit.Location
Returns theLocation
associated with this event.@Nullable org.bukkit.entity.HumanEntity
Returns thePlayer
associated with this event.@NotNull List<org.bukkit.inventory.ItemStack>
Returns a list with allItemStack
s that have been marked as unmovableReturns a list with all slots that have been marked as unmovableboolean
Checks whether this event is cancelled.boolean
isUnmovable(int slot)
Checks whether a slot number is set as unmovableboolean
isUnmovable(@NotNull org.bukkit.inventory.ItemStack itemStack)
Checks whether anItemStack
is set as unmovablevoid
removeUnmovable(int slot)
Removes a slot number from the list of unmovable slotsvoid
removeUnmovable(@NotNull org.bukkit.inventory.ItemStack itemStack)
Removes anItemStack
from the list of unmovableItemStack
svoid
setCancelled(boolean cancel)
Sets the cancellation status of this event.void
setLocation(@Nullable org.bukkit.Location loc)
Sets theLocation
associated with this eventvoid
setPlayer(@Nullable org.bukkit.entity.HumanEntity player)
Sets theHumanEntity
associated with this eventvoid
setSortableMaps(@NotNull Map<org.bukkit.inventory.ItemStack,Map<String,String>> sortableMap)
void
setUnmovable(int slot)
Prevents ChestSort from sorting/moving this specific slotvoid
setUnmovable(@NotNull org.bukkit.inventory.ItemStack itemStack)
Prevents ChestSort from sorting/moving matchingItemStack
sMethods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
ChestSortEvent
public ChestSortEvent(@NotNull @NotNull org.bukkit.inventory.Inventory inv)Creates a new ChestSortEvent- Parameters:
inv
- TheInventory
about to be sorted
-
-
Method Details
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList() -
getUnmovableItemStacks
Returns a list with allItemStack
s that have been marked as unmovable- Returns:
- List of all
ItemStack
s that have been marked as unmovable
-
getUnmovableSlots
Returns a list with all slots that have been marked as unmovable- Returns:
- List of all slots that have been marked as unmovable
-
getLocation
@Nullable public @Nullable org.bukkit.Location getLocation()Returns theLocation
associated with this event. Might be null- Returns:
Location
associated with this event, or null if noLocation
has been set
-
setLocation
public void setLocation(@Nullable @Nullable org.bukkit.Location loc)Sets theLocation
associated with this event- Parameters:
loc
- New Location
-
getInventory
@NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()Returns theInventory
associated with this event- Returns:
Inventory
to be sorted
-
getSortableMaps
-
setSortableMaps
-
getPlayer
@Nullable public @Nullable org.bukkit.entity.HumanEntity getPlayer()Returns thePlayer
associated with this event. Might be null- Returns:
Player
associated with this event, or null if no player has been set
-
setPlayer
public void setPlayer(@Nullable @Nullable org.bukkit.entity.HumanEntity player)Sets theHumanEntity
associated with this event- Parameters:
player
-HumanEntity
associated with this event, can be null
-
setUnmovable
public void setUnmovable(int slot)Prevents ChestSort from sorting/moving this specific slot- Parameters:
slot
- Slot that should not be touched
-
setUnmovable
public void setUnmovable(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)Prevents ChestSort from sorting/moving matchingItemStack
s- Parameters:
itemStack
-ItemStack
that should not be touched
-
removeUnmovable
public void removeUnmovable(int slot)Removes a slot number from the list of unmovable slots- Parameters:
slot
- Slot that may be sorted
-
removeUnmovable
public void removeUnmovable(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)Removes anItemStack
from the list of unmovableItemStack
s- Parameters:
itemStack
- ItemStack that may be sorted
-
isUnmovable
public boolean isUnmovable(int slot)Checks whether a slot number is set as unmovable- Parameters:
slot
- Slot to check- Returns:
- true if the slot number has been set unmovable, otherwise false
-
isUnmovable
public boolean isUnmovable(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)Checks whether anItemStack
is set as unmovable- Parameters:
itemStack
- ItemStack to check- Returns:
- true if the ItemStack has been set unmovable, otherwise false
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlers
in classorg.bukkit.event.Event
-
isCancelled
public boolean isCancelled()Checks whether this event is cancelled. If true, theInventory
will not be sorted- Specified by:
isCancelled
in interfaceorg.bukkit.event.Cancellable
- Returns:
- true when the event has been cancelled, otherwise false
-
setCancelled
public void setCancelled(boolean cancel)Sets the cancellation status of this event. When cancelled, theInventory
will not be sorted.- Specified by:
setCancelled
in interfaceorg.bukkit.event.Cancellable
- Parameters:
cancel
- Whether this event should be cancelled
-