diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-12 16:03:43 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-12 16:03:43 +0100 |
commit | eb219efe1fd54edf066350878ecf64eccc200dc5 (patch) | |
tree | 76d55123990c3103078e271dd529f8e375a6edaa /src/main/kotlin | |
parent | 3d3d521a6c8baaa5153fefa7cfed0cdd69c3fc01 (diff) | |
download | Firmament-eb219efe1fd54edf066350878ecf64eccc200dc5.tar.gz Firmament-eb219efe1fd54edf066350878ecf64eccc200dc5.tar.bz2 Firmament-eb219efe1fd54edf066350878ecf64eccc200dc5.zip |
feat: Add /firm waypoints export command
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/features/world/Waypoints.kt | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/kotlin/features/world/Waypoints.kt b/src/main/kotlin/features/world/Waypoints.kt index 16db059..3ebfe70 100644 --- a/src/main/kotlin/features/world/Waypoints.kt +++ b/src/main/kotlin/features/world/Waypoints.kt @@ -4,6 +4,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType import me.shedaniel.math.Color import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource import kotlinx.serialization.Serializable +import kotlinx.serialization.encodeToString import kotlin.collections.component1 import kotlin.collections.component2 import kotlin.collections.set @@ -32,6 +33,7 @@ import moe.nea.firmament.util.ClipboardUtils import moe.nea.firmament.util.MC import moe.nea.firmament.util.TimeMark import moe.nea.firmament.util.render.RenderInWorldContext +import moe.nea.firmament.util.tr object Waypoints : FirmamentFeature { override val identifier: String @@ -198,11 +200,22 @@ object Waypoints : FirmamentFeature { } } } + thenLiteral("export") { + thenExecute { + val data = Firmament.tightJson.encodeToString<List<ColeWeightWaypoint>>(waypoints.map { + ColeWeightWaypoint(it.x, + it.y, + it.z) + }) + ClipboardUtils.setTextContent(data) + source.sendFeedback(tr("firmament.command.waypoint.export", "Copied ${waypoints.size} waypoints to clipboard")) + } + } thenLiteral("import") { thenExecute { val contents = ClipboardUtils.getTextContents() val data = try { - Firmament.json.decodeFromString<List<ColeWeightWaypoint>>(contents) + Firmament.tightJson.decodeFromString<List<ColeWeightWaypoint>>(contents) } catch (ex: Exception) { Firmament.logger.error("Could not load waypoints from clipboard", ex) source.sendError(Text.translatable("firmament.command.waypoint.import.error")) |