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.booleanget(LocalPlayer player)Get a player's session.getIfPresent(LocalPlayer player)Get a player's session, if one exists.booleanhasBypass(LocalPlayer player, com.sk89q.worldedit.world.World world)Check whether a player has the region bypass permission.booleanregisterHandler(Handler.Factory<? extends Handler> factory, Handler.Factory<? extends Handler> after)Register a handler with the BukkitSessionManager.voidresetState(LocalPlayer player)Re-initialize handlers and clear "last position," "last state," etc.booleanunregisterHandler(Handler.Factory<? extends Handler> factory)Unregister a handler.protected Handler.Factory<? extends Handler>wrapForRegistration(Handler.Factory<? extends Handler> factory)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sk89q.worldguard.session.SessionManager
resetAllStates
-
Field Details
-
RUN_DELAY
public static final int RUN_DELAY- See Also:
- Constant Field Values
-
SESSION_LIFETIME
public static final long SESSION_LIFETIME- See Also:
- Constant Field Values
-
-
Constructor Details
-
AbstractSessionManager
protected AbstractSessionManager()
-
-
Method Details
-
customHandlersRegistered
public boolean customHandlersRegistered()- Specified by:
customHandlersRegisteredin interfaceSessionManager- Returns:
- true if custom handlers are or were at some point registered, false otherwise
-
wrapForRegistration
protected Handler.Factory<? extends Handler> wrapForRegistration(Handler.Factory<? extends Handler> factory) -
registerHandler
public boolean registerHandler(Handler.Factory<? extends Handler> factory, @Nullable Handler.Factory<? extends Handler> after)Description copied from interface:SessionManagerRegister 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:
registerHandlerin 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))falseif after is not registered, or factory is null
-
unregisterHandler
Description copied from interface:SessionManagerUnregister 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:
unregisterHandlerin 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:SessionManagerCheck whether a player has the region bypass permission.The return value may be cached for a few seconds.
- Specified by:
hasBypassin interfaceSessionManager- Parameters:
player- The playerworld- The world- Returns:
- A value
-
resetState
Description copied from interface:SessionManagerRe-initialize handlers and clear "last position," "last state," etc. information.- Specified by:
resetStatein interfaceSessionManager- Parameters:
player- The player
-
getIfPresent
Description copied from interface:SessionManagerGet a player's session, if one exists.- Specified by:
getIfPresentin interfaceSessionManager- Parameters:
player- The player- Returns:
- The session
-
get
Description copied from interface:SessionManagerGet 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:
getin interfaceSessionManager- Parameters:
player- The player to get a session for- Returns:
- The
player's session
-
createSession
Description copied from interface:SessionManagerCreate a session for a player.- Specified by:
createSessionin interfaceSessionManager- Parameters:
player- The player- Returns:
- The new session
-