diff options
author | IlmarsXd <ilmars500@gmail.com> | 2023-03-21 17:37:12 +0200 |
---|---|---|
committer | IlmarsXd <ilmars500@gmail.com> | 2023-03-21 17:37:12 +0200 |
commit | 623f260e2f1d586336fca13dc86bf2ffb0c6565c (patch) | |
tree | d54f367541619b80ae1863f5acb3d9f09de7bada /src/main/kotlin/dulkirmod/features | |
parent | e7723d5ff52da94eb65992b5bdd9c5bb316d5959 (diff) | |
download | DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.tar.gz DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.tar.bz2 DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.zip |
refactor modules
Diffstat (limited to 'src/main/kotlin/dulkirmod/features')
11 files changed, 261 insertions, 271 deletions
diff --git a/src/main/kotlin/dulkirmod/features/AlarmClock.kt b/src/main/kotlin/dulkirmod/features/AlarmClock.kt index 0d3f51c..f4c11d4 100644 --- a/src/main/kotlin/dulkirmod/features/AlarmClock.kt +++ b/src/main/kotlin/dulkirmod/features/AlarmClock.kt @@ -1,9 +1,9 @@ package dulkirmod.features -import dulkirmod.DulkirMod import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.Config import dulkirmod.utils.ScoreBoardUtils +import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils var lastUpdate: Long = 0 @@ -19,7 +19,7 @@ fun alarmClock() { if (Config.notifyZombieVillager && l.contains("8:00pm") && (currTime - lastUpdate) > 15000) { lastUpdate = currTime val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Zombie Villager", 5000) + TitleUtils.drawStringForTime("${color}Zombie Villager", 5000) if (Config.bestiaryAlertSounds) mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f) } @@ -27,7 +27,7 @@ fun alarmClock() { else if (Config.notifyGhast && l.contains("9:00pm") && (currTime - lastUpdate) > 15000) { lastUpdate = currTime val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Ghast", 5000) + TitleUtils.drawStringForTime("${color}Ghast", 5000) if (Config.bestiaryAlertSounds) mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f) } diff --git a/src/main/kotlin/dulkirmod/features/ArachneTimer.kt b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt index 5c97c86..4cb63f9 100644 --- a/src/main/kotlin/dulkirmod/features/ArachneTimer.kt +++ b/src/main/kotlin/dulkirmod/features/ArachneTimer.kt @@ -10,7 +10,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ArachneTimer { +object ArachneTimer { private var startmillis: Long = -1 private var endmillis: Long = -1 private var spawnmillis: Long = -1 diff --git a/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt index 27225ff..589c046 100644 --- a/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt +++ b/src/main/kotlin/dulkirmod/features/BrokenHypeNotif.kt @@ -1,9 +1,9 @@ package dulkirmod.features -import dulkirmod.DulkirMod import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.Config import dulkirmod.utils.TabListUtils +import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound @@ -61,7 +61,7 @@ fun brokenHypeNotif() { if (oldKill != kill && oldChampionXp == championXp && TabListUtils.area != "Private Island") { mc.thePlayer.playSound("random.anvil_land", 1f * Config.bestiaryNotifVol, 0f) val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Hype Broken", 5000) + TitleUtils.drawStringForTime("${color}Hype Broken", 5000) } // update item regardless of whether it is bugged or not oldKill = kill diff --git a/src/main/kotlin/dulkirmod/features/Croesus.kt b/src/main/kotlin/dulkirmod/features/Croesus.kt index 36bf3ee..ea8b022 100644 --- a/src/main/kotlin/dulkirmod/features/Croesus.kt +++ b/src/main/kotlin/dulkirmod/features/Croesus.kt @@ -9,75 +9,76 @@ import net.minecraft.nbt.NBTTagList import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -class Croesus { - - var lastGuiOpenEvent: Long = 0 - var lastPageNumber = 1 - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - val lastInCroesus = inCroesusBool - var pageNumber = 1 - - if (!Config.hideOpenedChests) return - if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { - inCroesusBool = false - return - } - inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") - - if (inCroesusBool) { - pageNumber = findPageNumber() - } - - // weird way of detecting page turn - if(lastPageNumber != pageNumber) - lastGuiOpenEvent = System.currentTimeMillis() - - if (inCroesusBool && !lastInCroesus) { - lastGuiOpenEvent = System.currentTimeMillis() - } - - if (inCroesusBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { - for (i in 9..44) { - boolArray[i - 9] = false - val slotIn = mc.thePlayer.openContainer.getSlot(i) - - if (slotIn.stack == null) continue - val stack = slotIn.stack - - val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue - for (j in 0 until tagList.tagCount()) { - if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true - } - } - } - } - - private fun findPageNumber(): Int { - val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber - - val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1 - - if (stackPrevLore.getStringTagAt(0).contains("1")) return 2 - - return 3 - } - - companion object { - var inCroesusBool: Boolean = false - var boolArray = BooleanArray(36) { false } - - fun inCroesus(): Boolean { - return inCroesusBool - } - - fun isChestOpened(slotIn: Slot): Boolean { - if (!inCroesusBool) return false - if (slotIn.inventory == mc.thePlayer.inventory) return false - val slotindex = slotIn.slotIndex - if (slotindex !in 9..44) return false - return boolArray[slotindex - 9] - } - } +object Croesus { + + var lastGuiOpenEvent: Long = 0 + var lastPageNumber = 1 + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val lastInCroesus = inCroesusBool + var pageNumber = 1 + + if (!Config.hideOpenedChests) return + if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { + inCroesusBool = false + return + } + inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") + + if (inCroesusBool) { + pageNumber = findPageNumber() + } + + // weird way of detecting page turn + if (lastPageNumber != pageNumber) + lastGuiOpenEvent = System.currentTimeMillis() + + if (inCroesusBool && !lastInCroesus) { + lastGuiOpenEvent = System.currentTimeMillis() + } + + if (inCroesusBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { + for (i in 9..44) { + boolArray[i - 9] = false + val slotIn = mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + + val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue + for (j in 0 until tagList.tagCount()) { + if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true + } + } + } + } + + private fun findPageNumber(): Int { + val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber + + val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1 + + if (stackPrevLore.getStringTagAt(0).contains("1")) return 2 + + return 3 + } + + var inCroesusBool: Boolean = false + + var boolArray = BooleanArray(36) { false } + + @JvmStatic + fun inCroesus(): Boolean { + return inCroesusBool + } + + @JvmStatic + fun isChestOpened(slotIn: Slot): Boolean { + if (!inCroesusBool) return false + if (slotIn.inventory == mc.thePlayer.inventory) return false + val slotindex = slotIn.slotIndex + if (slotindex !in 9..44) return false + return boolArray[slotindex - 9] + } }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/DragonTimer.kt b/src/main/kotlin/dulkirmod/features/DragonTimer.kt index 459c291..a03bea0 100644 --- a/src/main/kotlin/dulkirmod/features/DragonTimer.kt +++ b/src/main/kotlin/dulkirmod/features/DragonTimer.kt @@ -12,125 +12,119 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color import kotlin.math.max -class DragonTimer { - data class Dragon (val color: String, val pos: Vec3, var spawnTime: Long) - - companion object { - var dragons = arrayOf( - Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), - Dragon("red", Vec3(27.0, 18.0, 56.0), 0), - Dragon("green", Vec3(26.0, 18.0, 95.0), 0), - Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), - Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) - ) - } - - /** - * Called from within the MixinWorld Class - */ - fun handleNewParticle(particleID: Int, xCoord: Double, yCoord: Double, zCoord: Double) { - if (particleID != 26) return - // if (!TabListUtils.isInDungeons) return - if (!Config.dragonTimer) return - //TextUtils.info("§6particle id ${particleID} 175 = $p_175720_2_") - - val particleVec = Vec3(xCoord, yCoord, zCoord) - for (d in dragons) { - if (inRangeOf(d.color, particleVec)) { - if (System.currentTimeMillis() - d.spawnTime > 10000) { - d.spawnTime = System.currentTimeMillis() - } - } - } - } - - @SubscribeEvent - fun onRenderWorld(event: RenderWorldLastEvent) { - val curTime: Long = System.currentTimeMillis() - // for some reason this really doesn't like the syntax for (d in dragons) - for (i in 0..4) { - // d.spawnTime + 5000 is when dragon actually spawn - val d = dragons[i] - if (d.spawnTime + 5000 > curTime) { - if (isDead(d.color)) - return - val timeUntilSpawn: Float = ((d.spawnTime + 5000 - curTime).toFloat() / 1000f) - val color = when { - timeUntilSpawn <= 1 -> "§c" - timeUntilSpawn <= 3 -> "§e" - else -> "§a" - } - val playerVec = mc.thePlayer.positionVector - val scale = max(1f, playerVec.distanceTo(d.pos).toFloat()/5f) - WorldRenderUtils.renderString(d.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", - false, scale, true) - } - } - } - - /** - * true = dead - */ - private fun isDead(color:String): Boolean { - val world: World = mc.theWorld - val pos = when (color) { - "orange" -> BlockPos(90, 21, 56) - "red" -> BlockPos(20,22,59) - "green" -> BlockPos(22,21,94) - "purple" -> BlockPos(56,20,130) - "blue" -> BlockPos(89,21,94) - else -> BlockPos(0,0,0) - } - return world.isAirBlock(pos) - } - private fun inRangeOf(color: String, pos: Vec3): Boolean { - when (color) { - "orange" -> { - return (pos.xCoord.toInt() in 82..88 - && pos.yCoord.toInt() in 15..22 - && pos.zCoord.toInt() in 53..59) - } - "red" -> { - return (pos.xCoord.toInt() in 24..30 - && pos.yCoord.toInt() in 15..22 - && pos.zCoord.toInt() in 56..62) - } - "green" -> { - return (pos.xCoord.toInt() in 23..29 - && pos.yCoord.toInt() in 15..22 - && pos.zCoord.toInt() in 91..97) - } - "purple" -> { - return (pos.xCoord.toInt() in 53..59 - && pos.yCoord.toInt() in 15..22 - && pos.zCoord.toInt() in 122..128) - } - "blue" -> { - return (pos.xCoord.toInt() in 82..88 - && pos.yCoord.toInt() in 15..22 - && pos.zCoord.toInt() in 91..97) - } - else -> { - return false - } - } - } - - @SubscribeEvent - fun dragonBoxes(event: RenderWorldLastEvent) { - if (!Config.dragonKillBox) return - if (!ScoreBoardUtils.isInM7) return - if (mc.thePlayer.positionVector.yCoord > 45) return - // Blue - WorldRenderUtils.drawCustomBox(71.5, 25.0, 16.0, 10.0, 82.5, 25.0, Color(0, 170, 170, 255), 3f, phase = false) - // Purple - WorldRenderUtils.drawCustomBox(45.5, 23.0, 13.0, 10.0, 113.5, 23.0, Color(170, 0, 170, 255), 3f, phase = false) - // Green - WorldRenderUtils.drawCustomBox(7.0, 30.0, 8.0, 20.0, 80.0, 30.0, Color(85, 255, 85, 255), 3f, phase = false) - // Red - WorldRenderUtils.drawCustomBox(14.5, 25.0, 13.0, 15.0, 45.5, 25.0, Color(255, 85, 85, 255), 3f, phase = false) - // Orange - WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 30.0, Color(255, 170, 0, 255), 3f, phase = false) - } +object DragonTimer { + data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) + + private val dragons = arrayOf( + Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), + Dragon("red", Vec3(27.0, 18.0, 56.0), 0), + Dragon("green", Vec3(26.0, 18.0, 95.0), 0), + Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), + Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) + ) + + /** + * Called from within the MixinWorld Class + */ + fun handleNewParticle(pID: Int, x: Double, y: Double, z: Double) { + if (!Config.dragonTimer) return + + if (pID != 26) return + // if (!TabListUtils.isInDungeons) return + //TextUtils.info("§6particle id ${particleID} 175 = $p_175720_2_") + + val particleVec = Vec3(x, y, z) + dragons.forEach { + if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach + it.spawnTime = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + renderDragonBoxes() + + if (!Config.dragonTimer) return + val curTime = System.currentTimeMillis() + dragons.forEach { + if (it.spawnTime + 5000 < curTime || isDead(it.color)) return@forEach + val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f + val color = when { + timeUntilSpawn <= 1 -> "§c" + timeUntilSpawn <= 3 -> "§e" + else -> "§a" + } + + val scale = max(1.0, mc.thePlayer.positionVector.distanceTo(it.pos) / 5.0).toFloat() + + WorldRenderUtils.renderString( + it.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", false, scale, true + ) + } + } + + /** + * true = dead + */ + private fun isDead(color: String): Boolean { + val world: World = mc.theWorld + val pos = when (color) { + "orange" -> BlockPos(90, 21, 56) + "red" -> BlockPos(20, 22, 59) + "green" -> BlockPos(22, 21, 94) + "purple" -> BlockPos(56, 20, 130) + "blue" -> BlockPos(89, 21, 94) + else -> BlockPos(0, 0, 0) + } + return world.isAirBlock(pos) + } + + private fun inRangeOf(color: String, pos: Vec3): Boolean { + val x = pos.xCoord.toInt() + val y = pos.yCoord.toInt() + val z = pos.zCoord.toInt() + + return when (color) { + "orange" -> { + x in 82..88 && y in 15..22 && z in 53..59 + } + + "red" -> { + x in 24..30 && y in 15..22 && z in 56..62 + } + + "green" -> { + x in 23..29 && y in 15..22 && z in 91..97 + } + + "purple" -> { + x in 53..59 && y in 15..22 && z in 122..128 + } + + "blue" -> { + x in 82..88 && y in 15..22 && z in 91..97 + } + + else -> { + false + } + } + } + + fun renderDragonBoxes() { + if (!Config.dragonKillBox) return + if (!ScoreBoardUtils.isInM7) return + if (mc.thePlayer.positionVector.yCoord > 45) return + // Blue + WorldRenderUtils.drawCustomBox(71.5, 25.0, 16.0, 10.0, 82.5, 25.0, Color(0, 170, 170, 255), 3f, phase = false) + // Purple + WorldRenderUtils.drawCustomBox(45.5, 23.0, 13.0, 10.0, 113.5, 23.0, Color(170, 0, 170, 255), 3f, phase = false) + // Green + WorldRenderUtils.drawCustomBox(7.0, 30.0, 8.0, 20.0, 80.0, 30.0, Color(85, 255, 85, 255), 3f, phase = false) + // Red + WorldRenderUtils.drawCustomBox(14.5, 25.0, 13.0, 15.0, 45.5, 25.0, Color(255, 85, 85, 255), 3f, phase = false) + // Orange + WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 30.0, Color(255, 170, 0, 255), 3f, phase = false) + } } diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt index d1be829..9c54c46 100644 --- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt +++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt @@ -9,52 +9,47 @@ import net.minecraft.inventory.Slot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent -class DungeonLeap { - - - private var lastGuiOpenEvent: Long = 0 - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - val lastInLeap = inLeapMenuBool - - if (!Config.highlightLeap) return - if (mc.currentScreen == null || mc.currentScreen !is GuiChest) { - inLeapMenuBool = false - return - } - inLeapMenuBool = (ContainerNameUtil.currentGuiChestName == "Spirit Leap") - - if (inLeapMenuBool && !lastInLeap) { - lastGuiOpenEvent = System.currentTimeMillis() - } - - if (inLeapMenuBool && System.currentTimeMillis() - lastGuiOpenEvent < 300) { - for (i in 11..15) { - boolArray[i - 11] = false - val slotIn = mc.thePlayer.openContainer.getSlot(i) - - if (slotIn.stack == null) continue - val stack = slotIn.stack - if (Utils.stripColorCodes(stack.displayName).lowercase() == Config.highlightLeapName.lowercase()) boolArray[i - 11] = true - } - } - } - - companion object { - var inLeapMenuBool: Boolean = false - var boolArray = BooleanArray(5) { false } - - fun inLeapMenu(): Boolean { - return inLeapMenuBool - } - - fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { - if (!inLeapMenuBool) return false - if (slotIn.inventory == mc.thePlayer.inventory) return false - val slotIndex = slotIn.slotIndex - if (slotIndex !in 11..15) return false - return boolArray[slotIndex - 11] - } - } +object DungeonLeap { + @JvmField + var inLeapMenu = false + var leapPlayers = BooleanArray(5) { false } + + private var lastGuiOpenEvent = 0L + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val lastInLeap = inLeapMenu + + if (!Config.highlightLeap) return + if (mc.currentScreen == null || mc.currentScreen !is GuiChest) { + inLeapMenu = false + return + } + inLeapMenu = (ContainerNameUtil.currentGuiChestName == "Spirit Leap") + + if (inLeapMenu && !lastInLeap) { + lastGuiOpenEvent = System.currentTimeMillis() + } + + if (inLeapMenu && System.currentTimeMillis() - lastGuiOpenEvent < 300) { + for (i in 11..15) { + leapPlayers[i - 11] = false + val slotIn = mc.thePlayer.openContainer.getSlot(i) + + if (slotIn.stack == null) continue + val stack = slotIn.stack + if (Utils.stripColorCodes(stack.displayName).equals(Config.highlightLeapName, true)) { + leapPlayers[i - 11] = true + } + } + } + } + @JvmStatic + fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { + if (!inLeapMenu) return false + if (slotIn.inventory == mc.thePlayer.inventory) return false + val slotIndex = slotIn.slotIndex + if (slotIndex !in 11..15) return false + return leapPlayers[slotIndex - 11] + } }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt index b3113bd..8bcd145 100644 --- a/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt +++ b/src/main/kotlin/dulkirmod/features/GardenVisitorAlert.kt @@ -3,9 +3,10 @@ package dulkirmod.features import dulkirmod.DulkirMod import dulkirmod.config.Config import dulkirmod.utils.TabListUtils +import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils -class GardenVisitorAlert { +object GardenVisitorAlert { private var hasSentAlert = false private var lastAlert = 0 @@ -19,7 +20,7 @@ class GardenVisitorAlert { if (TabListUtils.maxVisitors && !hasSentAlert) { val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Max Visitors", 5000) + TitleUtils.drawStringForTime("${color}Max Visitors", 5000) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .3f) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .6f) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .9f) @@ -32,7 +33,7 @@ class GardenVisitorAlert { if (TabListUtils.maxVisitors && hasSentAlert && timeSinceLastAlert > 5000 && Config.persistentAlert) { lastAlert = System.currentTimeMillis().toInt() val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Max Visitors", 5000) + TitleUtils.drawStringForTime("${color}Max Visitors", 5000) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .3f) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .6f) DulkirMod.mc.thePlayer.playSound("note.pling", 1f * Config.bestiaryNotifVol, .9f) diff --git a/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt b/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt index 6e47a59..c65b3dd 100644 --- a/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt +++ b/src/main/kotlin/dulkirmod/features/KeeperWaypoints.kt @@ -10,7 +10,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.max -class KeeperWaypoints { +object KeeperWaypoints { @SubscribeEvent fun onWorldRenderLast(event: RenderWorldLastEvent) { if (!Config.keeperWaypoints) return diff --git a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt index db51a48..50f433e 100644 --- a/src/main/kotlin/dulkirmod/features/MatchoAlert.kt +++ b/src/main/kotlin/dulkirmod/features/MatchoAlert.kt @@ -3,9 +3,10 @@ package dulkirmod.features import dulkirmod.DulkirMod import dulkirmod.config.Config import dulkirmod.utils.TabListUtils +import dulkirmod.utils.TitleUtils import dulkirmod.utils.Utils -class MatchoAlert { +object MatchoAlert { var hasSentAlert = false @@ -19,7 +20,7 @@ class MatchoAlert { if (TabListUtils.explosivity && !hasSentAlert) { val color = Utils.getColorString(Config.bestiaryNotifColor) - DulkirMod.titleUtils.drawStringForTime("${color}Matcho", 5000) + TitleUtils.drawStringForTime("${color}Matcho", 5000) if (Config.bestiaryAlertSounds) DulkirMod.mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f) hasSentAlert = true diff --git a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt index a6a0ab6..9b429cb 100644 --- a/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt +++ b/src/main/kotlin/dulkirmod/features/chat/AbiphoneDND.kt @@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent private val abiphoneFormat = "✆ (\\w+) ✆ ".toRegex() private var lastRing: Long = 0 -class AbiphoneDND { +object AbiphoneDND { //BLOCK ABIPHONE SOUNDS @SubscribeEvent(receiveCanceled = false, priority = EventPriority.LOW) fun onSound(event: PlaySoundEvent) { @@ -22,24 +22,22 @@ class AbiphoneDND { } } - companion object { - fun handle(event: ClientChatReceivedEvent, unformatted: String) { - if (!Config.abiDND) return - if (unformatted matches abiphoneFormat) { - val matchResult = abiphoneFormat.find(unformatted) - event.isCanceled = true - lastRing = System.currentTimeMillis() - if (Config.abiCallerID) { - val blocked = if (Math.random() < .001) "Breefing" - else matchResult?.groups?.get(1)?.value - TextUtils.info("§6Call blocked from $blocked!") - } - } - if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") - && System.currentTimeMillis() - lastRing < 5000 - ) { - event.isCanceled = true + fun handle(event: ClientChatReceivedEvent, unformatted: String) { + if (!Config.abiDND) return + if (unformatted matches abiphoneFormat) { + val matchResult = abiphoneFormat.find(unformatted) + event.isCanceled = true + lastRing = System.currentTimeMillis() + if (Config.abiCallerID) { + val blocked = if (Math.random() < .001) "Breefing" + else matchResult?.groups?.get(1)?.value + TextUtils.info("§6Call blocked from $blocked!") } } + if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]") + && System.currentTimeMillis() - lastRing < 5000 + ) { + event.isCanceled = true + } } }
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt index 8e4d2dd..ca78dae 100644 --- a/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt +++ b/src/main/kotlin/dulkirmod/features/chat/FakeMsg.kt @@ -6,9 +6,9 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent object FakeMsg { private val dulkirRegex = "^From \\[MVP(\\+|\\+\\+)] Dulkir: c:".toRegex() fun handle(event: ClientChatReceivedEvent, unformatted: String) { - if (dulkirRegex.matches(unformatted)) { + if (unformatted.contains(dulkirRegex)) { event.isCanceled = true - val message = unformatted.replace(dulkirRegex, "").replace("&", "§") + val message = unformatted.replace(dulkirRegex, "").replace("&", "§").trim() TextUtils.info(message, false) } } |