Class PreSpawnSpawnerAdapter
This provider automatically detects the current Minecraft version and server implementation to return the appropriate spawner event listener. Different server forks have implemented spawner pre-spawn events at different times and with different APIs, requiring version-specific adapters to provide consistent functionality.
The adapter system handles the complex landscape of spawner events across different server implementations:
- TacoSpigot 1.8.8: Introduced
SpawnerPreSpawnEventearly - Paper 1.9-1.12: Uses
SpawnerSpawnEventfor pre-spawn detection - PaperSpigot 1.13+: Standardized on
PreSpawnerSpawnEvent
Each adapter implements the same Listener interface but handles
different underlying events, providing a unified PreSpawnSpawnerEvent
abstraction for plugin developers.
Example usage:
// Register the appropriate spawner adapter for the current server version
Listener spawnerAdapter = PreSpawnSpawnerAdapter.getSpawnerAdapter();
Bukkit.getPluginManager().registerEvents(spawnerAdapter, plugin);
// The adapter will automatically convert server-specific events to unified events
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ListenerRetrieves the appropriate spawner event adapter for the current server version and implementation.
-
Constructor Details
-
PreSpawnSpawnerAdapter
public PreSpawnSpawnerAdapter()
-
-
Method Details
-
getSpawnerAdapter
Retrieves the appropriate spawner event adapter for the current server version and implementation.This method analyzes the current Minecraft version to determine which server implementation is likely being used and returns the corresponding event adapter. The detection logic accounts for the historical evolution of spawner events across different server forks.
Version detection logic:
- Minecraft 1.8.8: Assumes TacoSpigot fork, which introduced early spawner events
- Minecraft 1.9-1.12.2: Assumes Paper fork with
SpawnerSpawnEvent - Minecraft 1.13+: Assumes modern PaperSpigot with
PreSpawnerSpawnEvent
Each returned adapter will listen for the appropriate server-specific spawner events and convert them into the unified
PreSpawnSpawnerEventthat can be handled consistently across all versions.- Returns:
- a
Listenerthat adapts server-specific spawner events to the unified API
-