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.Get the handler wrapped by this handler object, if applicable, or just return this if no handler is wrapped.voidinitialize(LocalPlayer player, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set)Called when the session is first being created or/wg flushstatesis used.booleanonCrossBoundary(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.booleantestMoveTo(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.voidtick(LocalPlayer player, ApplicableRegionSet set)Called periodically (at least once every second) bySessionManagerin the server's main thread.
-
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 flushstatesis used.- 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) bySessionManagerin 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.DENYcan be returned to prevent invincibility even if another handler permits it.- Parameters:
player- The player- Returns:
- Invincibility state
-
getWrappedHandler
Get the handler wrapped by this handler object, if applicable, or just return this if no handler is wrapped.- Returns:
- any wrapped handler, or this handler itself
-