Fix ex MVP++ users being shown as unranked
This commit is contained in:
@@ -58,7 +58,7 @@ enum class Skill(val accessor: KProperty1<Member, Double>, val color: DyeColor)
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Member(
|
data class Member(
|
||||||
val pets: List<Pet>,
|
val pets: List<Pet> = listOf(),
|
||||||
@SerialName("coop_invitation")
|
@SerialName("coop_invitation")
|
||||||
val coopInvitation: CoopInvitation? = null,
|
val coopInvitation: CoopInvitation? = null,
|
||||||
@SerialName("experience_skill_farming")
|
@SerialName("experience_skill_farming")
|
||||||
@@ -129,7 +129,7 @@ data class PlayerData(
|
|||||||
val rankPlusColor: String = "GOLD"
|
val rankPlusColor: String = "GOLD"
|
||||||
) {
|
) {
|
||||||
val rankPlusDyeColor = LegacyFormattingCode.values().find { it.name == rankPlusColor } ?: LegacyFormattingCode.GOLD
|
val rankPlusDyeColor = LegacyFormattingCode.values().find { it.name == rankPlusColor } ?: LegacyFormattingCode.GOLD
|
||||||
val rankData get() = RepoManager.neuRepo.constants.misc.ranks[monthlyPackageRank ?: packageRank]
|
val rankData get() = RepoManager.neuRepo.constants.misc.ranks[if (monthlyPackageRank == "NONE" || monthlyPackageRank == null) packageRank else monthlyPackageRank]
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder
|
|||||||
import com.mojang.brigadier.context.CommandContext
|
import com.mojang.brigadier.context.CommandContext
|
||||||
import com.mojang.brigadier.suggestion.SuggestionProvider
|
import com.mojang.brigadier.suggestion.SuggestionProvider
|
||||||
import java.lang.reflect.ParameterizedType
|
import java.lang.reflect.ParameterizedType
|
||||||
|
import java.lang.reflect.Type
|
||||||
|
import java.lang.reflect.TypeVariable
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
|
||||||
import moe.nea.firmament.util.iterate
|
import moe.nea.firmament.util.iterate
|
||||||
|
|
||||||
@@ -43,18 +45,31 @@ fun literal(
|
|||||||
): LiteralArgumentBuilder<DefaultSource> =
|
): LiteralArgumentBuilder<DefaultSource> =
|
||||||
LiteralArgumentBuilder.literal<DefaultSource>(name).also(block)
|
LiteralArgumentBuilder.literal<DefaultSource>(name).also(block)
|
||||||
|
|
||||||
|
|
||||||
|
private fun normalizeGeneric(argument: Type): Class<*> {
|
||||||
|
return if (argument is Class<*>) {
|
||||||
|
argument
|
||||||
|
} else if (argument is TypeVariable<*>) {
|
||||||
|
normalizeGeneric(argument.bounds[0])
|
||||||
|
} else if (argument is ParameterizedType) {
|
||||||
|
normalizeGeneric(argument.rawType)
|
||||||
|
} else {
|
||||||
|
Any::class.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class TypeSafeArg<T : Any>(val name: String, val argument: ArgumentType<T>) {
|
data class TypeSafeArg<T : Any>(val name: String, val argument: ArgumentType<T>) {
|
||||||
val argClass by lazy {
|
val argClass by lazy {
|
||||||
argument.javaClass
|
argument.javaClass
|
||||||
.iterate<Class<in ArgumentType<T>>> {
|
.iterate<Class<in ArgumentType<T>>> {
|
||||||
it.superclass
|
it.superclass
|
||||||
}
|
}
|
||||||
.map {
|
.flatMap {
|
||||||
it.genericSuperclass
|
it.genericInterfaces.toList()
|
||||||
}
|
}
|
||||||
.filterIsInstance<ParameterizedType>()
|
.filterIsInstance<ParameterizedType>()
|
||||||
.find { it.rawType == ArgumentType::class.java }!!
|
.find { it.rawType == ArgumentType::class.java }!!
|
||||||
.let { it.actualTypeArguments[0] as Class<*> }
|
.let { normalizeGeneric(it.actualTypeArguments[0]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmName("getWithThis")
|
@JvmName("getWithThis")
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ fun firmamentCommand() = literal("firmament") {
|
|||||||
thenExecute {
|
thenExecute {
|
||||||
ProfileViewer.onCommand(source, MC.player!!.name.unformattedString)
|
ProfileViewer.onCommand(source, MC.player!!.name.unformattedString)
|
||||||
}
|
}
|
||||||
|
thenArgument("name", string()) { name ->
|
||||||
|
suggestsList { MC.world?.players?.map { it.name.unformattedString } ?: listOf() }
|
||||||
|
thenExecute {
|
||||||
|
ProfileViewer.onCommand(source, get(name))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
thenLiteral("price") {
|
thenLiteral("price") {
|
||||||
thenArgument("item", string()) { item ->
|
thenArgument("item", string()) { item ->
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ object SkillPage : ProfilePage {
|
|||||||
profileViewer.account.rankData?.let {
|
profileViewer.account.rankData?.let {
|
||||||
("§${it.color}[${it.tag}${profileViewer.account.rankPlusDyeColor.modern}" +
|
("§${it.color}[${it.tag}${profileViewer.account.rankPlusDyeColor.modern}" +
|
||||||
"${it.plus ?: ""}§${it.color}] ${profileViewer.primaryName}")
|
"${it.plus ?: ""}§${it.color}] ${profileViewer.primaryName}")
|
||||||
} ?: "§${Formatting.GRAY}${profileViewer.primaryName}"
|
} ?: "${Formatting.GRAY}${profileViewer.primaryName}"
|
||||||
)
|
)
|
||||||
), 0, 0, 6, 1
|
), 0, 0, 6, 1
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user