aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-09-02 18:17:34 +0200
committerLinnea Gräf <nea@nea.moe>2024-09-02 18:17:34 +0200
commit20db57b43c9bc476e5af969552bcbec6729097da (patch)
tree1f0eaad808987a75588e89b88f54674884f54906 /src/main/kotlin/util
parent5ed74f2df49c93ed1617520a935078b59ad7e195 (diff)
downloadfirmament-20db57b43c9bc476e5af969552bcbec6729097da.tar.gz
firmament-20db57b43c9bc476e5af969552bcbec6729097da.tar.bz2
firmament-20db57b43c9bc476e5af969552bcbec6729097da.zip
Fix warp near X functionality not removing warps
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/WarpUtil.kt23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/kotlin/util/WarpUtil.kt b/src/main/kotlin/util/WarpUtil.kt
index e37f56f..c0ff996 100644
--- a/src/main/kotlin/util/WarpUtil.kt
+++ b/src/main/kotlin/util/WarpUtil.kt
@@ -1,4 +1,3 @@
-
package moe.nea.firmament.util
import io.github.moulberry.repo.constants.Islands
@@ -9,6 +8,9 @@ import kotlin.math.sqrt
import kotlin.time.Duration.Companion.seconds
import net.minecraft.text.Text
import net.minecraft.util.math.Position
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.commands.thenExecute
+import moe.nea.firmament.events.CommandEvent
import moe.nea.firmament.events.ProcessChatEvent
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
@@ -45,17 +47,32 @@ object WarpUtil {
fun teleportToNearestWarp(island: SkyBlockIsland, pos: Position) {
val nearestWarp = findNearestWarp(island, pos)
if (nearestWarp == null) {
- MC.sendChat(Text.literal("Could not find an unlocked warp in ${island.userFriendlyName}"))
+ MC.sendChat(Text.translatable("firmament.warp-util.no-warp-found", island.userFriendlyName))
return
}
if (island == SBData.skyblockLocation
&& sqrt(squaredDist(pos, nearestWarp)) > 1.1 * sqrt(squaredDist((MC.player ?: return).pos, nearestWarp))
) {
+ MC.sendChat(Text.translatable("firmament.warp-util.already-close", nearestWarp.warp))
return
}
+ MC.sendChat(Text.translatable("firmament.warp-util.attempting-to-warp", nearestWarp.warp))
+ lastWarpAttempt = TimeMark.now()
+ lastAttemptedWarp = nearestWarp.warp
MC.sendServerCommand("warp ${nearestWarp.warp}")
}
+ @Subscribe
+ fun clearUnlockedWarpsCommand(event: CommandEvent.SubCommand) {
+ event.subcommand("clearwarps") {
+ thenExecute {
+ DConfig.data?.excludedWarps?.clear()
+ DConfig.markDirty()
+ source.sendFeedback(Text.translatable("firmament.warp-util.clear-excluded"))
+ }
+ }
+ }
+
init {
ProcessChatEvent.subscribe("WarpUtil:processChat") {
if (it.unformattedString == "You haven't unlocked this fast travel destination!"
@@ -66,7 +83,7 @@ object WarpUtil {
MC.sendChat(Text.stringifiedTranslatable("firmament.warp-util.mark-excluded", lastAttemptedWarp))
lastWarpAttempt = TimeMark.farPast()
}
- if (it.unformattedString == "You may now fast travel to") {
+ if (it.unformattedString.startsWith("You may now fast travel to")) {
DConfig.data?.excludedWarps?.clear()
DConfig.markDirty()
}