Interface SessionManager

All Known Implementing Classes:
AbstractSessionManager

public interface SessionManager
  • Method Details

    • hasBypass

      boolean hasBypass(LocalPlayer player, com.sk89q.worldedit.world.World world)
      Check whether a player has the region bypass permission.

      The return value may be cached for a few seconds.

      Parameters:
      player - The player
      world - The world
      Returns:
      A value
    • resetAllStates

      void resetAllStates()
      Re-initialize handlers and clear "last position," "last state," etc. information for all players.
    • resetState

      void resetState(LocalPlayer player)
      Re-initialize handlers and clear "last position," "last state," etc. information.
      Parameters:
      player - The player
    • customHandlersRegistered

      boolean customHandlersRegistered()
      Returns:
      true if custom handlers are or were at some point registered, false otherwise
    • registerHandler

      boolean registerHandler(Handler.Factory<? extends Handler> factory, @Nullable Handler.Factory<? extends Handler> after)
      Register a handler with the BukkitSessionManager. You may specify another handler class to ensure your handler is always registered after that class. If that class is not already registered, this method will return false. For example, flags that always act on a player in a region (like HealFlag and FeedFlag) should be registered earlier, whereas flags that only take effect when a player leaves the region (like FarewellFlag and GreetingFlag) should be registered after the ExitFlag.Factory.class handler factory.
      Parameters:
      factory - a factory which takes a session and returns an instance of your handler
      after - the handler factory to insert the first handler after, to ensure a specific order when creating new sessions
      Returns:
      true (as specified by Collection.add(E)) false if after is not registered, or factory is null
    • unregisterHandler

      boolean unregisterHandler(Handler.Factory<? extends Handler> factory)
      Unregister a handler. This will prevent it from being added to newly created sessions only. Existing sessions with the handler will continue to use it. Will return false if the handler was not registered to begin with.
      Parameters:
      factory - the handler factory to unregister
      Returns:
      true if the handler was registered and is now unregistered, false otherwise
    • createSession

      Session createSession(LocalPlayer player)
      Create a session for a player.
      Parameters:
      player - The player
      Returns:
      The new session
    • getIfPresent

      @Nullable Session getIfPresent(LocalPlayer player)
      Get a player's session, if one exists.
      Parameters:
      player - The player
      Returns:
      The session
    • get

      Session get(LocalPlayer player)
      Get a player's session. A session will be created if there is no existing session for the player.

      This method can only be called from the main thread. While the session manager itself is thread-safe, some of the handlers may require initialization that requires the server main thread.

      Parameters:
      player - The player to get a session for
      Returns:
      The player's session