diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 28 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/config/Config.kt | 90 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/events/ChatEvent.kt | 19 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/AlarmClock.kt | 48 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/TitleUtils.kt | 36 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/Utils.kt | 14 | ||||
-rw-r--r-- | src/main/resources/Minecraftsounds.txt | 246 |
7 files changed, 471 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 diff --git a/src/main/resources/Minecraftsounds.txt b/src/main/resources/Minecraftsounds.txt new file mode 100644 index 0000000..64b010f --- /dev/null +++ b/src/main/resources/Minecraftsounds.txt @@ -0,0 +1,246 @@ +ambient.cave.cave +ambient.weather.rain +ambient.weather.thunder +game.player.hurt.fall.big +game.neutral.hurt.fall.big +game.hostile.hurt.fall.big +game.player.hurt.fall.small +game.neutral.hurt.fall.small +game.hostile.hurt.fall.small +game.player.hurt +game.neutral.hurt +game.hostile.hurt +game.player.die +game.neutral.die +game.hostile.die +dig.cloth +dig.glass +game.potion.smash +dig.grass +dig.gravel +dig.sand +dig.snow +dig.stone +dig.wood +fire.fire +fire.ignite +item.fireCharge.use +fireworks.blast +fireworks.blast_far +fireworks.largeBlast +fireworks.largeBlast_far +fireworks.launch +fireworks.twinkle +fireworks.twinkle_far +game.player.swim.splash +game.neutral.swim.splash +game.hostile.swim.splash +game.player.swim +game.neutral.swim +game.hostile.swim +liquid.lava +liquid.lavapop +liquid.water +minecart.base +minecart.inside +note.bass +note.bassattack +note.bd +note.harp +note.hat +note.pling +note.snare +portal.portal +portal.travel +portal.trigger +random.anvil_break +random.anvil_land +random.anvil_use +random.bow +random.bowhit +random.break +random.burp +random.chestclosed +random.chestopen +gui.button.press +random.click +random.door_open +random.door_close +random.drink +random.eat +random.explode +random.fizz +game.tnt.primed +creeper.primed +random.levelup +random.orb +random.pop +random.splash +random.successful_hit +random.wood_click +step.cloth +step.grass +step.gravel +step.ladder +step.sand +step.snow +step.stone +step.wood +tile.piston.in +tile.piston.out +mob.bat.death +mob.bat.hurt +mob.bat.idle +mob.bat.loop +mob.bat.takeoff +mob.blaze.breathe +mob.blaze.death +mob.blaze.hit +mob.cat.hiss +mob.cat.hitt +mob.cat.meow +mob.cat.purr +mob.cat.purreow +mob.chicken.hurt +mob.chicken.plop +mob.chicken.say +mob.chicken.step +mob.cow.hurt +mob.cow.say +mob.cow.step +mob.creeper.death +mob.creeper.say +mob.enderdragon.end +mob.enderdragon.growl +mob.enderdragon.hit +mob.enderdragon.wings +mob.endermen.death +mob.endermen.hit +mob.endermen.idle +mob.endermen.portal +mob.endermen.scream +mob.endermen.stare +mob.ghast.affectionate_scream +mob.ghast.charge +mob.ghast.death +mob.ghast.fireball +mob.ghast.moan +mob.ghast.scream +mob.guardian.hit +mob.guardian.idle +mob.guardian.death +mob.guardian.elder.hit +mob.guardian.elder.idle +mob.guardian.elder.death +mob.guardian.land.hit +mob.guardian.land.idle +mob.guardian.land.death +mob.guardian.curse +mob.guardian.attack +mob.guardian.flop +mob.horse.angry +mob.horse.armor +mob.horse.breathe +mob.horse.death +mob.horse.donkey.angry +mob.horse.donkey.death +mob.horse.donkey.hit +mob.horse.donkey.idle +mob.horse.gallop +mob.horse.hit +mob.horse.idle +mob.horse.jump +mob.horse.land +mob.horse.leather +mob.horse.skeleton.death +mob.horse.skeleton.hit +mob.horse.skeleton.idle +mob.horse.soft +mob.horse.wood +mob.horse.zombie.death +mob.horse.zombie.hit +mob.horse.zombie.idle +mob.irongolem.death +mob.irongolem.hit +mob.irongolem.throw +mob.irongolem.walk +mob.magmacube.big +mob.magmacube.jump +mob.magmacube.small +mob.pig.death +mob.pig.say +mob.pig.step +mob.rabbit.hurt +mob.rabbit.idle +mob.rabbit.hop +mob.rabbit.death +mob.sheep.say +mob.sheep.shear +mob.sheep.step +mob.silverfish.hit +mob.silverfish.kill +mob.silverfish.say +mob.silverfish.step +mob.skeleton.death +mob.skeleton.hurt +mob.skeleton.say +mob.skeleton.step +mob.slime.attack +mob.slime.big +mob.slime.small +mob.spider.death +mob.spider.say +mob.spider.step +mob.villager.death +mob.villager.haggle +mob.villager.hit +mob.villager.idle +mob.villager.no +mob.villager.yes +mob.wither.death +mob.wither.hurt +mob.wither.idle +mob.wither.shoot +mob.wither.spawn +mob.wolf.bark +mob.wolf.death +mob.wolf.growl +mob.wolf.howl +mob.wolf.hurt +mob.wolf.panting +mob.wolf.shake +mob.wolf.step +mob.wolf.whine +mob.zombie.death +mob.zombie.hurt +mob.zombie.infect +mob.zombie.metal +mob.zombie.remedy +mob.zombie.say +mob.zombie.step +mob.zombie.unfect +mob.zombie.wood +mob.zombie.woodbreak +mob.zombiepig.zpig +mob.zombiepig.zpigangry +mob.zombiepig.zpigdeath +mob.zombiepig.zpighurt +records.11 +records.13 +records.blocks +records.cat +records.chirp +records.far +records.mall +records.mellohi +records.stal +records.strad +records.wait +records.ward +music.menu +music.game +music.game.creative +music.game.end +music.game.end.dragon +music.game.end.credits +music.game.nether
\ No newline at end of file |