diff --git a/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt b/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt index 3ce8ee6..dd25c40 100644 --- a/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt +++ b/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt @@ -6,10 +6,10 @@ import one.oktw.galaxy.proxy.Main.Companion.main import kotlin.math.max class ResourcePackHelper { - private val appliedPacks: MutableMap> = mutableMapOf() + private val appliedPacks: MutableMap> = mutableMapOf() fun updatePlayerResourcePacks(player: Player, galaxy: String) { - val targetResourcePacks = main.config.galaxies[galaxy]?.ResourcePacks?.distinct()?.mapNotNull { main.config.resourcePacks[it] } ?: return + val targetResourcePacks = main.config.galaxies[galaxy]?.ResourcePacks?.distinct()?.mapNotNull { main.config.resourcePacks[it]?.packInfo() } ?: return val appliedResourcePacks = this.appliedPacks.getOrPut(player) { listOf() } var skipFurtherCheck = false @@ -17,15 +17,15 @@ class ResourcePackHelper { val packsToRemove = mutableListOf() for (index in 0..max(targetResourcePacks.size, appliedResourcePacks.size)) { - if (targetResourcePacks.getOrNull(index)?.hash.contentEquals(appliedResourcePacks.getOrNull(index)?.hash) && !skipFurtherCheck) continue + if (targetResourcePacks.getOrNull(index)?.id == appliedResourcePacks.getOrNull(index)?.id && !skipFurtherCheck) continue skipFurtherCheck = true - if (index < appliedResourcePacks.size) packsToRemove.add(appliedResourcePacks[index].packInfo()) - if (index < targetResourcePacks.size) packsToQueue.add(targetResourcePacks[index].packInfo()) + if (index < appliedResourcePacks.size) packsToRemove.add(appliedResourcePacks[index]) + if (index < targetResourcePacks.size) packsToQueue.add(targetResourcePacks[index]) } - main.logger.debug(appliedResourcePacks.map { it.packInfo().id }.toString()) - main.logger.debug(targetResourcePacks.map { it.packInfo().id }.toString()) + main.logger.debug(appliedResourcePacks.map { it.id }.toString()) + main.logger.debug(targetResourcePacks.map { it.id }.toString()) main.logger.info("Removing {} packs, Sending {} packs", packsToRemove.size, packsToQueue.size) packsToRemove.forEach { pack -> player.removeResourcePacks(pack) } packsToQueue.forEach { pack -> player.sendResourcePacks(pack) }