All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.event.RegionEvent.kt Maven / Gradle / Ivy

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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy