aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-10-03 02:51:09 -0500
committeringle <inglettronald@gmail.com>2022-10-03 02:51:09 -0500
commitb72e46efc1893883479b21482d8ef00f58971571 (patch)
tree0d41bca6049af80c1cfd3b413ea3b965a9e7beea /src/main/kotlin/dulkirmod
parent03462869f508f549eff1971262d708ffc7d3bfbc (diff)
downloadDulkirMod-b72e46efc1893883479b21482d8ef00f58971571.tar.gz
DulkirMod-b72e46efc1893883479b21482d8ef00f58971571.tar.bz2
DulkirMod-b72e46efc1893883479b21482d8ef00f58971571.zip
Added Bridge Support
Diffstat (limited to 'src/main/kotlin/dulkirmod')
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt4
-rw-r--r--src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt3
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt53
-rw-r--r--src/main/kotlin/dulkirmod/events/ChatEvent.kt23
4 files changed, 73 insertions, 10 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index d0ea1e5..265d121 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -11,14 +11,12 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.settings.KeyBinding
import net.minecraftforge.client.ClientCommandHandler
-import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.client.registry.ClientRegistry
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -84,7 +82,7 @@ class DulkirMod {
companion object {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
- const val MOD_VERSION = "1.0.3"
+ const val MOD_VERSION = "1.0.4"
const val CHAT_PREFIX = "<DulkirMod>"
val mc: Minecraft = Minecraft.getMinecraft()
diff --git a/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt b/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
index 3e5405a..46506a2 100644
--- a/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
+++ b/src/main/kotlin/dulkirmod/command/JoinDungeonCommand.kt
@@ -2,7 +2,6 @@ package dulkirmod.command
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.Config
-import net.minecraft.client.Minecraft
import net.minecraft.command.CommandException
import net.minecraft.command.ICommandSender
import net.minecraft.util.ChatComponentText
@@ -12,10 +11,8 @@ class JoinDungeonCommand : ClientCommandBase("joindungeon") {
@Throws(CommandException::class)
override fun processCommand(sender: ICommandSender, args: Array<String>) {
var arguments = args.contentToString().replace("[", "").replace("]", "").replace(",","")
- println(arguments)
var type = ""
var num = ""
- println(args[0])
if (args[0] == "master_catacombs") {
type = "M"
}
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 1a50b88..d17ef47 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -1,16 +1,13 @@
package dulkirmod.config
import dulkirmod.DulkirMod
+import dulkirmod.utils.Utils
import gg.essential.vigilance.Vigilant
import gg.essential.vigilance.data.Category
import gg.essential.vigilance.data.Property
import gg.essential.vigilance.data.PropertyType
import gg.essential.vigilance.data.SortingBehavior
-import dulkirmod.DulkirMod.Companion.display
-import dulkirmod.utils.Utils
-import java.awt.Color
import java.io.File
-import java.util.function.Consumer
object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", sortingBehavior = ConfigSorting) {
@@ -242,6 +239,50 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
)
var noReverse3rdPerson = false
+ @Property(
+ type = PropertyType.SWITCH,
+ name = "Bridge Bot Formatter",
+ description = "Global Toggle",
+ category = "Bridge"
+ )
+ var bridgeBot = false
+
+ @Property(
+ type = PropertyType.TEXT,
+ name = "Bridge Bot Name",
+ description = "Not case-sensitive",
+ category = "Bridge",
+ placeholder = "Bweefing",
+ protectedText = false
+ )
+ var botName: String = "Bweefing"
+
+ @Property(
+ type = PropertyType.SELECTOR,
+ name = "Bridge Chatter Name Color",
+ description = "Pick how the player name looks.",
+ category = "Bridge",
+ 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 bridgeColor = 6
+
fun init() {
initialize()
@@ -251,6 +292,10 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
"Custom Animations",
"All settings that are related to custom animations. Mostly help from Aton."
)
+ setCategoryDescription(
+ "Bridge",
+ "Expected format: (bridge bot user) > (sent message) - without any parenthesis."
+ )
}
private object ConfigSorting : SortingBehavior() {
override fun getCategoryComparator(): Comparator<in Category> = Comparator { o1, o2 ->
diff --git a/src/main/kotlin/dulkirmod/events/ChatEvent.kt b/src/main/kotlin/dulkirmod/events/ChatEvent.kt
index de180fa..f1a4bef 100644
--- a/src/main/kotlin/dulkirmod/events/ChatEvent.kt
+++ b/src/main/kotlin/dulkirmod/events/ChatEvent.kt
@@ -1,21 +1,44 @@
package dulkirmod.events
import dulkirmod.DulkirMod
+import dulkirmod.config.Config
import dulkirmod.utils.Utils.stripColorCodes
+import net.minecraft.util.ChatComponentText
+import net.minecraft.util.EnumChatFormatting
import net.minecraftforge.client.event.ClientChatReceivedEvent
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()
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW)
fun onChat(event: ClientChatReceivedEvent) {
if (event.type == 2.toByte()) {
return
}
+
+ // THROTTLE NOTIFIER
val unformatted = stripColorCodes(event.message.unformattedText)
if (unformatted == "This menu has been throttled! Please slow down..." && DulkirMod.config.throttleNotifier) {
event.isCanceled = true;
DulkirMod.mc.thePlayer.sendChatMessage("/pc " + DulkirMod.config.customMessage)
}
+
+ // BRIDGE BOT STUFF - CLICKABLE LINKS!
+ val message = event.message.unformattedText
+ if (guildFormat matches message && Config.bridgeBot) {
+ val matchResult = guildFormat.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