Class RegionCommands

java.lang.Object
com.sk89q.worldguard.commands.region.RegionCommands

public final class RegionCommands extends Object
Implements the /region commands for WorldGuard.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static ProtectedRegion
    checkExistingRegion(RegionManager regionManager, String id, boolean allowGlobal)
    Get a protected region by a given name, otherwise throw a CommandException.
    protected static void
    checkRegionDoesNotExist(RegionManager manager, String id, boolean mayRedefine)
    Check that a region with the given ID does not already exist.
    protected static ProtectedRegion
    checkRegionFromSelection(com.sk89q.worldedit.extension.platform.Actor actor, String id)
    Create a ProtectedRegion from the actor's selection.
    protected static String
    checkRegionId(String id, boolean allowGlobal)
    Validate a region ID.
    protected static RegionManager
    checkRegionManager(com.sk89q.worldedit.world.World world)
    Check that the given region manager is not null.
    protected static ProtectedRegion
    checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal, String rgCmd)
    Get the region at the player's location, if possible.
    protected static ProtectedRegion
    checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, String rgCmd)
    Get the region at the player's location, if possible.
    protected static com.sk89q.worldedit.regions.Region
    checkSelection(com.sk89q.worldedit.extension.platform.Actor actor)
    Get a WorldEdit selection for an actor, or emit an exception if there is none available.
    protected static boolean
    checkSpawnOverlap(com.sk89q.worldedit.extension.platform.Actor sender, com.sk89q.worldedit.world.World world, ProtectedRegion region)
    Inform a user if the region overlaps spawn protection.
    protected static com.sk89q.worldedit.world.World
    checkWorld(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender, char flag)
    Gets the world from the given flag, or falling back to the the current player if the sender is a player, otherwise reporting an error.
    protected static com.sk89q.worldedit.world.World
    checkWorld(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender, char flag, boolean allowWorldEditOverride)
     
    void
    claim(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Claiming command for users.
    void
    define(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Defines a new region.
    void
    flag(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Set a flag.
    void
    flagHelper(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
     
    protected static RegionPermissionModel
    getPermissionModel(com.sk89q.worldedit.extension.platform.Actor sender)
    Get the permission model to lookup permissions.
    void
    info(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Get information about a region.
    protected static void
    informNewUser(com.sk89q.worldedit.extension.platform.Actor sender, RegionManager manager, ProtectedRegion region)
    Inform a new user about automatic protection.
    void
    list(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    List regions.
    void
    load(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Reload the region database.
    void
    migrateDB(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Migrate the region database.
    void
    migrateHeights(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Migrate regions that went from 0-255 to new world heights.
    void
    migrateUuid(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Migrate the region databases to use UUIDs rather than name.
    void
    redefine(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Re-defines a region with a new selection.
    void
    remove(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Remove a region.
    void
    save(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Re-save the region database.
    void
    select(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Get a WorldEdit selection from a region.
    protected static <V> V
    setFlag(ProtectedRegion region, Flag<V> flag, com.sk89q.worldedit.extension.platform.Actor sender, String value)
    Utility method to set a flag.
    void
    setParent(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Set the parent of a region.
    protected static void
    setPlayerSelection(com.sk89q.worldedit.extension.platform.Actor actor, ProtectedRegion region, com.sk89q.worldedit.world.World world)
    Set an actor's selection to a given region.
    void
    setPriority(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Set the priority of a region.
    void
    teleport(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
    Teleport to a region
    void
    toggleBypass(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)
     
    protected static void
    warnAboutDimensions(com.sk89q.worldedit.extension.platform.Actor sender, ProtectedRegion region)
    Warn the sender if the dimensions of the given region are worrying.
    protected static void
    warnAboutSaveFailures(com.sk89q.worldedit.extension.platform.Actor sender)
    Warn the region saving is failing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RegionCommands

      public RegionCommands(WorldGuard worldGuard)
  • Method Details

    • define

      public void define(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Defines a new region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • redefine

      public void redefine(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Re-defines a region with a new selection.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • claim

      public void claim(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Claiming command for users.

      This command is a joke and it needs to be rewritten. It was contributed code :(

      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • select

      public void select(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Get a WorldEdit selection from a region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • info

      public void info(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Get information about a region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • list

      public void list(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      List regions.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • flag

      public void flag(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Set a flag.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • flagHelper

      public void flagHelper(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Throws:
      com.sk89q.minecraft.util.commands.CommandException
    • setPriority

      public void setPriority(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Set the priority of a region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • setParent

      public void setParent(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Set the parent of a region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • remove

      public void remove(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Remove a region.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • load

      public void load(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Reload the region database.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • save

      public void save(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Re-save the region database.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • migrateDB

      public void migrateDB(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Migrate the region database.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • migrateUuid

      public void migrateUuid(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Migrate the region databases to use UUIDs rather than name.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • migrateHeights

      public void migrateHeights(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Migrate regions that went from 0-255 to new world heights.
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • teleport

      public void teleport(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Teleport to a region
      Parameters:
      args - the arguments
      sender - the sender
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - any error
    • toggleBypass

      public void toggleBypass(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender) throws com.sk89q.minecraft.util.commands.CommandException
      Throws:
      com.sk89q.minecraft.util.commands.CommandException
    • getPermissionModel

      protected static RegionPermissionModel getPermissionModel(com.sk89q.worldedit.extension.platform.Actor sender)
      Get the permission model to lookup permissions.
      Parameters:
      sender - the sender
      Returns:
      the permission model
    • checkWorld

      protected static com.sk89q.worldedit.world.World checkWorld(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender, char flag) throws com.sk89q.minecraft.util.commands.CommandException
      Gets the world from the given flag, or falling back to the the current player if the sender is a player, otherwise reporting an error.
      Parameters:
      args - the arguments
      sender - the sender
      flag - the flag (such as 'w')
      Returns:
      a world
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - on error
    • checkWorld

      protected static com.sk89q.worldedit.world.World checkWorld(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender, char flag, boolean allowWorldEditOverride) throws com.sk89q.minecraft.util.commands.CommandException
      Throws:
      com.sk89q.minecraft.util.commands.CommandException
    • checkRegionId

      protected static String checkRegionId(String id, boolean allowGlobal) throws com.sk89q.minecraft.util.commands.CommandException
      Validate a region ID.
      Parameters:
      id - the id
      allowGlobal - whether __global__ is allowed
      Returns:
      the id given
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown on an error
    • checkExistingRegion

      protected static ProtectedRegion checkExistingRegion(RegionManager regionManager, String id, boolean allowGlobal) throws com.sk89q.minecraft.util.commands.CommandException
      Get a protected region by a given name, otherwise throw a CommandException.

      This also validates the region ID.

      Parameters:
      regionManager - the region manager
      id - the name to search
      allowGlobal - true to allow selecting __global__
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown if no region is found by the given name
    • checkRegionStandingIn

      protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, String rgCmd) throws com.sk89q.minecraft.util.commands.CommandException
      Get the region at the player's location, if possible.

      If the player is standing in several regions, an error will be raised and a list of regions will be provided.

      Parameters:
      regionManager - the region manager
      player - the player
      Returns:
      a region
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown if no region was found
    • checkRegionStandingIn

      protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal, String rgCmd) throws com.sk89q.minecraft.util.commands.CommandException
      Get the region at the player's location, if possible.

      If the player is standing in several regions, an error will be raised and a list of regions will be provided.

      If the player is not standing in any regions, the global region will returned if allowGlobal is true and it exists.

      Parameters:
      regionManager - the region manager
      player - the player
      allowGlobal - whether to search for a global region if no others are found
      Returns:
      a region
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown if no region was found
    • checkSelection

      protected static com.sk89q.worldedit.regions.Region checkSelection(com.sk89q.worldedit.extension.platform.Actor actor) throws com.sk89q.minecraft.util.commands.CommandException
      Get a WorldEdit selection for an actor, or emit an exception if there is none available.
      Parameters:
      actor - the actor
      Returns:
      the selection
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown on an error
    • checkRegionDoesNotExist

      protected static void checkRegionDoesNotExist(RegionManager manager, String id, boolean mayRedefine) throws com.sk89q.minecraft.util.commands.CommandException
      Check that a region with the given ID does not already exist.
      Parameters:
      manager - the manager
      id - the ID
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown if the ID already exists
    • checkRegionManager

      protected static RegionManager checkRegionManager(com.sk89q.worldedit.world.World world) throws com.sk89q.minecraft.util.commands.CommandException
      Check that the given region manager is not null.
      Parameters:
      world - the world
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown if the manager is null
    • checkRegionFromSelection

      protected static ProtectedRegion checkRegionFromSelection(com.sk89q.worldedit.extension.platform.Actor actor, String id) throws com.sk89q.minecraft.util.commands.CommandException
      Create a ProtectedRegion from the actor's selection.
      Parameters:
      actor - the actor
      id - the ID of the new region
      Returns:
      a new region
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown on an error
    • warnAboutSaveFailures

      protected static void warnAboutSaveFailures(com.sk89q.worldedit.extension.platform.Actor sender)
      Warn the region saving is failing.
      Parameters:
      sender - the sender to send the message to
    • warnAboutDimensions

      protected static void warnAboutDimensions(com.sk89q.worldedit.extension.platform.Actor sender, ProtectedRegion region)
      Warn the sender if the dimensions of the given region are worrying.
      Parameters:
      sender - the sender to send the message to
      region - the region
    • informNewUser

      protected static void informNewUser(com.sk89q.worldedit.extension.platform.Actor sender, RegionManager manager, ProtectedRegion region)
      Inform a new user about automatic protection.
      Parameters:
      sender - the sender to send the message to
      manager - the region manager
      region - the region
    • checkSpawnOverlap

      protected static boolean checkSpawnOverlap(com.sk89q.worldedit.extension.platform.Actor sender, com.sk89q.worldedit.world.World world, ProtectedRegion region)
      Inform a user if the region overlaps spawn protection.
      Parameters:
      sender - the sender to send the message to
      world - the world the region is in
      region - the region
    • setPlayerSelection

      protected static void setPlayerSelection(com.sk89q.worldedit.extension.platform.Actor actor, ProtectedRegion region, com.sk89q.worldedit.world.World world) throws com.sk89q.minecraft.util.commands.CommandException
      Set an actor's selection to a given region.
      Parameters:
      actor - the actor
      region - the region
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - thrown on a command error
    • setFlag

      protected static <V> V setFlag(ProtectedRegion region, Flag<V> flag, com.sk89q.worldedit.extension.platform.Actor sender, String value) throws InvalidFlagFormat
      Utility method to set a flag.
      Parameters:
      region - the region
      flag - the flag
      sender - the sender
      value - the value
      Throws:
      InvalidFlagFormat - thrown if the value is invalid