1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/*
* Firmament is a Hypixel Skyblock mod for modern Minecraft versions
* Copyright (C) 2023 Linnea Gräf
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 io.github.cottonmc.cotton.gui.client.CottonClientScreen
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.parameter
import io.ktor.http.URLProtocol
import io.ktor.http.path
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import kotlinx.coroutines.launch
import net.minecraft.text.Text
import moe.nea.firmament.Firmament
import moe.nea.firmament.apis.Profiles
import moe.nea.firmament.features.world.FairySouls
import moe.nea.firmament.gui.config.AllConfigsGui
import moe.nea.firmament.gui.profileviewer.ProfileViewer
import moe.nea.firmament.repo.ItemCostData
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.unformattedString
fun firmamentCommand() = literal("firmament") {
thenLiteral("config") {
thenExecute {
AllConfigsGui.showAllGuis()
}
}
thenLiteral("repo") {
thenLiteral("reload") {
thenLiteral("fetch") {
thenExecute {
source.sendFeedback(Text.translatable("firmament.repo.reload.network")) // TODO better reporting
RepoManager.launchAsyncUpdate()
}
}
thenExecute {
source.sendFeedback(Text.translatable("firmament.repo.reload.disk"))
RepoManager.reload()
}
}
}
thenLiteral("pv") {
thenExecute {
val me = MC.player!!.uuid
val name = MC.player!!.name.unformattedString
val names = mapOf(me to name)
source.sendFeedback(Text.translatable("firmament.pv.lookingup", name))
Firmament.coroutineScope.launch {
val profiles = Firmament.httpClient.get {
url {
protocol = URLProtocol.HTTPS
host = "api.hypixel.net"
path("skyblock", "profiles")
parameter("key", "06b68418-71eb-4c2a-bb8a-65ed8bd4d5aa")
parameter("uuid", me.toString())
}
}.body<Profiles>()
val profile = profiles.profiles.find { it.selected }
if (profile == null) {
source.sendFeedback(Text.translatable("firmament.pv.noprofile", name))
return@launch
}
ScreenUtil.setScreenLater(CottonClientScreen(ProfileViewer(me, names, profile)))
}
}
}
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 {
FairySouls.TConfig.showConfigEditor()
}
}
thenLiteral("sbdata") {
thenExecute {
source.sendFeedback(Text.translatable("firmament.sbinfo.profile", SBData.profileCuteName))
val locrawInfo = SBData.locraw
if (locrawInfo == null) {
source.sendFeedback(Text.translatable("firmament.sbinfo.nolocraw"))
} else {
source.sendFeedback(Text.translatable("firmament.sbinfo.server", locrawInfo.server))
source.sendFeedback(Text.translatable("firmament.sbinfo.gametype", locrawInfo.gametype))
source.sendFeedback(Text.translatable("firmament.sbinfo.mode", locrawInfo.mode))
source.sendFeedback(Text.translatable("firmament.sbinfo.map", locrawInfo.map))
}
}
}
}
}
fun registerFirmamentCommand(dispatcher: CommandDispatcher<FabricClientCommandSource>) {
val firmament = dispatcher.register(firmamentCommand())
dispatcher.register(literal("firm") {
redirect(firmament)
})
}
|