walkmc.event.RegionEvent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resources-addon Show documentation
Show all versions of resources-addon Show documentation
A resources API/Addon with compatibility with others plugins
The newest version!
package walkmc.event
import com.sk89q.worldguard.protection.regions.*
import org.bukkit.*
import org.bukkit.entity.*
import walkmc.*
/**
* Represents a region movement classifier.
*/
enum class Movement {
MOVE,
TELEPORT,
CONNECT,
DISCONNECT,
SPAWN;
val isByMovement get() = this == MOVE || this == TELEPORT
val isByConnection get() = this == CONNECT || this == DISCONNECT
}
/**
* Base class for any region-related event.
*/
abstract class RegionEvent(val region: ProtectedRegion, val player: Player) : CancellableEvent() {
val id: String = region.id
val world: World = player.world
val location: Location = player.location
}
/**
* Represents a region enter event. This will be called when a player enters in a region.
*/
open class RegionEnterEvent(
player: Player,
region: ProtectedRegion,
val movement: Movement,
) : RegionEvent(region, player)
/**
* Represents a region leave event. This will be called when a player leaves from a region.
*/
open class RegionLeaveEvent(
player: Player,
region: ProtectedRegion,
val movement: Movement,
) : RegionEvent(region, player)