mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2025-02-13 00:41:24 +01:00
Possibly fix minions sometimes being broken
This commit is contained in:
parent
c2cab8ee58
commit
74f9cd5965
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com.artillexstudios.axminions'
|
||||
version = '1.0.4'
|
||||
version = '1.0.5'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -106,15 +106,6 @@ class AxMinionsPlugin : AxPlugin() {
|
||||
handler.registerBrigadier()
|
||||
}
|
||||
|
||||
// Retroactively load minions for the already loaded worlds
|
||||
dataQueue.submit {
|
||||
Bukkit.getWorlds().fastFor { world ->
|
||||
MinionTypes.getMinionTypes().fastFor { _, v ->
|
||||
dataHandler.loadMinionsForWorld(v, world)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().also {
|
||||
it.registerEvents(MinionPlaceListener(), this)
|
||||
it.registerEvents(LinkingListener(), this)
|
||||
@ -125,6 +116,17 @@ class AxMinionsPlugin : AxPlugin() {
|
||||
it.registerEvents(MinionDropListener(), this)
|
||||
}
|
||||
|
||||
// Retroactively load minions for the already loaded worlds
|
||||
Bukkit.getWorlds().fastFor { world ->
|
||||
MinionTypes.getMinionTypes().fastFor { _, v ->
|
||||
dataHandler.loadMinionsForWorld(v, world)
|
||||
}
|
||||
|
||||
world.loadedChunks.fastFor {
|
||||
Minions.startTicking(it)
|
||||
}
|
||||
}
|
||||
|
||||
MinionTicker.startTicking()
|
||||
|
||||
Scheduler.get().runTimer({
|
||||
|
@ -10,11 +10,11 @@ class ChunkListener : Listener {
|
||||
|
||||
@EventHandler
|
||||
fun onChunkLoadEvent(event: ChunkLoadEvent) {
|
||||
Minions.addTicking(event.chunk)
|
||||
Minions.startTicking(event.chunk)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onChunkUnloadEvent(event: ChunkUnloadEvent) {
|
||||
Minions.removeTicking(event.chunk)
|
||||
Minions.stopTicking(event.chunk)
|
||||
}
|
||||
}
|
@ -86,9 +86,9 @@ class MinionPlaceListener : Listener {
|
||||
locationId,
|
||||
0
|
||||
)
|
||||
Minions.addTicking(chunk)
|
||||
Minions.startTicking(chunk)
|
||||
|
||||
Scheduler.get().run { task ->
|
||||
Scheduler.get().run { _ ->
|
||||
meta = item.itemMeta!!
|
||||
meta.persistentDataContainer.remove(Keys.PLACED)
|
||||
item.itemMeta = meta
|
||||
|
@ -1,14 +1,31 @@
|
||||
package com.artillexstudios.axminions.listeners
|
||||
|
||||
import com.artillexstudios.axminions.api.minions.miniontype.MinionTypes
|
||||
import com.artillexstudios.axminions.api.utils.fastFor
|
||||
import com.artillexstudios.axminions.minions.Minions
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.world.WorldLoadEvent
|
||||
import org.bukkit.event.world.WorldUnloadEvent
|
||||
|
||||
class WorldListener : Listener {
|
||||
|
||||
@EventHandler
|
||||
fun onWorldLoadEvent(event: WorldLoadEvent) {
|
||||
MinionTypes.loadForWorld(event.world)
|
||||
|
||||
event.world.loadedChunks.fastFor {
|
||||
Minions.startTicking(it)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onWorldUnload(event: WorldUnloadEvent) {
|
||||
val worldUUID = event.world.uid
|
||||
Minions.getMinions().fastFor {
|
||||
if (it.getLocation().world?.uid == worldUUID) {
|
||||
Minions.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ object Minions {
|
||||
internal val lock = ReentrantReadWriteLock()
|
||||
internal val minions = arrayListOf<ChunkPos>()
|
||||
|
||||
fun addTicking(chunk: Chunk) {
|
||||
fun startTicking(chunk: Chunk) {
|
||||
val chunkX = chunk.x
|
||||
val chunkZ = chunk.z
|
||||
val world = chunk.world
|
||||
@ -45,7 +45,7 @@ object Minions {
|
||||
return false
|
||||
}
|
||||
|
||||
fun removeTicking(chunk: Chunk) {
|
||||
fun stopTicking(chunk: Chunk) {
|
||||
val chunkX = chunk.x
|
||||
val chunkZ = chunk.z
|
||||
val world = chunk.world
|
||||
|
Loading…
Reference in New Issue
Block a user