Skip to content

Commit

Permalink
Feature: /shtps command (#1961)
Browse files Browse the repository at this point in the history
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 31, 2024
1 parent 31f9e29 commit c834fbb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import at.hannibal2.skyhanni.features.minion.MinionFeatures
import at.hannibal2.skyhanni.features.misc.CollectionTracker
import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.features.misc.TpsCounter
import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager
import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker
import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures
Expand Down Expand Up @@ -355,6 +356,10 @@ object Commands {
"shcolors",
"Prints a list of all Minecraft color & formatting codes in chat.",
) { ColorFormattingHelper.printColorCodeList() }
registerCommand(
"shtps",
"Informs in chat about the server ticks per second (TPS)."
) { TpsCounter.tpsCommand() }
}

private fun usersBugFix() {
Expand Down Expand Up @@ -470,7 +475,10 @@ object Commands {
"shtestisland",
"Sets the current skyblock island for testing purposes.",
) { SkyBlockIslandTest.onCommand(it) }
registerCommand("shdebugprice", "Debug different price sources for an item.") { ItemPriceUtils.debugItemPrice(it) }
registerCommand(
"shdebugprice",
"Debug different price sources for an item."
) { ItemPriceUtils.debugItemPrice(it) }
registerCommand(
"shdebugscoreboard",
"Monitors the scoreboard changes: Prints the raw scoreboard lines in the console after each update, with time since last update.",
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
Expand All @@ -32,7 +33,7 @@ object TpsCounter {
init {
// TODO use SecondPassedEvent + passedSince
fixedRateTimer(name = "skyhanni-tps-counter-seconds", period = 1000L) {
if (!isEnabled()) return@fixedRateTimer
if (!LorenzUtils.inSkyBlock) return@fixedRateTimer
if (packetsFromLastSecond == 0) return@fixedRateTimer

if (ignoreFirstTicks > 0) {
Expand Down Expand Up @@ -62,7 +63,7 @@ object TpsCounter {
}
// TODO use DelayedRun
fixedRateTimer(name = "skyhanni-tps-counter-ticks", period = 50L) {
if (!isEnabled()) return@fixedRateTimer
if (!LorenzUtils.inSkyBlock) return@fixedRateTimer

if (hasPacketReceived) {
hasPacketReceived = false
Expand All @@ -71,6 +72,10 @@ object TpsCounter {
}
}

fun tpsCommand() {
ChatUtils.chat(display)
}

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
tpsList.clear()
Expand All @@ -81,7 +86,7 @@ object TpsCounter {

@HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true)
fun onPacketReceive(event: PacketReceivedEvent) {
if (!config.tpsDisplay) return
if (!LorenzUtils.inSkyBlock) return
hasPacketReceived = true
}

Expand Down

0 comments on commit c834fbb

Please sign in to comment.