Docs » API reference » Region

Region

A named box of the world that a plugin watches. The plugin hears when players enter and leave it.

Regions are how a plugin builds spawn protection, claims, arenas or shops. It listens for players entering and leaving, and stops block breaking and placing inside. A region belongs to the plugin that made it and is saved with that plugin's data. It costs one check each time a player's feet move to another block.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from world.region(id, from, to).

Methods

MethodDescription
fn id(&self) -> Result<String>String id()Its name, unique to the plugin.
fn from(&self) -> Result<BlockPos>BlockPos from()One corner.
fn to(&self) -> Result<BlockPos>BlockPos to()The other corner.
fn contains(&self, place: Place) -> Result<bool>boolean contains(Place place)Whether a place is inside.
fn players(&self) -> Result<Vec<Player>>List<Player> players()Who is inside now.
fn resize(&self, from: BlockPos, to: BlockPos) -> Result<()>void resize(BlockPos from, BlockPos to)Moves its corners.
fn remove(&self) -> Result<()>void remove()Forgets it.

Events

Related events: PlayerEnteredRegion, PlayerLeftRegion.