@@ -67,10 +67,27 @@ class SpawningFeature(context: FeatureContext) : Feature(context) {
6767 }
6868
6969 override fun enable () {
70+ // -- Spread Spawn logic --
71+ val spreadConfig by config(
72+ " spread_config" , plugin.dataPath,
73+ SpreadEntityTypesConfig (),
74+ mergeUpdates = false ,
75+ formats = ConfigFormats (
76+ listOf (
77+ Format (
78+ " yml" , Yaml (
79+ serializersModule = gearyPaper.worldManager.global.getAddon(SerializableComponents ).serializers.module,
80+ configuration = YamlConfiguration (strictMode = false )
81+ )
82+ )
83+ )
84+ )
85+ )
86+ val mainWorld = Bukkit .getWorld(spreadConfig.worldName) ? : error(" World ${spreadConfig.worldName} not found, cannot initialize spread spawning" )
87+
7088 // -- Database logic --
7189 val db = plugin.sqliteDatabase(Path (" spawns.db" )) {
72- val world = Bukkit .getWorlds().firstOrNull() ? : error(" No worlds found, cannot initialize spawning database" )
73- SpawningSchema (listOf (world)).init ()
90+ SpawningSchema (listOf (mainWorld)).init ()
7491 }
7592 database = db
7693
@@ -100,24 +117,6 @@ class SpawningFeature(context: FeatureContext) : Feature(context) {
100117 spawnAttempts = config.maxSpawnAttemptsPerPlayer,
101118 mobSpawner = mobSpawner,
102119 )
103-
104- // -- Spread Spawn logic --
105- val spreadConfig by config(
106- " spread_config" , plugin.dataPath,
107- SpreadEntityTypesConfig (),
108- mergeUpdates = false ,
109- formats = ConfigFormats (
110- listOf (
111- Format (
112- " yml" , Yaml (
113- serializersModule = gearyPaper.worldManager.global.getAddon(SerializableComponents ).serializers.module,
114- configuration = YamlConfiguration (strictMode = false )
115- )
116- )
117- )
118- )
119- )
120- val mainWorld = Bukkit .getWorld(spreadConfig.worldName) ? : error(" World ${spreadConfig.worldName} not found, cannot initialize spread spawning" )
121120 val posChooser = InChunkLocationChooser (mobSpawner, mainWorld)
122121 val dao = SpawnLocationsDAO ()
123122 val chunkChooser = SpreadChunkChooser (logger, mainWorld, db, dao)
@@ -133,7 +132,7 @@ class SpawningFeature(context: FeatureContext) : Feature(context) {
133132 )
134133
135134 listeners(
136- ListSpawnListener (spreadSpawner, db, dao, plugin),
135+ ListSpawnListener (spreadSpawner, db, dao, plugin, mainWorld ),
137136 SpreadEntityDeathListener (
138137 spreadSpawner, db, plugin, mainWorld
139138 )
0 commit comments