Package com.sk89q.worldguard.session
Class AbstractSessionManager
java.lang.Object
com.sk89q.worldguard.session.AbstractSessionManager
- All Implemented Interfaces:
SessionManager
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSession
(LocalPlayer player) Create a session for a player.boolean
get
(LocalPlayer player) Get a player's session.getIfPresent
(LocalPlayer player) Get a player's session, if one exists.boolean
hasBypass
(LocalPlayer player, com.sk89q.worldedit.world.World world) Check whether a player has the region bypass permission.boolean
registerHandler
(Handler.Factory<? extends Handler> factory, Handler.Factory<? extends Handler> after) Register a handler with the BukkitSessionManager.void
resetState
(LocalPlayer player) Re-initialize handlers and clear "last position," "last state," etc.boolean
unregisterHandler
(Handler.Factory<? extends Handler> factory) Unregister a handler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sk89q.worldguard.session.SessionManager
resetAllStates
-
Field Details
-
RUN_DELAY
public static final int RUN_DELAY- See Also:
-
SESSION_LIFETIME
public static final long SESSION_LIFETIME- See Also:
-
-
Constructor Details
-
AbstractSessionManager
protected AbstractSessionManager()
-
-
Method Details
-
customHandlersRegistered
public boolean customHandlersRegistered()- Specified by:
customHandlersRegistered
in interfaceSessionManager
- 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 interfaceSessionManager
- Parameters:
factory
- a factory which takes a session and returns an instance of your handlerafter
- the handler factory to insert the first handler after, to ensure a specific order when creating new sessions- Returns:
true
(as specified byCollection.add(E)
)false
if after is not registered, or factory is null
-
unregisterHandler
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 interfaceSessionManager
- Parameters:
factory
- the handler factory to unregister- Returns:
- true if the handler was registered and is now unregistered, false otherwise
-
hasBypass
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 interfaceSessionManager
- Parameters:
player
- The playerworld
- The world- Returns:
- A value
-
resetState
Description copied from interface:SessionManager
Re-initialize handlers and clear "last position," "last state," etc. information.- Specified by:
resetState
in interfaceSessionManager
- Parameters:
player
- The player
-
getIfPresent
Description copied from interface:SessionManager
Get a player's session, if one exists.- Specified by:
getIfPresent
in interfaceSessionManager
- Parameters:
player
- The player- Returns:
- The session
-
get
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 interfaceSessionManager
- Parameters:
player
- The player to get a session for- Returns:
- The
player
's session
-
createSession
Description copied from interface:SessionManager
Create a session for a player.- Specified by:
createSession
in interfaceSessionManager
- Parameters:
player
- The player- Returns:
- The new session
-