-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dungeon waypoints based on rotation clay position, migration might wo…
…rk, might not
- Loading branch information
1 parent
1eeaa99
commit 5ecde7a
Showing
6 changed files
with
105 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
odinmain/src/main/kotlin/me/odinmain/config/DungeonWaypointConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
odinmain/src/main/kotlin/me/odinmain/config/DungeonWaypointConfigCLAY.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package me.odinmain.config | ||
|
||
import com.google.gson.* | ||
import com.google.gson.reflect.TypeToken | ||
import kotlinx.coroutines.* | ||
import me.odinmain.OdinMain.mc | ||
import me.odinmain.features.impl.dungeon.DungeonWaypoints.DungeonWaypoint | ||
import me.odinmain.utils.render.Color | ||
import java.io.File | ||
import java.io.IOException | ||
|
||
object DungeonWaypointConfigCLAY { | ||
private val gson = GsonBuilder().registerTypeAdapter(Color::class.java, Color.ColorSerializer()).setPrettyPrinting().create() | ||
|
||
var waypoints: MutableMap<String, MutableList<DungeonWaypoint>> = mutableMapOf() | ||
|
||
private val configFile = File(mc.mcDataDir, "config/odin/dungeon-waypoint-config-CLAY.json").apply { | ||
try { | ||
createNewFile() | ||
} catch (e: Exception) { | ||
println("Error initializing module config") | ||
} | ||
} | ||
|
||
fun loadConfig() { | ||
try { | ||
with(configFile.bufferedReader().use { it.readText() }) { | ||
if (this.isEmpty()) return | ||
|
||
waypoints = gson.fromJson( | ||
this, | ||
object : TypeToken<MutableMap<String, MutableList<DungeonWaypoint>>>() {}.type | ||
) | ||
} | ||
} catch (e: JsonSyntaxException) { | ||
println("Error parsing configs.") | ||
println(e.message) | ||
e.printStackTrace() | ||
} catch (e: JsonIOException) { | ||
println("Error reading configs.") | ||
} | ||
} | ||
|
||
@OptIn(DelicateCoroutinesApi::class) | ||
fun saveConfig() { | ||
GlobalScope.launch(Dispatchers.IO) { | ||
try { | ||
configFile.bufferedWriter().use { | ||
it.write(gson.toJson(waypoints)) | ||
} | ||
} catch (e: IOException) { | ||
println("Error saving Waypoint config.") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters