Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
package org.openrs2.deob.util.map
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper
|
|
import org.openrs2.yaml.Yaml
|
|
import java.nio.file.Files
|
|
import java.nio.file.Path
|
|
import javax.inject.Inject
|
|
import javax.inject.Provider
|
|
|
|
public class NameMapProvider @Inject constructor(@Yaml private val mapper: ObjectMapper) : Provider<NameMap> {
|
|
override fun get(): NameMap {
|
|
val combinedMap = NameMap()
|
|
|
|
if (!Files.exists(PATH)) {
|
|
return combinedMap
|
|
}
|
|
|
|
for (file in Files.list(PATH).filter(::isYamlFile)) {
|
|
val map = Files.newBufferedReader(file).use { reader ->
|
|
mapper.readValue(reader, NameMap::class.java)
|
|
}
|
|
combinedMap.add(map)
|
|
}
|
|
|
|
return combinedMap
|
|
}
|
|
|
|
private fun isYamlFile(path: Path): Boolean {
|
|
return Files.isRegularFile(path) && path.fileName.toString().endsWith(YAML_SUFFIX)
|
|
}
|
|
|
|
private companion object {
|
|
private val PATH = Path.of("share/deob/map")
|
|
private const val YAML_SUFFIX = ".yaml"
|
|
}
|
|
}
|
|
|