WorldEvent base class.
WorldEvent Base Class
All world events inherit from this class:Returns the world involved in the event
World Lifecycle Events
WorldInitEvent
WorldInitEvent
Cancellable: NoCalled when a world is initialized (first loaded).
WorldLoadEvent
WorldLoadEvent
Cancellable: NoCalled when a world is loaded.
WorldUnloadEvent
WorldUnloadEvent
Cancellable: YesCalled when a world is about to be unloaded.
WorldSaveEvent
WorldSaveEvent
Cancellable: NoCalled when a world is saved to disk.
Chunk Events
Chunk events extendChunkEvent which extends WorldEvent:
Returns the chunk X coordinate
Returns the chunk Z coordinate
Returns the chunk object
ChunkLoadEvent
ChunkLoadEvent
Cancellable: NoCalled when a chunk is loaded or newly generated.Methods:
isNewChunk()- Returns true if chunk was newly generated, false if loaded from storage
ChunkUnloadEvent
ChunkUnloadEvent
Cancellable: YesCalled when a chunk is about to be unloaded.
ChunkPopulateEvent
ChunkPopulateEvent
Cancellable: NoCalled when a chunk is populated with decorations (trees, ores, etc.).
World Property Events
SpawnChangeEvent
SpawnChangeEvent
Cancellable: NoCalled when a world’s spawn position changes.Methods:
getPreviousSpawn()- Returns the previous spawn position
WorldDifficultyChangeEvent
WorldDifficultyChangeEvent
Cancellable: NoCalled when a world’s difficulty changes.Methods:
getOldDifficulty()- Returns the previous difficultygetNewDifficulty()- Returns the new difficulty
WorldDisplayNameChangeEvent
WorldDisplayNameChangeEvent
Cancellable: NoCalled when a world’s display name changes.Methods:
getOldName()- Returns the previous display namegetNewName()- Returns the new display name
Audio-Visual Events
WorldSoundEvent
WorldSoundEvent
Cancellable: YesCalled when a sound is played in a world.Methods:
getSound()- Returns the Sound objectgetPosition()- Returns the Vector3 position where sound playsgetRecipients()- Returns array of Players who will hear the soundsetRecipients(array $recipients)- Sets who will hear the sound
WorldParticleEvent
WorldParticleEvent
Cancellable: YesCalled when particles are spawned in a world.Methods:
getParticle()- Returns the Particle objectgetPosition()- Returns the Vector3 position where particles spawngetRecipients()- Returns array of Players who will see particlessetRecipients(array $recipients)- Sets who will see particles
Usage Examples
Keeping Spawn Chunks Loaded
Custom Chunk Population
World Time Control
Sound Filtering
Complete World Event List
All world-related events:ChunkEvent- Base class for chunk eventsChunkLoadEvent- Chunk is loaded or generatedChunkPopulateEvent- Chunk is populated with decorationsChunkUnloadEvent- Chunk is being unloadedSpawnChangeEvent- World spawn position changesWorldDifficultyChangeEvent- World difficulty changesWorldDisplayNameChangeEvent- World display name changesWorldEvent- Base class for world eventsWorldInitEvent- World is initializedWorldLoadEvent- World is loadedWorldParticleEvent- Particles are spawnedWorldSaveEvent- World is savedWorldSoundEvent- Sound is playedWorldUnloadEvent- World is being unloaded