Class RegionCommands
java.lang.Object
com.sk89q.worldguard.commands.region.RegionCommands
Implements the /region commands for WorldGuard.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ProtectedRegioncheckExistingRegion(RegionManager regionManager, String id, boolean allowGlobal)Get a protected region by a given name, otherwise throw aCommandException.protected static voidcheckRegionDoesNotExist(RegionManager manager, String id, boolean mayRedefine)Check that a region with the given ID does not already exist.protected static ProtectedRegioncheckRegionFromSelection(com.sk89q.worldedit.extension.platform.Actor actor, String id)Create aProtectedRegionfrom the actor's selection.protected static StringcheckRegionId(String id, boolean allowGlobal)Validate a region ID.protected static RegionManagercheckRegionManager(com.sk89q.worldedit.world.World world)Check that the given region manager is not null.protected static ProtectedRegioncheckRegionStandingIn(RegionManager regionManager, LocalPlayer player, boolean allowGlobal, String rgCmd)Get the region at the player's location, if possible.protected static ProtectedRegioncheckRegionStandingIn(RegionManager regionManager, LocalPlayer player, String rgCmd)Get the region at the player's location, if possible.protected static com.sk89q.worldedit.regions.RegioncheckSelection(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 booleancheckSpawnOverlap(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.WorldcheckWorld(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.WorldcheckWorld(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender, char flag, boolean allowWorldEditOverride)voidclaim(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Claiming command for users.voiddefine(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Defines a new region.voidflag(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Set a flag.voidflagHelper(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)protected static RegionPermissionModelgetPermissionModel(com.sk89q.worldedit.extension.platform.Actor sender)Get the permission model to lookup permissions.voidinfo(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Get information about a region.protected static voidinformNewUser(com.sk89q.worldedit.extension.platform.Actor sender, RegionManager manager, ProtectedRegion region)Inform a new user about automatic protection.voidlist(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)List regions.voidload(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Reload the region database.voidmigrateDB(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Migrate the region database.voidmigrateUuid(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Migrate the region databases to use UUIDs rather than name.voidredefine(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Re-defines a region with a new selection.voidremove(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Remove a region.voidsave(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Re-save the region database.voidselect(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Get a WorldEdit selection from a region.protected static <V> VsetFlag(ProtectedRegion region, Flag<V> flag, com.sk89q.worldedit.extension.platform.Actor sender, String value)Utility method to set a flag.voidsetParent(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Set the parent of a region.protected static voidsetPlayerSelection(com.sk89q.worldedit.extension.platform.Actor actor, ProtectedRegion region, com.sk89q.worldedit.world.World world)Set an actor's selection to a given region.voidsetPriority(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Set the priority of a region.voidteleport(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)Teleport to a regionvoidtoggleBypass(com.sk89q.minecraft.util.commands.CommandContext args, com.sk89q.worldedit.extension.platform.Actor sender)protected static voidwarnAboutDimensions(com.sk89q.worldedit.extension.platform.Actor sender, ProtectedRegion region)Warn the sender if the dimensions of the given region are worrying.protected static voidwarnAboutSaveFailures(com.sk89q.worldedit.extension.platform.Actor sender)Warn the region saving is failing.
-
Constructor Details
-
RegionCommands
-
-
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.CommandExceptionDefines a new region.- Parameters:
args- the argumentssender- 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.CommandExceptionRe-defines a region with a new selection.- Parameters:
args- the argumentssender- 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.CommandExceptionClaiming command for users.This command is a joke and it needs to be rewritten. It was contributed code :(
- Parameters:
args- the argumentssender- 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.CommandExceptionGet a WorldEdit selection from a region.- Parameters:
args- the argumentssender- 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.CommandExceptionGet information about a region.- Parameters:
args- the argumentssender- 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.CommandExceptionList regions.- Parameters:
args- the argumentssender- 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.CommandExceptionSet a flag.- Parameters:
args- the argumentssender- 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.CommandExceptionSet the priority of a region.- Parameters:
args- the argumentssender- 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.CommandExceptionSet the parent of a region.- Parameters:
args- the argumentssender- 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.CommandExceptionRemove a region.- Parameters:
args- the argumentssender- 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.CommandExceptionReload the region database.- Parameters:
args- the argumentssender- 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.CommandExceptionRe-save the region database.- Parameters:
args- the argumentssender- 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.CommandExceptionMigrate the region database.- Parameters:
args- the argumentssender- 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.CommandExceptionMigrate the region databases to use UUIDs rather than name.- Parameters:
args- the argumentssender- 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.CommandExceptionTeleport to a region- Parameters:
args- the argumentssender- 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.CommandExceptionGets 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 argumentssender- the senderflag- 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.CommandExceptionValidate a region ID.- Parameters:
id- the idallowGlobal- 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.CommandExceptionGet a protected region by a given name, otherwise throw aCommandException.This also validates the region ID.
- Parameters:
regionManager- the region managerid- the name to searchallowGlobal- 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.CommandExceptionGet 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 managerplayer- 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.CommandExceptionGet 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 managerplayer- the playerallowGlobal- 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.CommandExceptionGet 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.CommandExceptionCheck that a region with the given ID does not already exist.- Parameters:
manager- the managerid- 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.CommandExceptionCheck 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.CommandExceptionCreate aProtectedRegionfrom the actor's selection.- Parameters:
actor- the actorid- 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 toregion- 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 tomanager- the region managerregion- 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 toworld- the world the region is inregion- 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.CommandExceptionSet an actor's selection to a given region.- Parameters:
actor- the actorregion- 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 InvalidFlagFormatUtility method to set a flag.- Parameters:
region- the regionflag- the flagsender- the sendervalue- the value- Throws:
InvalidFlagFormat- thrown if the value is invalid
-