HTTPS
https://git.nageyqma.icu/nageyqma/odin_next.git
SSH
git@git.nageyqma.icu:nageyqma/odin_next.git
HTTPS 链接可直接 git clone;推送代码请使用 SSH。
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
package com.odtheking.odin.commands
import com.github.stivais.commodore.Commodore
import com.github.stivais.commodore.utils.GreedyString
import com.odtheking.odin.OdinMod.mc
import com.odtheking.odin.OdinMod.scope
import com.odtheking.odin.clickgui.settings.impl.label
import com.odtheking.odin.config.DungeonWaypointConfig
import com.odtheking.odin.features.impl.dungeon.dungeonwaypoints.*
import com.odtheking.odin.utils.Color
import com.odtheking.odin.utils.modMessage
import com.odtheking.odin.utils.network.WebUtils
import com.odtheking.odin.utils.setClipboardContent
import kotlinx.coroutines.launch
val dungeonWaypointsCommand = Commodore("dwp", "dungeonwaypoints") {
runs {
mc.schedule { mc.setScreenAndShow(WaypointPackSelectorScreen(mc.gui.screen())) }
}
literal("fill").runs {
DungeonWaypoints.filled = !DungeonWaypoints.filled
modMessage("Fill status changed to: ${DungeonWaypoints.filled}")
}
literal("size").runs { sizeX: Double, sizeY: Double, sizeZ: Double ->
fun valid(size: Double) = size in 0.1..1.0
if (!valid(sizeX) || !valid(sizeY) || !valid(sizeZ)) return@runs modMessage("§cSize must be between 0.1 and 1.0!")
DungeonWaypoints.sizeX = sizeX
DungeonWaypoints.sizeY = sizeY
DungeonWaypoints.sizeZ = sizeZ
modMessage("Size changed to: ${sizeX}, ${sizeY}, $sizeZ")
}
literal("resetsecrets").runs {
SecretWaypoints.resetSecrets()
modMessage("§aSecrets have been reset!")
}
literal("type").runs { type: String ->
DungeonWaypoints.WaypointType.getByName(type)?.let {
DungeonWaypoints.waypointType = it
modMessage("Waypoint type changed to: ${it.label}")
} ?: modMessage("§cInvalid waypoint type!")
}
literal("useblocksize").runs {
DungeonWaypoints.useBlockSize = !DungeonWaypoints.useBlockSize
modMessage("Use block size status changed to: ${DungeonWaypoints.useBlockSize}")
}
literal("depth").runs {
DungeonWaypoints.depthCheck = !DungeonWaypoints.depthCheck
modMessage("Next waypoint will be added with depth check: ${DungeonWaypoints.depthCheck}")
}
literal("color").runs { hex: String ->
if (!hex.matches(Regex("[0-9A-Fa-f]{8}"))) return@runs modMessage("Color hex not properly formatted! Use format RRGGBBAA")
DungeonWaypoints.color = Color(hex)
modMessage("Color changed to: $hex")
}
literal("export").runs {
scope.launch {
val encoded = DungeonWaypointConfig.encodeWaypoints(DungeonWaypoints.exportEditableWaypoints())
if (encoded != null) {
setClipboardContent(encoded)
modMessage("Wrote waypoint config to clipboard.")
} else modMessage("Failed to write waypoint config to clipboard.")
}
}
literal("import").runs { importString: GreedyString? ->
scope.launch {
val input = (importString?.let {
if (importString.string.startsWith("https://")) WebUtils.fetchString(importString.string).getOrNull()
else importString.string
} ?: mc.keyboardHandler.clipboard)
val waypoints = DungeonWaypointConfig.decodeWaypoints(input.trim().trim { it == '\n' }) ?: return@launch modMessage("§cFailed to decode waypoints from clipboard. §fIs the data valid?")
DungeonWaypoints.importEditableWaypoints(waypoints)
modMessage("Imported waypoints from clipboard!${if (!DungeonWaypoints.enabled) "§7(Make sure to enable the DungeonWayPoints module)" else ""}")
}
}
}