Class AbstractSessionManager

java.lang.Object
com.sk89q.worldguard.session.AbstractSessionManager
All Implemented Interfaces:
SessionManager

public abstract class AbstractSessionManager extends Object implements SessionManager
  • Field Details

  • Constructor Details

    • AbstractSessionManager

      protected AbstractSessionManager()
  • Method Details

    • customHandlersRegistered

      public boolean customHandlersRegistered()
      Specified by:
      customHandlersRegistered in interface SessionManager
      Returns:
      true if custom handlers are or were at some point registered, false otherwise
    • registerHandler

      public boolean registerHandler(Handler.Factory<? extends Handler> factory, @Nullable Handler.Factory<? extends Handler> after)
      Description copied from interface: SessionManager
      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.
      Specified by:
      registerHandler in interface SessionManager
      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

      public boolean unregisterHandler(Handler.Factory<? extends Handler> factory)
      Description copied from interface: SessionManager
      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.
      Specified by:
      unregisterHandler in interface SessionManager
      Parameters:
      factory - the handler factory to unregister
      Returns:
      true if the handler was registered and is now unregistered, false otherwise
    • hasBypass

      public boolean hasBypass(LocalPlayer player, com.sk89q.worldedit.world.World world)
      Description copied from interface: SessionManager
      Check whether a player has the region bypass permission.

      The return value may be cached for a few seconds.

      Specified by:
      hasBypass in interface SessionManager
      Parameters:
      player - The player
      world - The world
      Returns:
      A value
    • resetState

      public void resetState(LocalPlayer player)
      Description copied from interface: SessionManager
      Re-initialize handlers and clear "last position," "last state," etc. information.
      Specified by:
      resetState in interface SessionManager
      Parameters:
      player - The player
    • getIfPresent

      @Nullable public Session getIfPresent(LocalPlayer player)
      Description copied from interface: SessionManager
      Get a player's session, if one exists.
      Specified by:
      getIfPresent in interface SessionManager
      Parameters:
      player - The player
      Returns:
      The session
    • get

      public Session get(LocalPlayer player)
      Description copied from interface: SessionManager
      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.

      Specified by:
      get in interface SessionManager
      Parameters:
      player - The player to get a session for
      Returns:
      The player's session
    • createSession

      public Session createSession(LocalPlayer player)
      Description copied from interface: SessionManager
      Create a session for a player.
      Specified by:
      createSession in interface SessionManager
      Parameters:
      player - The player
      Returns:
      The new session