aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt28
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt90
-rw-r--r--src/main/kotlin/dulkirmod/events/ChatEvent.kt19
-rw-r--r--src/main/kotlin/dulkirmod/features/AlarmClock.kt48
-rw-r--r--src/main/kotlin/dulkirmod/utils/TitleUtils.kt36
-rw-r--r--src/main/kotlin/dulkirmod/utils/Utils.kt14
6 files changed, 225 insertions, 10 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index 265d121..2f8c16e 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -4,6 +4,8 @@ import dulkirmod.command.*
import dulkirmod.config.Config
import dulkirmod.events.ChatEvent
import dulkirmod.features.NametagCleaner
+import dulkirmod.features.alarmClock
+import dulkirmod.utils.TitleUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -33,6 +35,7 @@ import kotlin.coroutines.EmptyCoroutineContext
)
class DulkirMod {
+ var lastLongUpdate : Long = 0
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
val directory = File(event.modConfigurationDirectory, "dulkirmod")
@@ -55,6 +58,7 @@ class DulkirMod {
MinecraftForge.EVENT_BUS.register(this)
MinecraftForge.EVENT_BUS.register(ChatEvent())
MinecraftForge.EVENT_BUS.register(NametagCleaner)
+ MinecraftForge.EVENT_BUS.register(DulkirMod.titleUtils)
keyBinds.forEach(ClientRegistry::registerKeyBinding)
}
@@ -69,9 +73,22 @@ class DulkirMod {
if (Config.noReverse3rdPerson && mc.gameSettings.thirdPersonView == 2)
mc.gameSettings.thirdPersonView = 0
- if (event.phase != TickEvent.Phase.START || display == null) return
- mc.displayGuiScreen(display)
- display = null
+ if (event.phase == TickEvent.Phase.START && display != null) {
+ mc.displayGuiScreen(display)
+ display = null
+ }
+
+ var longupdate = false
+ val currTime : Long = System.currentTimeMillis()
+ if (currTime - lastLongUpdate > 1000) {
+ longupdate = true
+ lastLongUpdate = currTime
+ }
+ if (longupdate) {
+ // EXECUTE STUFF HERE THAT DOESN'T REALLY NEED TO BE RUN EVERY TICK
+ alarmClock()
+ longupdate = false
+ }
}
@SubscribeEvent
@@ -89,14 +106,11 @@ class DulkirMod {
var config = Config
var display: GuiScreen? = null
val scope = CoroutineScope(EmptyCoroutineContext)
+ val titleUtils = TitleUtils()
val keyBinds = arrayOf(
KeyBinding("Open Settings", Keyboard.KEY_RSHIFT, "Dulkir Mod"),
)
}
-
- // terminal throttle code
-
-
}
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index d17ef47..2bb1de7 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -283,7 +283,95 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
var bridgeColor = 6
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Ghast Notification",
+ description = "Shows a title at 9:00pm for bestiary",
+ category = "Bestiary"
+ )
+ var notifyGhast = false
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Zombie Villager Notification",
+ description = "Shows a title at 8:00pm for bestiary",
+ category = "Bestiary"
+ )
+ var notifyZombieVillager = false
+ @Property(
+ type = PropertyType.SELECTOR,
+ name = "Bestiary Notification Color",
+ description = "Changes color of title notification",
+ category = "Bestiary",
+ options = ["§0Black",
+ "§1Dark Blue",
+ "§2Dark Green",
+ "§3Dark Aqua",
+ "§4Dark Red",
+ "§5Dark Purple",
+ "§6Gold",
+ "§7Gray",
+ "§8Dark Gray",
+ "§9Blue",
+ "§aGreen",
+ "§bAqua",
+ "§cRed",
+ "§dLight Purple",
+ "§eYellow",
+ "§fWhite",
+ "§zSBA Chroma"
+ ]
+ )
+ var bestiaryNotifColor = 15
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Text Shadow",
+ description = "Shows text shadow for notification",
+ category = "Bestiary"
+ )
+ var bestiaryTextShadow = false
+
+ @Property(
+ type = PropertyType.DECIMAL_SLIDER,
+ name = "Scale",
+ description = "Size of notification!",
+ category = "Bestiary",
+ minF = 0f,
+ maxF = 1f,
+ decimalPlaces = 1
+ )
+ var bestiaryNotifSize = .7f
+
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Alert Noises",
+ description = "Uses relevant mob sounds, doesn't override audio/patcher settings",
+ category = "Bestiary"
+ )
+ var bestiaryAlertSounds = false
+
+ @Property(
+ type = PropertyType.DECIMAL_SLIDER,
+ name = "Alert Volume",
+ description = "Volume of notification!",
+ category = "Bestiary",
+ minF = 0f,
+ maxF = 1f,
+ decimalPlaces = 1
+ )
+ var bestiaryNotifVol = .7f
+
+ @Property(
+ type = PropertyType.BUTTON,
+ name = "Demo Volume Selection",
+ description = "Plays the Ghast Noise as Reference, Might add individual sliders later but this seems like enough",
+ category = "Bestiary"
+ )
+ fun demoVolume() {
+ DulkirMod.mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f)
+ }
fun init() {
initialize()
addDependency("customMessage", "throttleNotifier")
@@ -294,7 +382,7 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
setCategoryDescription(
"Bridge",
- "Expected format: (bridge bot user) > (sent message) - without any parenthesis."
+ "If your bridge format does not work, message me on discord and I can probably add it."
)
}
private object ConfigSorting : SortingBehavior() {
diff --git a/src/main/kotlin/dulkirmod/events/ChatEvent.kt b/src/main/kotlin/dulkirmod/events/ChatEvent.kt
index f1a4bef..e034996 100644
--- a/src/main/kotlin/dulkirmod/events/ChatEvent.kt
+++ b/src/main/kotlin/dulkirmod/events/ChatEvent.kt
@@ -10,7 +10,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class ChatEvent {
- private val guildFormat = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z]\\[[A-Z]+])?§f: (\\w+) > .+".toRegex()
+ private val guildFormat = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+) > .+".toRegex()
+ private val alternateFormat = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+): .+".toRegex()
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW)
fun onChat(event: ClientChatReceivedEvent) {
if (event.type == 2.toByte()) {
@@ -40,5 +41,21 @@ class ChatEvent {
).setChatStyle(event.message.siblings[1].chatStyle.createShallowCopy())
}
}
+
+ // OTHER FORMAT
+ else if (alternateFormat matches message && Config.bridgeBot) {
+ val matchResult = alternateFormat.find(message)
+ val (prefix, name, playerName) = matchResult!!.destructured
+ if (stripColorCodes(name.lowercase()) == Config.botName.lowercase()) {
+ val newPrefix = if (prefix == "§2Guild") "§2Bridge" else "§3Bridge"
+ val color = if (Config.bridgeColor == 16) "§z" else EnumChatFormatting.values()[Config.bridgeColor]
+ event.message.siblings[0] = ChatComponentText(
+ "$newPrefix > $color$playerName§f: "
+ )
+ event.message.siblings[1] = ChatComponentText(
+ event.message.siblings[1].unformattedText.replace("$playerName: ", "")
+ ).setChatStyle(event.message.siblings[1].chatStyle.createShallowCopy())
+ }
+ }
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/AlarmClock.kt b/src/main/kotlin/dulkirmod/features/AlarmClock.kt
new file mode 100644
index 0000000..9c46a08
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/AlarmClock.kt
@@ -0,0 +1,48 @@
+package dulkirmod.features
+
+import dulkirmod.DulkirMod
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.Config
+import dulkirmod.utils.Utils
+import net.minecraft.scoreboard.Score
+import net.minecraft.scoreboard.ScorePlayerTeam
+import net.minecraft.util.EnumChatFormatting
+
+var lastUpdate : Long = 0
+
+fun alarmClock() {
+ // CHECK IF IN SKYBLOCK
+ if (!Utils.isInSkyblock()) return
+ // CHECK TIME
+ val currTime : Long = System.currentTimeMillis()
+ val scoreboard = mc.thePlayer.worldScoreboard
+ val sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1)
+ val scores: List<Score> = ArrayList(scoreboard.getSortedScores(sidebarObjective))
+ val lines: MutableList<String> = ArrayList()
+ for (i in scores.indices.reversed()) {
+ val score = scores[i]
+ val scoreplayerteam1 = scoreboard.getPlayersTeam(score.playerName)
+ val line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.playerName)
+ lines.add(line)
+ }
+ for (l in lines) {
+ // ZOMBIE VILLAGER
+ if (Config.notifyZombieVillager && l.contains("8:00pm") && (currTime - lastUpdate) > 15000) {
+ lastUpdate = currTime
+ val color = if (Config.bestiaryNotifColor == 16) "§z" else EnumChatFormatting.values()[Config.bestiaryNotifColor]
+ DulkirMod.titleUtils.drawStringForTime("${color}Zombie Villager", 5000)
+ if (Config.bestiaryAlertSounds)
+ mc.thePlayer.playSound("mob.villager.yes", 1f * Config.bestiaryNotifVol, 0f)
+ }
+ // GHASTS
+ else if (Config.notifyGhast && l.contains("9:00pm") && (currTime - lastUpdate) > 15000) {
+ lastUpdate = currTime
+ val color = if (Config.bestiaryNotifColor == 16) "§z" else EnumChatFormatting.values()[Config.bestiaryNotifColor]
+ DulkirMod.titleUtils.drawStringForTime("${color}Ghast", 5000)
+ if (Config.bestiaryAlertSounds)
+ mc.thePlayer.playSound("mob.ghast.scream", 1f * Config.bestiaryNotifVol, 1f)
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/utils/TitleUtils.kt b/src/main/kotlin/dulkirmod/utils/TitleUtils.kt
new file mode 100644
index 0000000..52fe793
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/utils/TitleUtils.kt
@@ -0,0 +1,36 @@
+package dulkirmod.utils
+
+import dulkirmod.DulkirMod.Companion.mc
+import dulkirmod.config.Config
+import net.minecraft.client.gui.ScaledResolution
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.min
+
+class TitleUtils {
+ var curString = ""
+ var endTime : Long = 0
+
+ @SubscribeEvent
+ fun onRender(event: RenderGameOverlayEvent.Text) {
+ if (System.currentTimeMillis() > endTime) return
+ val width = mc.fontRendererObj.getStringWidth(curString)
+ val screenWidth = ScaledResolution(mc).scaledWidth_double
+ val screenHeight = ScaledResolution(mc).scaledHeight_double
+ var scale = ((screenWidth - 100) * Config.bestiaryNotifSize) / width
+ scale = min(scale, 10.0)
+ GlStateManager.pushMatrix()
+ GlStateManager.translate((screenWidth / 2 - width * scale / 2), screenHeight/2 - (4.5 * scale), 0.0)
+ GlStateManager.scale(scale, scale, scale)
+ mc.fontRendererObj.drawString(curString, 0f, 0f, 0, Config.bestiaryTextShadow)
+ GlStateManager.popMatrix()
+ }
+
+ fun drawStringForTime(string : String, time : Int) {
+ this.curString = string
+ this.endTime = time.toLong() + System.currentTimeMillis()
+ }
+
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt
index c3caa26..95f714b 100644
--- a/src/main/kotlin/dulkirmod/utils/Utils.kt
+++ b/src/main/kotlin/dulkirmod/utils/Utils.kt
@@ -9,7 +9,6 @@ import java.awt.Toolkit
import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection
-import java.lang.IllegalArgumentException
import java.util.*
object Utils {
@@ -54,4 +53,17 @@ object Utils {
}
mc.displayGuiScreen(null)
}
+
+ fun isInSkyblock() : Boolean{
+ if ((mc.theWorld != null) && (mc.thePlayer != null)) {
+ if (mc.isSingleplayer || mc.thePlayer.clientBrand == null ||
+ !mc.thePlayer.clientBrand.lowercase(Locale.getDefault()).contains("hypixel")) {
+ return false
+ }
+ if (mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1) == null)
+ return false;
+ return stripColorCodes(mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1).displayName).contains("SKYBLOCK")
+ }
+ return false
+ }
} \ No newline at end of file