Package com.sk89q.worldguard.session
Interface SessionManager
- All Known Implementing Classes:
AbstractSessionManager
public interface SessionManager
-
Method Summary
Modifier and TypeMethodDescriptioncreateSession
(LocalPlayer player) Deprecated.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
Re-initialize handlers and clear "last position," "last state," etc.void
resetState
(LocalPlayer player) Re-initialize handlers and clear "last position," "last state," etc.boolean
unregisterHandler
(Handler.Factory<? extends Handler> factory) Unregister a handler.
-
Method Details
-
hasBypass
Check whether a player has the region bypass permission.The return value may be cached for a few seconds.
- Parameters:
player
- The playerworld
- The world- Returns:
- A value
-
resetAllStates
void resetAllStates()Re-initialize handlers and clear "last position," "last state," etc. information for all players. -
resetState
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 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
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
Deprecated.Useget(com.sk89q.worldguard.LocalPlayer)
insteadCreate a session for a player.- Parameters:
player
- The player- Returns:
- The new session
-
getIfPresent
Get a player's session, if one exists.- Parameters:
player
- The player- Returns:
- The session
-
get
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
-
get(com.sk89q.worldguard.LocalPlayer)
instead