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.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChestSortEvent​(@NotNull org.bukkit.inventory.Inventory inv)
    Creates a new ChestSortEvent
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.inventory.Inventory
    Returns the Inventory associated with this event
    @Nullable org.bukkit.Location
    Returns the Location associated with this event.
    @Nullable org.bukkit.entity.HumanEntity
    Returns the Player associated with this event.
    @NotNull Map<org.bukkit.inventory.ItemStack,​Map<String,​String>>
     
    @NotNull List<org.bukkit.inventory.ItemStack>
    Returns a list with all ItemStacks that have been marked as unmovable
    @NotNull List<Integer>
    Returns a list with all slots that have been marked as unmovable
    boolean
    Checks whether this event is cancelled.
    boolean
    isUnmovable​(int slot)
    Checks whether a slot number is set as unmovable
    boolean
    isUnmovable​(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Checks whether an ItemStack is set as unmovable
    void
    removeUnmovable​(int slot)
    Removes a slot number from the list of unmovable slots
    void
    removeUnmovable​(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Removes an ItemStack from the list of unmovable ItemStacks
    void
    setCancelled​(boolean cancel)
    Sets the cancellation status of this event.
    void
    setLocation​(@Nullable org.bukkit.Location loc)
    Sets the Location associated with this event
    void
    setPlayer​(@Nullable org.bukkit.entity.HumanEntity player)
    Sets the HumanEntity associated with this event
    void
    setSortableMaps​(@NotNull Map<org.bukkit.inventory.ItemStack,​Map<String,​String>> sortableMap)
     
    void
    setUnmovable​(int slot)
    Prevents ChestSort from sorting/moving this specific slot
    void
    setUnmovable​(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Prevents ChestSort from sorting/moving matching ItemStacks

    Methods inherited from class org.bukkit.event.Event

    getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

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

    • ChestSortEvent

      public ChestSortEvent(@NotNull @NotNull org.bukkit.inventory.Inventory inv)
      Creates a new ChestSortEvent
      Parameters:
      inv - The Inventory about to be sorted
  • Method Details

    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
    • getUnmovableItemStacks

      @NotNull public @NotNull List<org.bukkit.inventory.ItemStack> getUnmovableItemStacks()
      Returns a list with all ItemStacks that have been marked as unmovable
      Returns:
      List of all ItemStacks that have been marked as unmovable
    • getUnmovableSlots

      @NotNull public @NotNull List<Integer> 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 the Location associated with this event. Might be null
      Returns:
      Location associated with this event, or null if no Location has been set
    • setLocation

      public void setLocation(@Nullable @Nullable org.bukkit.Location loc)
      Sets the Location associated with this event
      Parameters:
      loc - New Location
    • getInventory

      @NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()
      Returns the Inventory associated with this event
      Returns:
      Inventory to be sorted
    • getSortableMaps

      @NotNull public @NotNull Map<org.bukkit.inventory.ItemStack,​Map<String,​String>> getSortableMaps()
    • setSortableMaps

      public void setSortableMaps(@NotNull @NotNull Map<org.bukkit.inventory.ItemStack,​Map<String,​String>> sortableMap)
    • getPlayer

      @Nullable public @Nullable org.bukkit.entity.HumanEntity getPlayer()
      Returns the Player 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 the HumanEntity 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 matching ItemStacks
      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 an ItemStack from the list of unmovable ItemStacks
      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 an ItemStack 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 class org.bukkit.event.Event
    • isCancelled

      public boolean isCancelled()
      Checks whether this event is cancelled. If true, the Inventory will not be sorted
      Specified by:
      isCancelled in interface org.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, the Inventory will not be sorted.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancel - Whether this event should be cancelled