Skip to content

Commit

Permalink
Replace BlessingToast with elementa version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Oct 14, 2023
1 parent 5daf8a5 commit 5426e6b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
55 changes: 55 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/toast/BlessingToast.kt
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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<BlessingBuff>) :
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)
}

This file was deleted.

0 comments on commit 5426e6b

Please sign in to comment.