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
    • isStoppedWithPlayerQuit

      public boolean isStoppedWithPlayerQuit()
      Get whether this session shall stop if the player quits the arena.

      The default implementation always retruns true. You may override this method and include your own logic.

      Returns:
      true to call stop() as a result
    • isActive

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

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

      public final boolean stop()
      Safely stops and cleans the session
      It's safe 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 final 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