diff options
author | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
commit | 2c0e73deb53f54d78bd5594786313ac82151be1a (patch) | |
tree | 97fc2f389cc99d8f9e078a1cd7b0c6a5859a3f34 /src/main/kotlin/com/ambientaddons | |
parent | 363b2426f8d9e45e52c472750c798dcaceb05a88 (diff) | |
download | AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.gz AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.bz2 AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.zip |
added chest qol features (complete, i think)
Diffstat (limited to 'src/main/kotlin/com/ambientaddons')
12 files changed, 590 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/AmbientAddons.kt b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt new file mode 100644 index 0000000..bf8e503 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/AmbientAddons.kt @@ -0,0 +1,65 @@ +import com.ambientaddons.commands.AmbientCommand +import com.ambientaddons.config.Config +import com.ambientaddons.config.PersistentData +import com.ambientaddons.features.dungeon.AutoBuyChest +import com.ambientaddons.utils.LocationUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiScreen +import net.minecraftforge.client.ClientCommandHandler +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.common.ModMetadata +import net.minecraftforge.fml.common.event.FMLInitializationEvent +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.io.File + +@Mod( + modid = "ambientaddons", + name = "AmbientAddons", + version = "0.1", + useMetadata = true, + clientSideOnly = true +) +class AmbientAddons { + + @Mod.EventHandler + fun preInit(event: FMLPreInitializationEvent) { + metadata = event.modMetadata + val directory = File(event.modConfigurationDirectory, "ambientaddons-forge") + directory.mkdirs() + configDirectory = directory + persistentData = PersistentData.load() + config = Config + } + + @Mod.EventHandler + fun onInit(event: FMLInitializationEvent) { + ClientCommandHandler.instance.registerCommand(AmbientCommand()) + + listOf( + this, + LocationUtils, + AutoBuyChest + ).forEach(MinecraftForge.EVENT_BUS::register) + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START || currentGui == null) return + mc.displayGuiScreen(currentGui) + currentGui = null + } + + companion object { + val mc: Minecraft = Minecraft.getMinecraft() + var currentGui: GuiScreen? = null + + lateinit var configDirectory: File + lateinit var config: Config + lateinit var persistentData: PersistentData + + lateinit var metadata: ModMetadata + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt new file mode 100644 index 0000000..5bfd92b --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/commands/AmbientCommand.kt @@ -0,0 +1,28 @@ +package com.ambientaddons.commands + +import AmbientAddons +import com.ambientaddons.config.Config +import com.ambientaddons.utils.Extensions.withModPrefix +import com.ambientaddons.utils.LocationUtils +import gg.essential.universal.UChat +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender + +class AmbientCommand : CommandBase() { + override fun getCommandName() = "ambientaddons" + + override fun getCommandAliases() = listOf("aa") + + override fun getCommandUsage(sender: ICommandSender?) = "/$commandName" + + override fun getRequiredPermissionLevel() = 0 + + override fun processCommand(sender: ICommandSender?, args: Array<String>) { + when (args.getOrNull(0)) { + null -> AmbientAddons.currentGui = Config.gui() + "location" -> UChat.chat(LocationUtils.toString().withModPrefix()) + "buy" -> AutoBuyCommand.processCommand(args.drop(1)) + else -> UChat.chat("§cUnknown argument!") + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt new file mode 100644 index 0000000..c7ff9a7 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt @@ -0,0 +1,43 @@ +package com.ambientaddons.commands + +import AmbientAddons.Companion.persistentData +import com.ambientaddons.utils.Extensions.withModPrefix +import gg.essential.universal.UChat + +object AutoBuyCommand { + fun processCommand(args: List<String>) { + when (args.getOrNull(0)) { + "add" -> { + val item = args[1] + val newPrice = args.getOrNull(2)?.toIntOrNull() + persistentData.autoBuyItems[item] = newPrice + persistentData.save() + UChat.chat("§aAdded item §a§l$item §awith ${if (newPrice == null) "no minimum price." else " minimum price §a§l$newPrice"}".withModPrefix()) + } + "remove" -> { + val item = args[1] + if (persistentData.autoBuyItems.contains(item)) { + persistentData.autoBuyItems.remove(item) + persistentData.save() + UChat.chat("§aRemoved item §a§l$item.".withModPrefix()) + } else UChat.chat("§cItem §a§l$item does not exist!".withModPrefix()) + } + "list" -> { + UChat.chat("§2§lItems".withModPrefix()) + persistentData.autoBuyItems.forEach { + if (it.value == null) { + UChat.chat(" §b${it.key}") + } else { + UChat.chat(" §b${it.key} §7(max price §a${it.value} §7coins)") + } + } + } + else -> { + UChat.chat("§2§lUsage".withModPrefix()) + UChat.chat(" §aAdd item: §b/ambient buy add <Skyblock ID> [max allowable price]") + UChat.chat(" §aRemove item: §b/ambient buy remove <Skyblock ID>") + UChat.chat(" §aList: §b/ambient buy list") + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt new file mode 100644 index 0000000..b283abb --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -0,0 +1,36 @@ +package com.ambientaddons.config + +import gg.essential.vigilance.Vigilant +import java.awt.Color +import java.io.File + + +object Config : Vigilant( + File(AmbientAddons.configDirectory, "config.toml"), + AmbientAddons.metadata.name +) { + var blockLowReroll = false + var autoBuyChest = 0 + + init { + category("Pre/Post Dungeon") { + subcategory("Chest QOL") { + switch ( + ::blockLowReroll, + name = "Block rerolling low chests", + description = "Prevents rerolling non-Bedrock chests (or Obsidian on M4)." + ) + selector( + ::autoBuyChest, + name = "Dungeon Reward Chests", + description = "Either blocks rerolls or automatically buys dungeon reward chests containing certain items.", + options = listOf("Off", "Block Reroll", "Autobuy") + ) + } + + } + } + + + +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt new file mode 100644 index 0000000..87bb287 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt @@ -0,0 +1,48 @@ +package com.ambientaddons.config + +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import java.io.File +import kotlinx.serialization.encodeToString +import kotlinx.serialization.decodeFromString + +@Serializable +data class PersistentData( + var autoBuyItems: MutableMap<String, Int?> = mutableMapOf( + "RECOMBOBULATOR_3000" to 5000000, + "FIRST_MASTER_STAR" to null, + "SECOND_MASTER_STAR" to null, + "THIRD_MASTER_STAR" to null, + "FOURTH_MASTER_STAR" to null, + "FIFTH_MASTER_STAR" to null, + "SPIRIT_WING" to null, + "SPIRIT_STONE" to 1000000, + "SHADOW_ASSASSIN_CHESTPLATE" to null, + "GIANTS_SWORD" to null, + "DARK_CLAYMORE" to null, + "THUNDERLORD_7" to null, + "WITHER_CHESTPLATE" to null, + "ULTIMATE_ONE_FOR_ALL_1" to null + ) +) { + + fun save() { + configFile.writeText(Json.encodeToString(this)) + } + + companion object { + private val configFile: File = File(AmbientAddons.configDirectory,"data.json") + + fun load(): PersistentData { + val data = if (!configFile.exists()) { + configFile.createNewFile() + PersistentData() + } else configFile.runCatching { + Json.decodeFromString<PersistentData>(this.readText()) + }.getOrNull() ?: PersistentData() + return data.apply { + this.save() + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt b/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt new file mode 100644 index 0000000..276abc3 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/events/GuiContainerEvent.kt @@ -0,0 +1,17 @@ +package com.ambientaddons.events + +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.inventory.Container +import net.minecraft.inventory.Slot +import net.minecraftforge.fml.common.eventhandler.Cancelable +import net.minecraftforge.fml.common.eventhandler.Event + +// credit Harry282/Skyblock-Client, under AGPL 3.0 +open class GuiContainerEvent(val container: Container, val gui: GuiContainer) : Event() { + @Cancelable + class DrawSlotEvent(container: Container, gui: GuiContainer, var slot: Slot) : GuiContainerEvent(container, gui) + + @Cancelable + class SlotClickEvent(container: Container, gui: GuiContainer, var slot: Slot?, var slotId: Int) : + GuiContainerEvent(container, gui) +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/events/ReceivePacketEvent.kt b/src/main/kotlin/com/ambientaddons/events/ReceivePacketEvent.kt new file mode 100644 index 0000000..d69fefe --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/events/ReceivePacketEvent.kt @@ -0,0 +1,9 @@ +package com.ambientaddons.events + +import net.minecraft.network.Packet +import net.minecraftforge.fml.common.eventhandler.Cancelable +import net.minecraftforge.fml.common.eventhandler.Event + +// credit Harry282/Skyblock-Client, under AGPL 3.0 +@Cancelable +class ReceivePacketEvent(packet: Packet<*>) : Event()
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt new file mode 100644 index 0000000..36f0b94 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/features/dungeon/AutoBuyChest.kt @@ -0,0 +1,114 @@ +package com.ambientaddons.features.dungeon + +import AmbientAddons.Companion.config +import AmbientAddons.Companion.mc +import AmbientAddons.Companion.persistentData +import com.ambientaddons.events.GuiContainerEvent +import com.ambientaddons.utils.Extensions.chest +import com.ambientaddons.utils.Extensions.enchants +import com.ambientaddons.utils.Extensions.items +import com.ambientaddons.utils.Extensions.lore +import com.ambientaddons.utils.Extensions.skyblockID +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.Extensions.withModPrefix +import com.ambientaddons.utils.LocationUtils +import gg.essential.universal.UChat +import net.minecraft.item.ItemStack +import net.minecraftforge.client.event.GuiOpenEvent +import net.minecraftforge.client.event.GuiScreenEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object AutoBuyChest { + private const val BUY_SLOT_INDEX = 31 + private const val KISMET_SLOT_INDEX = 50 + private var rewardChest: RewardChest? = null + private var hasOpenedChest = false + private var hasLookedAtChest = false + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + hasOpenedChest = false + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + UChat.chat(event.slotId) + if (rewardChest == null) return + if (event.slotId == BUY_SLOT_INDEX) { + hasOpenedChest = true + } else if (event.slotId == KISMET_SLOT_INDEX) { + if (config.blockLowReroll && rewardChest != RewardChest.Bedrock && (rewardChest != RewardChest.Obsidian || LocationUtils.dungeonFloor.toString() != "M4")) { + UChat.chat("§cBlocked reroll! This low-tier chest should not be rerolled.".withModPrefix()) + event.isCanceled = true + return + } + if (config.autoBuyChest == 1) { + val items = event.gui.chest?.lowerChestInventory?.items ?: return + if (getShouldOpen(items)) { + UChat.chat("§cBlocked reroll! Profitable content in chest.".withModPrefix()) + event.isCanceled = true + } + } + } + } + + @SubscribeEvent + fun onGuiOpen(event: GuiOpenEvent) { + if (event.gui == null) return + val chest = event.gui.chest?.lowerChestInventory?.name + + rewardChest = when (chest) { + "Wood Chest" -> RewardChest.Wood + "Gold Chest" -> RewardChest.Gold + "Emerald Chest" -> RewardChest.Emerald + "Diamond Chest" -> RewardChest.Diamond + "Obsidian Chest" -> RewardChest.Obsidian + "Bedrock Chest" -> RewardChest.Bedrock + else -> null + } + + hasLookedAtChest = false + } + + @SubscribeEvent + fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) { + if (config.autoBuyChest != 2 || rewardChest == null || hasLookedAtChest) return + if (rewardChest == RewardChest.Wood) return + val chest = event.gui?.chest ?: return + val items = chest.lowerChestInventory.items + if (items.last() != null) { + hasLookedAtChest = true + if (getShouldOpen(items)) { + mc.playerController.windowClick(chest.windowId, BUY_SLOT_INDEX, 0, 0, mc.thePlayer) + hasOpenedChest = true + mc.thePlayer.closeScreen() + } + } + } + + private fun getShouldOpen(items: List<ItemStack?>): Boolean { + val chestPrice = + items[BUY_SLOT_INDEX]?.lore?.getOrNull(6)?.stripControlCodes()?.filter { it.isDigit() }?.toIntOrNull() ?: 0 + + val lootItems = items.subList(9, 18).mapNotNull { itemStack -> + if (itemStack?.skyblockID == "ENCHANTED_BOOK") { + val enchants = itemStack.enchants + enchants?.entries?.singleOrNull()?.let { + "${it.key.uppercase()}_${it.value}" + } + } else itemStack?.skyblockID + } + + val maxPrice = lootItems.sumOf { + persistentData.autoBuyItems.getOrDefault(it, 0) ?: 100000000 + } + + return chestPrice <= maxPrice + } + + enum class RewardChest { + Wood, Gold, Emerald, Diamond, Obsidian, Bedrock + } + +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt b/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt new file mode 100644 index 0000000..a64fed0 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/DungeonFloor.kt @@ -0,0 +1,32 @@ +package com.ambientaddons.utils + +data class DungeonFloor( + val mode: Mode, + val floor: Int +) { + override fun toString(): String { + return when { + floor == 0 -> "E" + mode == Mode.Normal -> "F$floor" + else -> "M$floor" + } + } + + companion object { + fun String.toDungeonFloor(): DungeonFloor? { + if (this.isEmpty()) return null + if (this == "E") return DungeonFloor(Mode.Normal, 0) + val floorInt = this.last().digitToIntOrNull() ?: return null + if (floorInt !in 1..7) return null + return when (this.first()) { + 'F' -> DungeonFloor(Mode.Normal, floorInt) + 'M' -> DungeonFloor(Mode.Master, floorInt) + else -> null + } + } + } +} + +enum class Mode { Normal, Master } + + diff --git a/src/main/kotlin/com/ambientaddons/utils/Extensions.kt b/src/main/kotlin/com/ambientaddons/utils/Extensions.kt new file mode 100644 index 0000000..3da5767 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/Extensions.kt @@ -0,0 +1,73 @@ +package com.ambientaddons.utils + +import com.ambientaddons.utils.Extensions.enchants +import com.ambientaddons.utils.Extensions.extraAttributes +import com.ambientaddons.utils.Extensions.skyblockID +import net.minecraft.client.gui.GuiScreen +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.IInventory +import net.minecraft.item.Item +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NBTTagCompound +import net.minecraft.util.StringUtils + +object Extensions { + fun String.substringBetween(start: String, end: String): String { + return this + .substringAfter("(", "") + .substringBefore(")", "") + } + + fun String.stripControlCodes(): String { + return StringUtils.stripControlCodes(this) + } + + fun String.cleanSB(): String { + return StringUtils.stripControlCodes(this) + ?.toCharArray() + ?.filter { it.code in 21..126 } + ?.joinToString("") + ?: "" + } + + fun String.withModPrefix(): String { + return "§9§lAmbient §7» §r${this}" + } + + val GuiScreen.chest: ContainerChest? + get() = (this as? GuiChest)?.inventorySlots as? ContainerChest + + val IInventory.items: List<ItemStack?> + get() = (0 until this.sizeInventory).map { this.getStackInSlot(it) } + + + private val ItemStack.extraAttributes: NBTTagCompound? + get() { + if (!this.hasTagCompound()) return null + return this.getSubCompound("ExtraAttributes", false) ?: return null + } + + val ItemStack.skyblockID: String? + get() = this.extraAttributes?.let { + if (!it.hasKey("id", 8)) return null + return it.getString("id") + } + + val ItemStack.enchants: Map<String, Int>? + get() = this.extraAttributes?.let { extraAttributes -> + if (!extraAttributes.hasKey("enchantments", 10)) return null + val enchantments = extraAttributes.getCompoundTag("enchantments") + enchantments.keySet.associateWith { enchantments.getInteger(it) } + } + + val ItemStack.lore: List<String>? + get() { + if (!this.hasTagCompound()) return null + val displayTag = this.getSubCompound("display", false) ?: return null + if (!displayTag.hasKey("Lore", 9)) return null + val loreList = displayTag.getTagList("Lore", 8) + return (0 until loreList.tagCount()).map { loreList.getStringTagAt(it) } + } + +} diff --git a/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt b/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt new file mode 100644 index 0000000..d185a08 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/LocationUtils.kt @@ -0,0 +1,87 @@ +package com.ambientaddons.utils + +import AmbientAddons.Companion.mc +import com.ambientaddons.utils.DungeonFloor.Companion.toDungeonFloor +import com.ambientaddons.utils.Extensions.cleanSB +import com.ambientaddons.utils.Extensions.stripControlCodes +import com.ambientaddons.utils.Extensions.substringBetween +import com.ambientaddons.utils.TabListUtils.fetchTabEntries +import net.minecraft.scoreboard.Score +import net.minecraft.scoreboard.ScorePlayerTeam +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import net.minecraftforge.fml.common.network.FMLNetworkEvent + +object LocationUtils { + private var areaRegex = Regex("^(?:Area|Dungeon): ([\\w ].+)\$") + private var onHypixel = false + var inSkyblock = false + var location: String? = null + var dungeonFloor: DungeonFloor? = null + var ticks = 0 + + @SubscribeEvent + fun onWorldUnload(event: WorldEvent.Unload) { + inSkyblock = false + dungeonFloor = null + location = null + } + + @SubscribeEvent + fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) { + onHypixel = mc.runCatching { + !event.isLocal && ((thePlayer?.clientBrand?.lowercase()?.contains("hypixel") + ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel")) == true) + }.getOrDefault(false) + } + + @SubscribeEvent + fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + onHypixel = false + } + + // from Skytils, under AGPL 3.0 + fun fetchScoreboardLines(): List<String> { + val scoreboard = mc.theWorld?.scoreboard ?: return emptyList() + val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList() + val scores = scoreboard.getSortedScores(objective).filter { input: Score? -> + input != null && input.playerName != null && !input.playerName + .startsWith("#") + }.take(15) + return scores.map { + ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName).cleanSB() + }.asReversed() + } + + // modified from Harry282/Skyblock-Client, under AGPL 3.0 + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!onHypixel || event.phase != TickEvent.Phase.START) return + if (ticks % 10 == 0) { + val title = mc.theWorld?.scoreboard?.getObjectiveInDisplaySlot(1)?.displayName?.cleanSB() + if (!inSkyblock) { + inSkyblock = title?.contains("SKYBLOCK") == true + } + if (inSkyblock) { + if (location == null) { + val tab = fetchTabEntries() + location = tab.firstNotNullOfOrNull { areaRegex.find(it.text.stripControlCodes()) }?.let { + it.groupValues.getOrNull(1) + } + } + if (location == "Catacombs" && dungeonFloor == null) { + val dungeonLine = fetchScoreboardLines().find { + it.run { contains("The Catacombs (") && !contains("Queue") } + } + dungeonFloor = dungeonLine?.substringBetween("(", ")")?.toDungeonFloor() + } + } + } + ticks++ + } + + override fun toString(): String = + "onHypixel: $onHypixel, inSkyblock: $inSkyblock, location: $location, floor: $dungeonFloor" + +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt b/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt new file mode 100644 index 0000000..6fd7fef --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt @@ -0,0 +1,38 @@ +package com.ambientaddons.utils + +import AmbientAddons.Companion.mc +import com.google.common.collect.ComparisonChain +import com.google.common.collect.Ordering +import net.minecraft.client.network.NetworkPlayerInfo +import net.minecraft.world.WorldSettings + +// From SkytilsMod/Skytils, under AGPL 3.0 +val NetworkPlayerInfo.text: String + get() = mc.ingameGUI.tabList.getPlayerName(this) + +object TabListUtils { + private val playerInfoOrdering = object : Ordering<NetworkPlayerInfo>() { + override fun compare(p_compare_1_: NetworkPlayerInfo?, p_compare_2_: NetworkPlayerInfo?): Int { + val scorePlayerTeam = p_compare_1_?.playerTeam + val scorePlayerTeam1 = p_compare_2_?.playerTeam + if (p_compare_1_ != null) { + if (p_compare_2_ != null) { + return ComparisonChain.start().compareTrueFirst( + p_compare_1_.gameType != WorldSettings.GameType.SPECTATOR, + p_compare_2_.gameType != WorldSettings.GameType.SPECTATOR + ).compare( + if (scorePlayerTeam != null) scorePlayerTeam.registeredName else "", + if (scorePlayerTeam1 != null) scorePlayerTeam1.registeredName else "" + ).compare(p_compare_1_.gameProfile.name, p_compare_2_.gameProfile.name).result() + } + return 0 + } + return -1 + } + } + + fun fetchTabEntries(): List<NetworkPlayerInfo> = + if (mc.thePlayer == null) emptyList() else playerInfoOrdering.sortedCopy( + mc.thePlayer.sendQueue.playerInfoMap + ) +}
\ No newline at end of file |