RuneHive-Game
Loading...
Searching...
No Matches
ObjectExamines.kt
Go to the documentation of this file.
1package org.jire.runehiveps.objectexamines
2
3import com.google.gson.Gson
4import com.google.gson.GsonBuilder
5import com.runehive.Config
6import it.unimi.dsi.fastutil.ints.Int2ObjectMap
7import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
8import java.nio.file.Path
9import kotlin.io.path.bufferedReader
10
11/**
12 * @author Jire
13 */
14object ObjectExamines {
15
16 private val defaultFilePath: Path = Path.of(
17 "data",
18 "def",
19 "object_examines.json"
20 )
21
22 @JvmField
23 val map: Int2ObjectMap<String> = Int2ObjectOpenHashMap()
24
25 @JvmStatic
26 @JvmOverloads
27 fun loadObjectExamines(
28 filePath: Path = defaultFilePath,
29 gson: Gson = GsonBuilder()
30 .setPrettyPrinting()
31 .create()
32 ) {
33 val examines: Array<ObjectExamine> =
34 gson.fromJson(filePath.bufferedReader(), Array<ObjectExamine>::class.java)
35 for (examine in examines) {
36 map.put(examine.id, examine.examine.replace("%SERVER_NAME%", Config.SERVER_NAME))
37 }
38 }
39
40}