diff options
Diffstat (limited to 'src/main/kotlin/features/world/FirmWaypointManager.kt')
| -rw-r--r-- | src/main/kotlin/features/world/FirmWaypointManager.kt | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main/kotlin/features/world/FirmWaypointManager.kt b/src/main/kotlin/features/world/FirmWaypointManager.kt index d18483c..c6e2610 100644 --- a/src/main/kotlin/features/world/FirmWaypointManager.kt +++ b/src/main/kotlin/features/world/FirmWaypointManager.kt @@ -2,7 +2,7 @@ package moe.nea.firmament.features.world import com.mojang.brigadier.arguments.StringArgumentType import kotlinx.serialization.serializer -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.commands.DefaultSource import moe.nea.firmament.commands.RestArgumentType @@ -16,11 +16,11 @@ import moe.nea.firmament.util.ClipboardUtils import moe.nea.firmament.util.FirmFormatters import moe.nea.firmament.util.MC import moe.nea.firmament.util.TemplateUtil -import moe.nea.firmament.util.data.MultiFileDataHolder +import moe.nea.firmament.util.data.DataHolder import moe.nea.firmament.util.tr object FirmWaypointManager { - object DataHolder : MultiFileDataHolder<FirmWaypoints>(serializer(), "waypoints") + object DConfig : DataHolder<MutableMap<String, FirmWaypoints>>(serializer(), "waypoints", ::mutableMapOf) val SHARE_PREFIX = "FIRM_WAYPOINTS/" val ENCODED_SHARE_PREFIX = TemplateUtil.getPrefixComparisonSafeBase64Encoding(SHARE_PREFIX) @@ -46,10 +46,10 @@ object FirmWaypointManager { return copy } - fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Text) -> Unit) { + fun loadWaypoints(waypoints: FirmWaypoints, sendFeedback: (Component) -> Unit) { val copy = waypoints.deepCopy() if (copy.isRelativeTo != null) { - val origin = MC.player!!.blockPos + val origin = MC.player!!.blockPosition() copy.waypoints.replaceAll { it.copy( x = it.x + origin.x, @@ -57,7 +57,7 @@ object FirmWaypointManager { z = it.z + origin.z, ) } - copy.lastRelativeImport = origin.toImmutable() + copy.lastRelativeImport = origin.immutable() sendFeedback(tr("firmament.command.waypoint.import.ordered.success", "Imported ${copy.size} relative waypoints. Make sure you stand in the correct spot while loading the waypoints: ${copy.isRelativeTo}.")) } else { @@ -70,7 +70,7 @@ object FirmWaypointManager { fun setOrigin(source: DefaultSource, text: String?) { val waypoints = Waypoints.useEditableWaypoints() waypoints.isRelativeTo = text ?: waypoints.isRelativeTo ?: "" - val pos = MC.player!!.blockPos + val pos = MC.player!!.blockPosition() waypoints.lastRelativeImport = pos source.sendFeedback(tr("firmament.command.waypoint.originset", "Set the origin of waypoints to ${FirmFormatters.formatPosition(pos)}. Run /firm waypoints export to save the waypoints relative to this position.")) @@ -100,7 +100,7 @@ object FirmWaypointManager { } thenLiteral("save") { thenArgument("name", StringArgumentType.string()) { name -> - suggestsList { DataHolder.list().keys } + suggestsList { DConfig.data.keys } thenExecute { val waypoints = Waypoints.useNonEmptyWaypoints() if (waypoints == null) { @@ -109,8 +109,8 @@ object FirmWaypointManager { } waypoints.id = get(name) val exportableWaypoints = createExportableCopy(waypoints) - DataHolder.insert(get(name), exportableWaypoints) - DataHolder.save() + DConfig.data[get(name)] = exportableWaypoints + DConfig.markDirty() source.sendFeedback(tr("firmament.command.waypoint.saved", "Saved waypoints locally as ${get(name)}. Use /firm waypoints load to load them again.")) } @@ -118,10 +118,10 @@ object FirmWaypointManager { } thenLiteral("load") { thenArgument("name", StringArgumentType.string()) { name -> - suggestsList { DataHolder.list().keys } + suggestsList { DConfig.data.keys } thenExecute { val name = get(name) - val waypoints = DataHolder.list()[name] + val waypoints = DConfig.data[name] if (waypoints == null) { source.sendError( tr("firmament.command.waypoint.nosaved", |
