VitalMinigameInstance

open class VitalMinigameInstance(var id: UUID = UUID.randomUUID(), val plugin: SpigotPlugin, val world: World) : VitalEntity<UUID> , Listener

Defines a single game instance that can be hosted on the server. Each instance can have n-amount of states, but only one active state at a given time. Every state may have n-amount of event handlers, which will only fire when their state is currently active on an instance. Every instance will be bound to its own world for proper instance capsulation.

An instance in itself is also a listener and can receive game events independently on which state is currently active.

Switching to a state will register all defined event handlers for the new state, and unregister all from the old one.

Constructors

Link copied to clipboard
constructor(id: UUID = UUID.randomUUID(), plugin: SpigotPlugin, world: World)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var id: UUID
Link copied to clipboard
Link copied to clipboard

Holds the currently active state of this instance. All event handlers defined on this state are active while this state is active. Once deactivated by switching to another state, all event handlers will be unregistered.

Link copied to clipboard
val world: World

Functions

Link copied to clipboard

Checks if the given state is active by its class.

Link copied to clipboard
open fun onRegister()

Lifecycle function; called when this instance is registered on the global VitalMinigameInstanceService bean. Can be used to perform custom logic during instance registration.

Link copied to clipboard
open fun onUnregister()

Lifecycle function; called when this instance is unregistered on the global VitalMinigameInstanceService bean. Can be used to perform custom logic during instance unregistration.

Link copied to clipboard
fun register()

Registers all declared event handlers for this state and then calls onRegister.

Link copied to clipboard

Sets the state of this instance to the given state.

Link copied to clipboard

Unregisters all registered event handlers from this state and then calls onUnregister.