Skip to content

Commit

Permalink
create titles only from TitleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed May 14, 2024
1 parent 11394a8 commit 48018b6
Show file tree
Hide file tree
Showing 37 changed files with 98 additions and 79 deletions.
10 changes: 5 additions & 5 deletions src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import net.minecraft.network.play.server.S45PacketTitle
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.opengl.GL11
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

object TitleManager {
Expand All @@ -25,7 +24,7 @@ object TitleManager {
private var heightModifier = 1.8
private var fontSizeModifier = 4f

fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) {
fun sendTitle(text: String, duration: Duration, height: Double = 1.8, fontSize: Float = 4f) {
originalText = text
display = "§f$text"
endTime = SimpleTimeMark.now() + duration
Expand All @@ -35,7 +34,7 @@ object TitleManager {

fun optionalResetTitle(condition: (String) -> Boolean) {
if (condition(originalText)) {
sendTitle("", 1.milliseconds, 1.8, 4f)
endTime = SimpleTimeMark.farPast()
}
}

Expand Down Expand Up @@ -79,12 +78,13 @@ object TitleManager {
val height = scaledResolution.scaledHeight

GlStateManager.enableBlend()
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0)
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO)
val renderer = Minecraft.getMinecraft().fontRendererObj

GlStateManager.pushMatrix()
GlStateManager.translate((width / 2).toFloat(), (height / heightModifier).toFloat(), 3.0f)
GlStateManager.scale(fontSizeModifier, fontSizeModifier, fontSizeModifier)
GlStateManager.scale(fontSizeModifier, fontSizeModifier, 1f)
// TODO dont use neu text method
TextRenderUtils.drawStringCenteredScaledMaxWidth(display, renderer, 0f, 0f, true, 75, 0)
GlStateManager.popMatrix()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.bingo

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.data.item.SkyhanniItems
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
Expand All @@ -18,8 +19,8 @@ import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getCachedIngredients
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.JsonArray
Expand Down Expand Up @@ -249,7 +250,7 @@ object MinionCraftHelper {
private fun notify(minionName: String) {
if (alreadyNotified.contains(minionName)) return

LorenzUtils.sendTitle("Can craft $minionName", 3.seconds)
TitleManager.sendTitle("Can craft $minionName", 3.seconds)
alreadyNotified.add(minionName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package at.hannibal2.skyhanni.features.dungeon

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacks
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.data.item.SkyhanniItems
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -48,7 +48,7 @@ object DungeonArchitectFeatures {
{ HypixelCommands.getFromSacks("ARCHITECT_FIRST_DRAFT", 1) },
prefix = false
)
LorenzUtils.sendTitle("§c§lPUZZLE FAILED!", 3.seconds)
TitleManager.sendTitle("§c§lPUZZLE FAILED!", 3.seconds)
event.blockedReason = "puzzle_fail"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.EntityMovementData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.Mayor
import at.hannibal2.skyhanni.data.MayorAPI.currentMayor
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.BlockClickEvent
import at.hannibal2.skyhanni.events.BurrowDetectEvent
import at.hannibal2.skyhanni.events.BurrowDugEvent
Expand All @@ -23,7 +24,6 @@ import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
Expand Down Expand Up @@ -307,7 +307,7 @@ object GriffinBurrowHelper {
} else ""
if (lastTitleSentTime.passedSince() > 2.seconds) {
lastTitleSentTime = SimpleTimeMark.now()
LorenzUtils.sendTitle(text + keybindSuffix, 2.seconds, fontSize = 3f)
TitleManager.sendTitle(text + keybindSuffix, 2.seconds, fontSize = 3f)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package at.hannibal2.skyhanni.features.event.diana

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
Expand All @@ -21,7 +21,7 @@ object GriffinPetWarning {

if (!DianaAPI.hasGriffinPet() && lastWarnTime.passedSince() > 30.seconds) {
lastWarnTime = SimpleTimeMark.now()
LorenzUtils.sendTitle("§cGriffin Pet!", 3.seconds)
TitleManager.sendTitle("§cGriffin Pet!", 3.seconds)
ChatUtils.chat("Reminder to use a Griffin pet for Mythological Ritual!")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.event.diana

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
Expand All @@ -13,7 +14,6 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.hasGroup
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
Expand Down Expand Up @@ -294,7 +294,7 @@ object InquisitorWaypointShare {
if (!waypoints.containsKey(name)) {
ChatUtils.chat("$displayName §l§efound an inquisitor at §l§c${x.toInt()} ${y.toInt()} ${z.toInt()}!")
if (name != McPlayer.name) {
LorenzUtils.sendTitle("§dINQUISITOR §efrom §b$displayName", 5.seconds)
TitleManager.sendTitle("§dINQUISITOR §efrom §b$displayName", 5.seconds)
McSound.BEEP.play()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.data.item.SkyhanniItems
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
Expand Down Expand Up @@ -226,7 +227,7 @@ object HoppityEggLocator {
}

if (maxLineDistance.isEmpty()) {
LorenzUtils.sendTitle("§cNo eggs found, try getting closer", 2.seconds)
TitleManager.sendTitle("§cNo eggs found, try getting closer", 2.seconds)
return
}
secondPos = maxLineDistance.first().nearestPointOnLine(firstPos, secondPos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
Expand All @@ -13,12 +14,12 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.now
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.datetime.SkyBlockTime
import at.hannibal2.skyhanni.utils.datetime.TimeUtils.format
Expand Down Expand Up @@ -153,7 +154,7 @@ object HoppityEggsManager {
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.showClaimedEggs) return
if (isBuzy()) return
if (isBusy()) return
if (!ChocolateFactoryAPI.isHoppityEvent()) return

val displayList = HoppityEggType.entries
Expand Down Expand Up @@ -185,17 +186,17 @@ object HoppityEggsManager {

private fun warn() {
if (!config.warnUnclaimedEggs) return
if (isBuzy()) return
if (isBusy()) return
if (lastWarnTime.passedSince() < 30.seconds) return

lastWarnTime = now()
val amount = HoppityEggType.entries.size
ChatUtils.chat("All $amount Hoppity Eggs are ready to be found.!")
LorenzUtils.sendTitle("§e$amount Hoppity Eggs!", 5.seconds)
TitleManager.sendTitle("§e$amount Hoppity Eggs!", 5.seconds)
McSound.PLING.play()
}

private fun isBuzy() = ReminderUtils.isBusy(config.showDuringContest)
private fun isBusy() = ReminderUtils.isBusy(config.showDuringContest)

@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI.isBait
Expand Down Expand Up @@ -78,13 +79,13 @@ object FishingBaitWarnings {

private fun showBaitChangeWarning(before: String, after: String) {
McSound.CLICK.play()
LorenzUtils.sendTitle("§eBait changed!", 2.seconds)
TitleManager.sendTitle("§eBait changed!", 2.seconds)
ChatUtils.chat("Fishing Bait changed: $before §e-> $after")
}

private fun showNoBaitWarning() {
McSound.ERROR.play()
LorenzUtils.sendTitle("§cNo bait is used!", 2.seconds)
TitleManager.sendTitle("§cNo bait is used!", 2.seconds)
ChatUtils.chat("You're not using any fishing baits!")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
Expand Down Expand Up @@ -75,7 +76,7 @@ object FishingTimer {

if (inHollows && newCount >= 60 && config.wormLimitAlert) {
McSound.BEEP.play()
LorenzUtils.sendTitle("§cWORM CAP FULL!!!", 2.seconds)
TitleManager.sendTitle("§cWORM CAP FULL!!!", 2.seconds)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent
Expand Down Expand Up @@ -58,7 +59,7 @@ object SeaCreatureFeatures {
if (config.alertOtherCatches && lastRareCatch.passedSince() > 1.seconds) {
val creature = SeaCreatureManager.allFishingMobs[creatureType.nametag]
val text = "${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!"
LorenzUtils.sendTitle(text, 1.5.seconds, 3.6, 7f)
TitleManager.sendTitle(text, 1.5.seconds, 3.6, 7f)
if (config.playSound) McSound.BEEP.play()
}
}
Expand All @@ -70,7 +71,7 @@ object SeaCreatureFeatures {
if (!config.alertOwnCatches) return

if (event.seaCreature.rare) {
LorenzUtils.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 2.8, 7f)
TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 2.8, 7f)
if (config.playSound) McSound.BEEP.play()
lastRareCatch = SimpleTimeMark.now()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.fishing

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.features.fishing.TotemOfCorruptionConfig.OutlineType
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
Expand All @@ -12,12 +13,11 @@ import at.hannibal2.skyhanni.utils.ColourUtils.toChromaColour
import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sendTitle
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereWireframeInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.datetime.TimeUnit
import at.hannibal2.skyhanni.utils.datetime.TimeUtils.format
Expand Down Expand Up @@ -156,7 +156,7 @@ object TotemOfCorruption {
val timeToWarn = config.warnWhenAboutToExpire.seconds
if (timeToWarn > 0.seconds && timeRemaining == timeToWarn) {
McSound.PLING.play()
sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds)
TitleManager.sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds)
}
Totem(totem.getLorenzVec(), timeRemaining, owner)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.enums.OutsideSbFeature
import at.hannibal2.skyhanni.config.features.garden.NextJacobContestConfig.ShareContestsEntry
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
Expand All @@ -21,11 +22,11 @@ import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
Expand Down Expand Up @@ -427,7 +428,7 @@ object GardenNextJacobContest {
lastWarningTime = SimpleTimeMark.now()
val cropText = crops.joinToString("§7, ") { (if (it == boostedCrop) "§6" else "§a") + it.cropName }
ChatUtils.chat("Next farming contest: $cropText")
LorenzUtils.sendTitle("§eFarming Contest!", 5.seconds)
TitleManager.sendTitle("§eFarming Contest!", 5.seconds)
McSound.BEEP.play()

val cropTextNoColor = crops.joinToString(", ") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.garden

import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.TitleManager
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
Expand Down Expand Up @@ -155,7 +156,7 @@ object GardenOptimalSpeed {
if (System.currentTimeMillis() < lastWarnTime + 20_000) return

lastWarnTime = System.currentTimeMillis()
LorenzUtils.sendTitle("§cWrong speed!", 3.seconds)
TitleManager.sendTitle("§cWrong speed!", 3.seconds)
cropInHand?.let {
var text = "Wrong speed for ${it.cropName}: §f$currentSpeed"
if (sneaking) text += " §7[Sneaking]"
Expand Down
Loading

0 comments on commit 48018b6

Please sign in to comment.