Class Handler

java.lang.Object
com.sk89q.worldguard.session.handler.Handler
Direct Known Subclasses:
EntryFlag, FarewellFlag, FeedFlag, FlagValueChangeHandler, GodMode, GreetingFlag, HealFlag, WaterBreathing

public abstract class Handler extends Object
Stores session data and possibly acts on it.
  • Constructor Details

    • Handler

      protected Handler(Session session)
      Create a new handler.
      Parameters:
      session - The session
  • Method Details

    • getSession

      public Session 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 player
      current - The player's current location
      set - 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 player
      current - The player's current location
      set - 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 when Session.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 player
      from - The previous, valid, location
      to - The new location to test
      toSet - The regions for the new location
      moveType - 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 player
      from - The previous, valid, location
      to - The new location to test
      toSet - The regions for the new location
      entered - The list of regions that have been entered
      exited - The list of regions that have been left
      moveType - The type of move
      Returns:
      Whether the movement should be allowed
    • tick

      public void tick(LocalPlayer player, ApplicableRegionSet set)
      Called periodically (at least once every second) by SessionManager in the server's main thread.
      Parameters:
      player - The player
      set - The regions for the player's current location
    • getInvincibility

      @Nullable public StateFlag.State getInvincibility(LocalPlayer player)
      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