Class SpecialItemUseSession

java.lang.Object
de.marcely.bedwars.api.game.specialitem.SpecialItemUseSession

public abstract class SpecialItemUseSession extends Object
Represents a session of a special item use
A new session is created every time someone uses a special item.
Make sure to call stop(), even when you're handler, after you're done as the plugin will invoke handleStop() for EVERY still active session after the round ended.
Also make sure to invoke takeItem() if you wish the item to be taken away
  • Constructor Details

  • Method Details

    • handleStop

      protected abstract void handleStop()
      Forcefully stops and cleans the session
    • isActive

      public boolean isActive()
      Returns true when stop() hasn't been called yet
      Returns:
      Whether or not the session is still active
    • getEvent

      @Nullable public @Nullable PlayerUseSpecialItemEvent getEvent()
      Returns the event/session details
      Returns:
      The event included in this session.null when isActive() returns false
    • stop

      public boolean stop()
      Safely stops and cleans the session
      It's safe to to call this even if it hasn't been passed yet to SpecialItemUseHandler.openSession(PlayerUseSpecialItemEvent)
      Returns:
      false if it already has been stopped
    • takeItem

      public boolean takeItem()
      Takes a special item from the players inventory
      Returns:
      false if it failed as he doesn't have any special items of that type anymore
      Throws:
      IllegalStateException - When the session already has been stopped