diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/SpamHider.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/SpamHider.kt
index 624bc5c7e..8d81d7a82 100644
--- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/SpamHider.kt
+++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/handlers/SpamHider.kt
@@ -36,8 +36,8 @@ import gg.skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextShadow
import gg.skytils.skytilsmod.utils.graphics.colors.CommonColors
import gg.skytils.skytilsmod.utils.startsWithAny
import gg.skytils.skytilsmod.utils.stripControlCodes
+import gg.skytils.skytilsmod.utils.toast.BlessingToast
import gg.skytils.skytilsmod.utils.toasts.*
-import gg.skytils.skytilsmod.utils.toasts.BlessingToast.BlessingBuff
import kotlinx.serialization.*
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
@@ -347,17 +347,14 @@ object SpamHider : PersistentSave(File(Skytils.modDir, "spamhider.json")) {
val buffs = match.groupValues.mapNotNull { blessingGroup ->
Regexs.BLESSINGBUFF.pattern.matchEntire(blessingGroup)
}.map { blessingBuffMatch ->
- BlessingBuff(
+ BlessingToast.BlessingBuff(
blessingBuffMatch.groups["buff1"]?.value ?: return@let,
blessingBuffMatch.groups["symbol1"]?.value ?: return@let
)
}
- if (lastBlessingType != "") GuiManager.toastGui.add(
- BlessingToast(
- lastBlessingType,
- buffs
- )
- )
+ if (lastBlessingType != "") {
+ GuiManager.addToast(BlessingToast(lastBlessingType, buffs))
+ }
cancelChatPacket(event, false)
}
}
diff --git a/src/main/kotlin/gg/skytils/skytilsmod/utils/toast/BlessingToast.kt b/src/main/kotlin/gg/skytils/skytilsmod/utils/toast/BlessingToast.kt
new file mode 100644
index 000000000..b373aab11
--- /dev/null
+++ b/src/main/kotlin/gg/skytils/skytilsmod/utils/toast/BlessingToast.kt
@@ -0,0 +1,55 @@
+/*
+ * Skytils - Hypixel Skyblock Quality of Life Mod
+ * Copyright (C) 2020-2023 Skytils
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package gg.skytils.skytilsmod.utils.toast
+
+import gg.essential.elementa.components.UIImage
+import gg.essential.universal.ChatColor
+import net.minecraft.util.EnumChatFormatting
+
+class BlessingToast(blessingType: String, buffs: List) :
+ Toast(
+ title = when (blessingType) {
+ "life" -> ChatColor.RED
+ "power" -> ChatColor.LIGHT_PURPLE
+ "stone" -> ChatColor.GREEN
+ "wisdom" -> ChatColor.AQUA
+ "time" -> ChatColor.GOLD
+ else -> ChatColor.GOLD
+ } +
+ "§l${blessingType.uppercase()} BLESSING!"
+ , UIImage.ofResource("/assets/skytils/toasts/blessings/${blessingType}.png"))
+{
+ init {
+ subtextState.set(
+ buffs.joinToString(separator = " ") { buff ->
+ val color: String = when (buff.symbol) {
+ "❤", "❁" -> EnumChatFormatting.RED.toString()
+ "✎" -> EnumChatFormatting.AQUA.toString()
+ "❈", "HP" -> EnumChatFormatting.GREEN.toString()
+ "✦" -> EnumChatFormatting.WHITE.toString()
+ "☠" -> EnumChatFormatting.BLUE.toString()
+ else -> EnumChatFormatting.GRAY.toString()
+ }
+ "$color${buff.amount}${buff.symbol}"
+ }
+ )
+ }
+
+ class BlessingBuff(val amount: String, val symbol: String)
+}
\ No newline at end of file
diff --git a/src/main/kotlin/gg/skytils/skytilsmod/utils/toasts/BlessingToast.kt b/src/main/kotlin/gg/skytils/skytilsmod/utils/toasts/BlessingToast.kt
deleted file mode 100644
index 0324be6d7..000000000
--- a/src/main/kotlin/gg/skytils/skytilsmod/utils/toasts/BlessingToast.kt
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Skytils - Hypixel Skyblock Quality of Life Mod
- * Copyright (C) 2020-2023 Skytils
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package gg.skytils.skytilsmod.utils.toasts
-
-import gg.skytils.skytilsmod.Skytils
-import gg.skytils.skytilsmod.utils.RenderUtil
-import net.minecraft.client.gui.Gui
-import net.minecraft.client.renderer.GLAllocation
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraft.client.renderer.RenderHelper
-import net.minecraft.util.EnumChatFormatting
-import net.minecraft.util.ResourceLocation
-
-class BlessingToast(blessing: String, private val buffs: List) : IToast {
- private val buffer = GLAllocation.createDirectFloatBuffer(16)
- private val maxDrawTime: Long = Skytils.config.toastTime.toLong()
- private val blessing: Blessing? = Blessing.fromName(blessing)
- override fun draw(toastGui: GuiToast, delta: Long): IToast.Visibility {
- toastGui.mc.textureManager.bindTexture(TEXTURE)
- GlStateManager.color(1.0f, 1.0f, 1.0f)
- Gui.drawModalRectWithCustomSizedTexture(0, 0, 0f, 0f, 160, 32, 160f, 32f)
- RenderHelper.disableStandardItemLighting()
- toastGui.mc.fontRendererObj.drawStringWithShadow(blessing!!.formattedName, 30f, 7f, 16777215)
- val buffStats = StringBuilder()
- for (buff in buffs) {
- val color: String = when (buff.symbol) {
- "❤", "❁" -> EnumChatFormatting.RED.toString()
- "✎" -> EnumChatFormatting.AQUA.toString()
- "❈", "HP" -> EnumChatFormatting.GREEN.toString()
- "✦" -> EnumChatFormatting.WHITE.toString()
- "☠" -> EnumChatFormatting.BLUE.toString()
- else -> EnumChatFormatting.GRAY.toString()
- }
- buffStats.append(color).append(buff.amount).append(buff.symbol).append(" ")
- }
- GuiToast.drawSubline(toastGui, delta, 0L, maxDrawTime, buffer, buffStats.toString(), false)
- RenderHelper.enableGUIStandardItemLighting()
- RenderUtil.renderTexture(blessing.texture, 8, 8)
- GlStateManager.disableLighting()
- return if (delta >= maxDrawTime) IToast.Visibility.HIDE else IToast.Visibility.SHOW
- }
-
- private enum class Blessing(val blessingName: String, location: String, val formattedName: String) {
- LIFE("life", "skytils:toasts/blessings/life.png", "§c§lLIFE BLESSING!"), POWER(
- "power",
- "skytils:toasts/blessings/power.png",
- "§5§lPOWER BLESSING!"
- ),
- STONE("stone", "skytils:toasts/blessings/stone.png", "§a§lSTONE BLESSING!"), WISDOM(
- "wisdom",
- "skytils:toasts/blessings/wisdom.png",
- "§b§lWISDOM BLESSING!"
- ),
- TIME("time", "skytils:toasts/blessings/time.png", "§6§lTIME BLESSING!");
-
- val texture: ResourceLocation = ResourceLocation(location)
-
- companion object {
- fun fromName(name: String): Blessing? {
- for (type in values()) {
- if (type.blessingName == name) return type
- }
- return null
- }
- }
-
- }
-
- class BlessingBuff(var amount: String, var symbol: String)
- companion object {
- private val TEXTURE = ResourceLocation("skytils:gui/toast.png")
- }
-
-}
\ No newline at end of file