Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
  • Loading branch information
j10a1n15 committed Jul 6, 2024
1 parent 908b8f7 commit ec24fdb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedField
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.Webhook
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.WebhookData
import me.partlysanestudios.partlysaneskies.render.gui.components.PSSItemRender
import me.partlysanestudios.partlysaneskies.utils.ChatUtils.trueUnformattedMessage
import me.partlysanestudios.partlysaneskies.utils.ImageUtils.asHex
import me.partlysanestudios.partlysaneskies.utils.StringUtils.romanNumeralToInt
import me.partlysanestudios.partlysaneskies.utils.StringUtils.toRoman
Expand All @@ -26,7 +25,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color

object CropMilestoneWebhook: Webhook() {
object CropMilestoneWebhook : Webhook() {
override val icon = PSSItemRender(ItemStack(Items.reeds), true)
.setX(CenterConstraint())
.setY(CenterConstraint())
Expand All @@ -46,8 +45,10 @@ object CropMilestoneWebhook: Webhook() {

@SubscribeEvent
fun onChatMessage(event: ClientChatReceivedEvent) {
if (!enabled) return

val message = event.message.formattedText

val (crop, oldLevel, newLevel) = regex.find(message)?.destructured ?: return
val oldLevelInt = if ("\\d+".toRegex().containsMatchIn(oldLevel)) {
oldLevel.toIntOrNull() ?: 0
Expand Down Expand Up @@ -95,10 +96,10 @@ object CropMilestoneWebhook: Webhook() {
EmbedField(
name = crop,
value = ":tada: $oldLevelString$newLevelString :tada:",
)
)
)
)
),
),
),
),
).send()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,33 @@

package me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner

import gg.essential.elementa.UIComponent
import gg.essential.elementa.components.UIBlock
import gg.essential.elementa.constraints.CenterConstraint
import gg.essential.elementa.dsl.constrain
import gg.essential.elementa.dsl.percent
import me.partlysanestudios.partlysaneskies.PartlySaneSkies
import me.partlysanestudios.partlysaneskies.config.psconfig.Toggle
import me.partlysanestudios.partlysaneskies.config.psconfig.Toggle.Companion.asBoolean
import me.partlysanestudios.partlysaneskies.config.psconfig.Toggle.Companion.asToggle
import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity
import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity.Companion.getRarityFromColorCode
import me.partlysanestudios.partlysaneskies.data.skyblockdata.SkyblockDataManager
import me.partlysanestudios.partlysaneskies.data.skyblockdata.SkyblockItem
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedData
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedField
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.Webhook
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.WebhookData
import me.partlysanestudios.partlysaneskies.render.gui.components.PSSItemRender
import me.partlysanestudios.partlysaneskies.utils.ImageUtils.asHex
import me.partlysanestudios.partlysaneskies.utils.StringUtils.colorCodeToColor
import net.minecraft.block.material.Material
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import java.awt.Color
import java.util.*

object DropWebhook: Webhook() {
override val icon get() = PSSItemRender(ItemStack(Items.gold_ingot), true).constrain {
width = 80.percent
height = 80.percent
x = CenterConstraint()
y = CenterConstraint()
}

object DropWebhook : Webhook() {
override val icon
get() = PSSItemRender(ItemStack(Items.gold_ingot), true).constrain {
width = 80.percent
height = 80.percent
x = CenterConstraint()
y = CenterConstraint()
}

override val id: String = "rngdrop"
override val name: String = "RNG Drop"
override val description: String = "Automatically send a Discord message\nwhenever a rare item has dropped"
Expand All @@ -51,10 +44,9 @@ object DropWebhook: Webhook() {
config.registerOption("send$displayName", Toggle("Send $displayName Drops", "Allow the webhook to send drops of ${displayName.lowercase()} rarity.", true))
}
}

fun trigger(drop: Drop) {
if (config.find("enabled")?.asBoolean != true) {
return
}
if (!enabled) return

if (shouldBlockDrop(drop.dropRarity)) {
return
Expand All @@ -81,13 +73,13 @@ object DropWebhook: Webhook() {
EmbedField(
name = name,
value = description,
inline = true
)
)
)
)
inline = true,
),
),
),
),
).send()
}

private fun shouldBlockDrop(rarity: Rarity) = config.find("send${rarity.displayName}")?.asBoolean != true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedField
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.Webhook
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.WebhookData
import me.partlysanestudios.partlysaneskies.render.gui.components.PSSItemRender
import me.partlysanestudios.partlysaneskies.utils.ChatUtils.trueUnformattedMessage
import me.partlysanestudios.partlysaneskies.utils.ImageUtils.asHex
import me.partlysanestudios.partlysaneskies.utils.StringUtils.romanNumeralToInt
import me.partlysanestudios.partlysaneskies.utils.StringUtils.toRoman
Expand All @@ -26,7 +25,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color

object BestiaryMilestoneWebhook: Webhook() {
object BestiaryMilestoneWebhook : Webhook() {
override val icon = PSSItemRender(ItemStack(Items.golden_sword), true)
.setX(CenterConstraint())
.setY(CenterConstraint())
Expand All @@ -49,6 +48,8 @@ object BestiaryMilestoneWebhook: Webhook() {

@SubscribeEvent
fun onChatMessage(event: ClientChatReceivedEvent) {
if (!enabled) return

val message = event.message.formattedText
if (message.contains("§lBESTIARY MILESTONE")) {
headingMessageSent = true
Expand Down Expand Up @@ -104,10 +105,10 @@ object BestiaryMilestoneWebhook: Webhook() {
EmbedField(
name = "Milestone",
value = ":tada: $oldLevelString$newLevelString :tada:",
)
)
)
)
),
),
),
),
).send()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,22 @@ import gg.essential.elementa.dsl.percent
import me.partlysanestudios.partlysaneskies.PartlySaneSkies
import me.partlysanestudios.partlysaneskies.config.psconfig.Toggle
import me.partlysanestudios.partlysaneskies.config.psconfig.Toggle.Companion.asBoolean
import me.partlysanestudios.partlysaneskies.data.cache.PetData
import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity
import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity.Companion.getRarityFromColorCode
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedData
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.EmbedField
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.Webhook
import me.partlysanestudios.partlysaneskies.features.discord.webhooks.WebhookData
import me.partlysanestudios.partlysaneskies.render.gui.components.PSSItemRender
import me.partlysanestudios.partlysaneskies.utils.ChatUtils.trueUnformattedMessage
import me.partlysanestudios.partlysaneskies.utils.ImageUtils.asHex
import me.partlysanestudios.partlysaneskies.utils.StringUtils.colorCodeToColor
import me.partlysanestudios.partlysaneskies.utils.StringUtils.romanNumeralToInt
import me.partlysanestudios.partlysaneskies.utils.StringUtils.toRoman
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color

object PetLevelUpWebhook: Webhook() {
object PetLevelUpWebhook : Webhook() {
override val icon = PSSItemRender(ItemStack(Items.bone), true)
.setX(CenterConstraint())
.setY(CenterConstraint())
Expand All @@ -56,6 +52,8 @@ object PetLevelUpWebhook: Webhook() {

@SubscribeEvent
fun onChatMessage(event: ClientChatReceivedEvent) {
if (!enabled) return

val message = event.message.formattedText

regex.find(message)?.let {
Expand Down Expand Up @@ -96,11 +94,11 @@ object PetLevelUpWebhook: Webhook() {
fields = listOf(
EmbedField(
name = "${rarity.displayName} $name",
value = ":tada: $levelString :tada:"
)
)
)
)
value = ":tada: $levelString :tada:",
),
),
),
),
).send()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.awt.Color

object SkillUpgradeWebhook: Webhook() {
object SkillUpgradeWebhook : Webhook() {
override val icon = PSSItemRender(ItemStack(Items.diamond_pickaxe), true)
.setX(CenterConstraint())
.setY(CenterConstraint())
Expand All @@ -43,9 +43,11 @@ object SkillUpgradeWebhook: Webhook() {
}

val regex = "SKILL LEVEL UP (\\w+) (\\w+)➜(\\w+)".toRegex()

@SubscribeEvent
fun onChatMessage(event: ClientChatReceivedEvent) {
if (!enabled) return

val message = event.trueUnformattedMessage

val (skill, oldLevel, newLevel) = regex.find(message)?.destructured ?: return
Expand Down Expand Up @@ -96,11 +98,11 @@ object SkillUpgradeWebhook: Webhook() {
EmbedField(
name = skill,
value = ":tada: $oldLevelString$newLevelString :tada:",
inline = true
)
)
)
)
inline = true,
),
),
),
),
).send()
}
}
}

0 comments on commit ec24fdb

Please sign in to comment.