Class Handler
java.lang.Object
com.sk89q.worldguard.session.handler.Handler
- Direct Known Subclasses:
EntryFlag
,FarewellFlag
,FeedFlag
,FlagValueChangeHandler
,GodMode
,GreetingFlag
,HealFlag
,WaterBreathing
Stores session data and possibly acts on it.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInvincibility
(LocalPlayer player) Return whether the player should be invincible.Get the session.void
initialize
(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) Called when the session is first being created or/wg flushstates
is used.boolean
onCrossBoundary
(LocalPlayer player, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) Called when a player has moved into a new location.boolean
testMoveTo
(LocalPlayer player, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, MoveType moveType) Called whenSession.testMoveTo(LocalPlayer, Location, MoveType)
is called.void
tick
(LocalPlayer player, ApplicableRegionSet set) Called periodically (at least once every second) bySessionManager
in the server's main thread.void
uninitialize
(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) Called when the session should clear its caches.
-
Constructor Details
-
Handler
Create a new handler.- Parameters:
session
- The session
-
-
Method Details
-
getSession
Get the session.- Returns:
- The session
-
initialize
public void initialize(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) Called when the session is first being created or/wg flushstates
is used.- Parameters:
player
- The playercurrent
- The player's current locationset
- The regions for the current location
-
uninitialize
public void uninitialize(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) Called when the session should clear its caches.- Parameters:
player
- The playercurrent
- The player's current locationset
- The regions for the current location
-
testMoveTo
public boolean testMoveTo(LocalPlayer player, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, MoveType moveType) Called whenSession.testMoveTo(LocalPlayer, Location, MoveType)
is called.If this method returns
false
, then no other handlers will be run (for this move attempt).- Parameters:
player
- The playerfrom
- The previous, valid, locationto
- The new location to testtoSet
- The regions for the new locationmoveType
- The type of movement- Returns:
- Whether the movement should be allowed
-
onCrossBoundary
public boolean onCrossBoundary(LocalPlayer player, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) Called when a player has moved into a new location.This is called only if the move test (
Session.testMoveTo(LocalPlayer, Location, MoveType)
) was successful.If this method returns
false
, then no other handlers will be run (for this move attempt).- Parameters:
player
- The playerfrom
- The previous, valid, locationto
- The new location to testtoSet
- The regions for the new locationentered
- The list of regions that have been enteredexited
- The list of regions that have been leftmoveType
- The type of move- Returns:
- Whether the movement should be allowed
-
tick
Called periodically (at least once every second) bySessionManager
in the server's main thread.- Parameters:
player
- The playerset
- The regions for the player's current location
-
getInvincibility
Return whether the player should be invincible.StateFlag.State.DENY
can be returned to prevent invincibility even if another handler permits it.- Parameters:
player
- The player- Returns:
- Invincibility state
-