Skip to content

Commit 17056e0

Browse files
committed
added support for non formatted json
1 parent 232af43 commit 17056e0

File tree

8 files changed

+122
-71
lines changed

8 files changed

+122
-71
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ version=0.2.1
77
# requiredOdin and the latest action must have the same name if useActions is true.
88
requiredOdin=Odin-1.3.2.jar
99
odinRepository = odtheking/Odin
10-
useActions=true
10+
useActions=false

src/main/kotlin/com/github/subat0m1c/hatecheaters/HateCheaters.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import com.github.subat0m1c.hatecheaters.commands.CommandRegistry
44
import com.github.subat0m1c.hatecheaters.commands.impl.PVCommand
55
import com.github.subat0m1c.hatecheaters.modules.dungeons.BetterPartyFinder
66
import com.github.subat0m1c.hatecheaters.modules.dungeons.ClearSecrets
7-
import com.github.subat0m1c.hatecheaters.modules.skyblock.HateCheatersModule
87
import com.github.subat0m1c.hatecheaters.modules.render.ProfileViewer
98
import com.github.subat0m1c.hatecheaters.modules.render.ProfileViewer.pvCommand
9+
import com.github.subat0m1c.hatecheaters.modules.skyblock.HateCheatersModule
1010
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.ItemGridDSL
1111
import com.github.subat0m1c.hatecheaters.utils.ExtraStatsHandler
1212
import com.github.subat0m1c.hatecheaters.utils.LogHandler
1313
import com.github.subat0m1c.hatecheaters.utils.LogHandler.Logger
1414
import com.github.subat0m1c.hatecheaters.utils.OdinCheck.checkIfOdinIsLoaded
15+
import com.github.subat0m1c.hatecheaters.utils.toasts.ToastRenderer
1516
import kotlinx.coroutines.*
1617
import kotlinx.serialization.json.Json
1718
import me.odinmain.OdinMain.mc
1819
import me.odinmain.features.ModuleManager
19-
import com.github.subat0m1c.hatecheaters.utils.toasts.ToastRenderer
2020
import net.minecraft.client.gui.GuiScreen
2121
import net.minecraftforge.common.MinecraftForge
2222
import net.minecraftforge.fml.common.Mod

src/main/kotlin/com/github/subat0m1c/hatecheaters/modules/dungeons/BetterPartyFinder.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
package com.github.subat0m1c.hatecheaters.modules.dungeons
22

33
import com.github.subat0m1c.hatecheaters.HateCheaters.Companion.launch
4-
import com.github.subat0m1c.hatecheaters.utils.DungeonStats.displayDungeonData
54
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.Utils.formatted
5+
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.Utils.without
66
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
77
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.secondsToMinutes
88
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.toastMessage
9+
import com.github.subat0m1c.hatecheaters.utils.DungeonStats.displayDungeonData
910
import com.github.subat0m1c.hatecheaters.utils.ItemUtils.witherImpactRegex
1011
import com.github.subat0m1c.hatecheaters.utils.LogHandler.Logger
1112
import com.github.subat0m1c.hatecheaters.utils.apiutils.HypixelApi.getProfile
1213
import me.odinmain.features.Module
1314
import me.odinmain.features.settings.Setting.Companion.withDependency
1415
import me.odinmain.features.settings.impl.*
15-
import me.odinmain.utils.*
16-
import me.odinmain.utils.skyblock.*
16+
import me.odinmain.utils.noControlCodes
17+
import me.odinmain.utils.round
18+
import me.odinmain.utils.runIn
19+
import me.odinmain.utils.skyblock.PlayerUtils
1720
import me.odinmain.utils.skyblock.PlayerUtils.alert
18-
import kotlin.collections.HashSet
21+
import me.odinmain.utils.skyblock.lore
22+
import me.odinmain.utils.skyblock.partyMessage
23+
import me.odinmain.utils.skyblock.sendCommand
1924

2025
object BetterPartyFinder : Module(
2126
name = "Better Party Finder",
@@ -282,8 +287,9 @@ object BetterPartyFinder : Module(
282287
if (it < (secretsreq * 1000)) kickedReasons.add("Did not meet secret req: ${it}/$secretsreq")
283288
}
284289

285-
val mmComps = (currentProfile.dungeons.dungeonTypes.mastermode.tierComps.entries.sumOf { entry -> entry.value.takeUnless { entry.key == "total" } ?: 0 })
286-
val floorComps = (currentProfile.dungeons.dungeonTypes.catacombs.tierComps.entries.sumOf { entry -> entry.value.takeUnless { entry.key == "total" } ?: 0 })
290+
val mmComps = (currentProfile.dungeons.dungeonTypes.mastermode.tierComps.without("total")).values.sum()
291+
val floorComps =
292+
(currentProfile.dungeons.dungeonTypes.mastermode.tierComps.without("total")).values.sum()
287293
((secretCount.toDouble()/(mmComps + floorComps).toDouble()).toFloat()).let {
288294
if (!savgKick) return@let
289295
if (it < savgreq) kickedReasons.add("Did not meet savg req: ${it.round(2)}/$savgreq")

src/main/kotlin/com/github/subat0m1c/hatecheaters/modules/skyblock/HateCheatersModule.kt

Lines changed: 83 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.subat0m1c.hatecheaters.modules.skyblock
22

33
import com.github.subat0m1c.hatecheaters.utils.networkutils.CheckUpdate
44
import com.github.subat0m1c.hatecheaters.utils.toasts.ToastRenderer
5-
import io.netty.buffer.Unpooled
65
import me.odinmain.events.impl.PacketEvent
76
import me.odinmain.features.Module
87
import me.odinmain.features.settings.AlwaysActive
@@ -11,25 +10,7 @@ import me.odinmain.features.settings.impl.BooleanSetting
1110
import me.odinmain.features.settings.impl.SelectorSetting
1211
import me.odinmain.features.settings.impl.StringSetting
1312
import me.odinmain.utils.skyblock.modMessage
14-
import net.minecraft.entity.EntityLiving
15-
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry
16-
import net.minecraft.entity.ai.EntityAIWatchClosest
17-
import net.minecraft.entity.monster.EntityZombie
18-
import net.minecraft.entity.passive.EntityPig
19-
import net.minecraft.item.Item
20-
import net.minecraft.item.ItemStack
21-
import net.minecraft.network.EnumConnectionState
22-
import net.minecraft.network.EnumPacketDirection
23-
import net.minecraft.network.PacketBuffer
24-
import net.minecraft.network.play.server.S02PacketChat
25-
import net.minecraft.network.play.server.S14PacketEntity.S15PacketEntityRelMove
26-
import net.minecraft.network.play.server.S20PacketEntityProperties
27-
import net.minecraft.network.play.server.S2FPacketSetSlot
28-
import net.minecraft.network.play.server.S32PacketConfirmTransaction
29-
import net.minecraft.util.ChatComponentScore
30-
import net.minecraft.util.ChatComponentText
31-
import net.minecraft.util.IChatComponent
32-
import net.minecraft.util.Vec3
13+
import net.minecraft.network.play.server.S38PacketPlayerListItem
3314
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
3415

3516
@AlwaysActive
@@ -100,22 +81,81 @@ object HateCheatersModule : Module(
10081
// //println("sent packet: ${event.packet::class.java.simpleName} with id: ${packetId}: $testString")
10182
// }
10283
//
103-
// @SubscribeEvent
104-
// fun onPacketReceive(event: PacketEvent.Receive) {
105-
// val packet = event.packet as? S2FPacketSetSlot ?: return
106-
// val windowId = packet.func_149175_c()
107-
// val slot = packet.func_149173_d()
108-
// val itemStack = packet.func_149174_e()
109-
//
110-
// val newPacket = S2FPacketSetSlot(
111-
// windowId,
112-
// slot ,
113-
// itemStack
114-
// )
84+
@SubscribeEvent
85+
fun onPacketReceive(event: PacketEvent.Receive) {
86+
val packet = event.packet as? S38PacketPlayerListItem ?: return
87+
modMessage(
88+
"""
89+
Player List Packet:
90+
Action: ${packet.action}
91+
Entries: ${
92+
packet.entries.joinToString("\n") {
93+
"""
94+
{
95+
name: ${it?.profile?.name},
96+
id: ${it?.profile?.id},
97+
gameMode: ${it?.gameMode},
98+
ping: ${it?.ping},
99+
displayName: ${it?.displayName}
100+
other: ${
101+
it?.profile?.properties?.entries()?.joinToString("\n") { (key, value) ->
102+
"""
103+
{
104+
key: $key
105+
property: {
106+
name: ${value.name}
107+
value: ${value.value}
108+
sig: ${value.signature}
109+
}
110+
}
111+
""".trimIndent()
112+
}
113+
}
114+
}
115+
""".trimIndent()
116+
}
117+
}
118+
""".trimIndent()
119+
)
120+
}
121+
122+
// if (event.packet !is S3BPacketScoreboardObjective && event.packet !is S3CPacketUpdateScore && event.packet !is S3EPacketTeams) return
123+
// if (event.packet is S3BPacketScoreboardObjective) {
124+
// val packet = event.packet as? S3BPacketScoreboardObjective ?: return
125+
//
126+
// LogHandler.Logger.info("objective packet: scoreboard name: ${packet.func_149339_c()}, object value: ${packet.func_149337_d()}")
127+
// }
128+
//
129+
// if (event.packet is S3CPacketUpdateScore) {
130+
// val packet = event.packet as? S3CPacketUpdateScore ?: return
131+
//
132+
// LogHandler.Logger.info("Update score packet: score: ${packet.objectiveName} text: ${packet.playerName}")
133+
// }
134+
//
135+
// if (event.packet is S3EPacketTeams) {
136+
// val packet = event.packet as? S3EPacketTeams ?: return
137+
//
138+
// LogHandler.Logger.info("""
139+
// Teams packet:
140+
// team name: ${packet.name},
141+
// display name: ${packet.displayName}
142+
// suffix: ${packet.suffix},
143+
// prefix: ${packet.prefix},
144+
// action: ${packet.action},
145+
// friendly fire: ${packet.friendlyFlags},
146+
// name tag visibility: ${packet.nameTagVisibility},
147+
// players: ${packet.players},
148+
// color: ${packet.color}
149+
// """.trimIndent())
150+
// }
151+
152+
// val packet = event.packet as? S47PacketPlayerListHeaderFooter ?: return
153+
// println("header: ${packet.header}, footer: ${packet.footer}")
154+
// if (packet.action != S38PacketPlayerListItem.Action.ADD_PLAYER) return
115155
//
116156
// val buf = PacketBuffer(Unpooled.buffer())
117157
// val packetId = try {
118-
// EnumConnectionState.PLAY.getPacketId(EnumPacketDirection.SERVERBOUND, event.packet)
158+
// EnumConnectionState.PLAY.getPacketId(EnumPacketDirection.CLIENTBOUND, packet)
119159
// } catch (e: NullPointerException) {
120160
// println("${event.packet::class.java.simpleName} failed to get packet id")
121161
// null
@@ -124,13 +164,19 @@ object HateCheatersModule : Module(
124164
// packetId?.let {
125165
// buf.writeVarIntToBuffer(it)
126166
// }
127-
// newPacket.writePacketData(buf)
167+
// packet.writePacketData(buf)
168+
//
169+
// val payload = PacketBuffer(Unpooled.buffer())
170+
// payload.writeVarIntToBuffer(buf.readableBytes())
171+
// payload.writeBytes(buf)
172+
// println("readable bytes: ${payload.readableBytes()}")
128173
//
129174
// val testString = StringBuilder()
130-
// for (i in 0 until buf.readableBytes()) {
131-
// testString.append(String.format("%02X ", buf.getByte(i)))
175+
// for (i in 0 until payload.readableBytes()) {
176+
// testString.append(String.format("%02X ", payload.getByte(i)))
132177
// }
133178
//
179+
// println("packet: $packet")
180+
//
134181
// println("Recieved and made a packet: $testString")
135-
// }
136182
}

src/main/kotlin/com/github/subat0m1c/hatecheaters/pvgui/v2/pages/Dungeons.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.github.subat0m1c.hatecheaters.pvgui.v2.pages
22

33
import com.github.subat0m1c.hatecheaters.pvgui.v2.Pages
44
import com.github.subat0m1c.hatecheaters.pvgui.v2.Pages.centeredText
5-
import com.github.subat0m1c.hatecheaters.pvgui.v2.pages.Dungeons.ct
65
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.Utils.without
76
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.profileLazy
87
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.colorClass
@@ -25,13 +24,17 @@ object Dungeons: Pages.PVPage("Dungeons") {
2524
private val cataCenter = mainCenterX - mainWidth / 4
2625
private val cataLineY = mainHeight * 0.1
2726

28-
private val mmComps: Int by profileLazy { (profile.dungeons.dungeonTypes.mastermode.tierComps.without("total")).values.sum() }
29-
private val floorComps: Int by profileLazy { (profile.dungeons.dungeonTypes.catacombs.tierComps.without("total")).values.sum() }
27+
private val mmComps: Float by profileLazy { (profile.dungeons.dungeonTypes.mastermode.tierComps.without("total")).values.sum() }
28+
private val floorComps: Float by profileLazy { (profile.dungeons.dungeonTypes.catacombs.tierComps.without("total")).values.sum() }
3029

3130
private val text: List<String> by profileLazy {
3231
listOf(
3332
"§bSecrets§7: ${profile.dungeons.secrets.commas.colorizeNumber(100000)}",
34-
"§dAverage Secret Count§7: ${(profile.dungeons.secrets.toDouble()/(mmComps + floorComps)).round(2).colorize(15.0)}",
33+
"§dAverage Secret Count§7: ${
34+
(profile.dungeons.secrets.toDouble() / (mmComps + floorComps).toDouble()).round(
35+
2
36+
).colorize(15.0)
37+
}",
3538
"§cBlood Mob Kills§7: ${profile.playerStats.bloodMobKills.commas}",
3639
"§7Spirit Pet: ${if (profile.pets.pets.any { it.type == "SPIRIT" && it.tier == "LEGENDARY" }) "§l§2Found!" else "§o§4Missing!"}",
3740
)

src/main/kotlin/com/github/subat0m1c/hatecheaters/utils/DungeonStats.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ package com.github.subat0m1c.hatecheaters.utils
22

33
import com.github.subat0m1c.hatecheaters.modules.dungeons.BetterPartyFinder.importantItems
44
import com.github.subat0m1c.hatecheaters.modules.render.ProfileViewer.statsPv
5-
import com.github.subat0m1c.hatecheaters.pvgui.v2.pages.Profile.profile
65
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.Utils.formatted
76
import com.github.subat0m1c.hatecheaters.pvgui.v2.utils.Utils.without
8-
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.capitalizeWords
97
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.chatConstructor
108
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.colorize
11-
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.colorizeNumber
12-
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.commas
139
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.secondsToMinutes
14-
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.toastMessage
15-
import com.github.subat0m1c.hatecheaters.utils.ItemUtils.witherImpactRegex
1610
import com.github.subat0m1c.hatecheaters.utils.ItemUtils.colorName
1711
import com.github.subat0m1c.hatecheaters.utils.ItemUtils.maxMagicalPower
12+
import com.github.subat0m1c.hatecheaters.utils.ItemUtils.witherImpactRegex
1813
import com.github.subat0m1c.hatecheaters.utils.apiutils.HypixelData
1914
import com.github.subat0m1c.hatecheaters.utils.apiutils.LevelUtils.cataLevel
2015
import com.github.subat0m1c.hatecheaters.utils.apiutils.LevelUtils.classAverage
@@ -83,7 +78,7 @@ object DungeonStats {
8378

8479
displayText("""
8580
§3| §bSecrets: §f${catacombs.secrets.colorize(100000)} §8: §bAverage: §f${(catacombs.secrets.toDouble()/(mmComps + floorComps)).round(2).colorize(15.0)}
86-
§3| §cBlood mobs: §f${(profileKills["watcher_summon_undead"] ?: 0) + (profileKills["master_watcher_summon_undead"] ?: 0)}
81+
§3| §cBlood mobs: §f${(profileKills["watcher_summon_undead"] ?: 0f) + (profileKills["master_watcher_summon_undead"] ?: 0f)}
8782
""".trimIndent()
8883
)
8984

src/main/kotlin/com/github/subat0m1c/hatecheaters/utils/apiutils/HypixelApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package com.github.subat0m1c.hatecheaters.utils.apiutils
22

33
import com.github.subat0m1c.hatecheaters.modules.skyblock.HateCheatersModule
44
import com.github.subat0m1c.hatecheaters.utils.LogHandler.Logger
5-
import com.github.subat0m1c.hatecheaters.utils.networkutils.WebUtils.getUUIDbyName
65
import com.github.subat0m1c.hatecheaters.utils.apiutils.HypixelData.PlayerInfo
76
import com.github.subat0m1c.hatecheaters.utils.apiutils.HypixelData.ProfilesData
87
import com.github.subat0m1c.hatecheaters.utils.networkutils.WebUtils
8+
import com.github.subat0m1c.hatecheaters.utils.networkutils.WebUtils.getUUIDbyName
99
import com.github.subat0m1c.hatecheaters.utils.networkutils.WebUtils.streamAndRead
1010
import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.withContext
1212

1313
object HypixelApi {
1414
private val url =
15-
if (HateCheatersModule.server == "default") "https://subat0mic.click/" else "https://${HateCheatersModule.server}/"
15+
if (HateCheatersModule.server == "default") "http://127.0.0.1:8000/" else "https://${HateCheatersModule.server}/"
1616

1717
private fun getServer(endpoint: EndPoint, uuid: String): String = url + endpoint.name.lowercase() + "/" + uuid
1818

src/main/kotlin/com/github/subat0m1c/hatecheaters/utils/apiutils/HypixelData.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ object HypixelData {
148148

149149
@Serializable
150150
data class PlayerStats(
151-
val kills: Map<String, Int> = emptyMap(),
152-
val deaths: Map<String, Int> = emptyMap(),
151+
val kills: Map<String, Float> = emptyMap(),
152+
val deaths: Map<String, Float> = emptyMap(),
153153
) {
154154
@Transient
155-
val bloodMobKills = (kills["watcher_summon_undead"] ?: 0) + (kills["master_watcher_summon_undead"] ?: 0)
155+
val bloodMobKills =
156+
((kills["watcher_summon_undead"] ?: 0f) + (kills["master_watcher_summon_undead"] ?: 0f)).toInt()
156157
}
157158

158159
@Serializable
@@ -415,37 +416,37 @@ object HypixelData {
415416
val timesPlayed: Map<String, Double>? = null,
416417
val experience: Double = 0.0,
417418
@SerialName("tier_completions")
418-
val tierComps: Map<String, Int> = emptyMap(),
419+
val tierComps: Map<String, Float> = emptyMap(),
419420
@SerialName("milestone_completions")
420-
val milestoneComps: Map<String, Int> = emptyMap(),
421+
val milestoneComps: Map<String, Float> = emptyMap(),
421422
@SerialName("fastest_time")
422-
val fastestTimes: Map<String, Long> = emptyMap(),
423+
val fastestTimes: Map<String, Float> = emptyMap(),
423424
@SerialName("best_runs")
424425
val bestRuns: Map<String, List<BestRun>> = emptyMap(),
425426
@SerialName("best_score")
426-
val bestScore: Map<String, Int> = emptyMap(),
427+
val bestScore: Map<String, Float> = emptyMap(),
427428
@SerialName("mobs_killed")
428-
val mobsKilled: Map<String, Int> = emptyMap(),
429+
val mobsKilled: Map<String, Float> = emptyMap(),
429430
@SerialName("most_mobs_killed")
430-
val mostMobsKilled: Map<String, Int> = emptyMap(),
431+
val mostMobsKilled: Map<String, Float> = emptyMap(),
431432
@SerialName("most_damage_berserk")
432433
val mostDamageBers: Map<String, Double> = emptyMap(),
433434
@SerialName("most_healing")
434435
val mostHealing: Map<String, Double> = emptyMap(),
435436
@SerialName("watcher_kills")
436-
val watcherKills: Map<String, Int> = emptyMap(),
437+
val watcherKills: Map<String, Float> = emptyMap(),
437438
@SerialName("highest_tier_completed")
438439
val highestTierComp: Int = 0,
439440
@SerialName("most_damage_tank")
440441
val mostDamageTank: Map<String, Double> = emptyMap(),
441442
@SerialName("most_damage_healer")
442443
val mostDamageHealer: Map<String, Double> = emptyMap(),
443444
@SerialName("fastest_time_s")
444-
val fastestTimeS: Map<String, Long> = emptyMap(),
445+
val fastestTimeS: Map<String, Double> = emptyMap(),
445446
@SerialName("most_damage_mage")
446447
val mostDamageMage: Map<String, Double> = emptyMap(),
447448
@SerialName("fastest_time_s_plus")
448-
val fastestTimeSPlus: Map<String, Long> = emptyMap(),
449+
val fastestTimeSPlus: Map<String, Double> = emptyMap(),
449450
@SerialName("most_damage_Archer")
450451
val mostDamageArcher: Map<String, Double> = emptyMap(),
451452
) {

0 commit comments

Comments
 (0)