aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/commands
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-29 23:28:52 +0200
committernea <nea@nea.moe>2023-05-29 23:28:52 +0200
commitdd0afac3a8459035827dac36986a690c8a9541ea (patch)
tree2bc3ab50b69590a6811a8265f4c533163d07457c /src/main/kotlin/moe/nea/firmament/commands
parentc133505e3b1f8e5aeb62c1a0e99513ec4bfcf239 (diff)
downloadFirmament-dd0afac3a8459035827dac36986a690c8a9541ea.tar.gz
Firmament-dd0afac3a8459035827dac36986a690c8a9541ea.tar.bz2
Firmament-dd0afac3a8459035827dac36986a690c8a9541ea.zip
Add price checker
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/commands')
-rw-r--r--src/main/kotlin/moe/nea/firmament/commands/dsl.kt12
-rw-r--r--src/main/kotlin/moe/nea/firmament/commands/rome.kt26
2 files changed, 38 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/commands/dsl.kt b/src/main/kotlin/moe/nea/firmament/commands/dsl.kt
index e2b9e8a..155e700 100644
--- a/src/main/kotlin/moe/nea/firmament/commands/dsl.kt
+++ b/src/main/kotlin/moe/nea/firmament/commands/dsl.kt
@@ -23,6 +23,7 @@ import com.mojang.brigadier.builder.ArgumentBuilder
import com.mojang.brigadier.builder.LiteralArgumentBuilder
import com.mojang.brigadier.builder.RequiredArgumentBuilder
import com.mojang.brigadier.context.CommandContext
+import com.mojang.brigadier.suggestion.SuggestionProvider
import java.lang.reflect.ParameterizedType
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import moe.nea.firmament.util.iterate
@@ -80,6 +81,17 @@ fun <T : ArgumentBuilder<DefaultSource, T>, AT : Any> T.thenArgument(
block: RequiredArgumentBuilder<DefaultSource, AT>.(TypeSafeArg<AT>) -> Unit
): T = then(argument(name, argument, block))
+fun <T : RequiredArgumentBuilder<DefaultSource, String>> T.suggestsList(provider: () -> Iterable<String>) {
+ suggests(SuggestionProvider<DefaultSource> { context, builder ->
+ provider()
+ .asSequence()
+ .filter { it.startsWith(builder.remaining, ignoreCase = true) }
+ .forEach {
+ builder.suggest(it)
+ }
+ builder.buildFuture()
+ })
+}
fun <T : ArgumentBuilder<DefaultSource, T>> T.thenLiteral(
name: String,
diff --git a/src/main/kotlin/moe/nea/firmament/commands/rome.kt b/src/main/kotlin/moe/nea/firmament/commands/rome.kt
index 55dce75..02b12d9 100644
--- a/src/main/kotlin/moe/nea/firmament/commands/rome.kt
+++ b/src/main/kotlin/moe/nea/firmament/commands/rome.kt
@@ -19,12 +19,16 @@
package moe.nea.firmament.commands
import com.mojang.brigadier.CommandDispatcher
+import com.mojang.brigadier.arguments.StringArgumentType.getString
+import com.mojang.brigadier.arguments.StringArgumentType.string
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import moe.nea.firmament.features.world.FairySouls
import moe.nea.firmament.gui.config.AllConfigsGui
+import moe.nea.firmament.repo.ItemCostData
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.SBData
+import moe.nea.firmament.util.SkyblockId
fun firmamentCommand() = literal("firmament") {
@@ -47,6 +51,28 @@ fun firmamentCommand() = literal("firmament") {
}
}
}
+ thenLiteral("price") {
+ thenArgument("item", string()) { item ->
+ suggestsList { RepoManager.neuRepo.items.items.keys }
+ thenExecute {
+ val itemName = SkyblockId(getString(context, "item"))
+ source.sendFeedback(Text.translatable("firmament.price", itemName.neuItem))
+ val bazaarData = ItemCostData.bazaarData[itemName]
+ if (bazaarData != null) {
+ source.sendFeedback(Text.translatable("firmament.price.bazaar"))
+ source.sendFeedback(Text.translatable("firmament.price.bazaar.productid", bazaarData.productId.bazaarId))
+ source.sendFeedback(Text.translatable("firmament.price.bazaar.buy.price", bazaarData.quickStatus.buyPrice))
+ source.sendFeedback(Text.translatable("firmament.price.bazaar.buy.order", bazaarData.quickStatus.buyOrders))
+ source.sendFeedback(Text.translatable("firmament.price.bazaar.sell.price", bazaarData.quickStatus.sellPrice))
+ source.sendFeedback(Text.translatable("firmament.price.bazaar.sell.order", bazaarData.quickStatus.sellOrders))
+ }
+ val lowestBin = ItemCostData.lowestBin[itemName]
+ if (lowestBin != null) {
+ source.sendFeedback(Text.translatable("firmament.price.lowestbin", lowestBin))
+ }
+ }
+ }
+ }
thenLiteral("dev") {
thenLiteral("config") {
thenExecute {