diff options
| author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-07 16:19:58 -0400 | 
|---|---|---|
| committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-09-07 16:20:04 -0400 | 
| commit | a5658b53d13943452612a6ea7e5f97ea78553d7f (patch) | |
| tree | c064f0b0e57dacd1cfec5c792c6369186aee23c4 /src/main/kotlin | |
| parent | ae5cc372ccbc371e3285fb9968e48d7a5a13ce24 (diff) | |
| download | SkytilsMod-a5658b53d13943452612a6ea7e5f97ea78553d7f.tar.gz SkytilsMod-a5658b53d13943452612a6ea7e5f97ea78553d7f.tar.bz2 SkytilsMod-a5658b53d13943452612a6ea7e5f97ea78553d7f.zip | |
Chat Tab commands
Diffstat (limited to 'src/main/kotlin')
3 files changed, 56 insertions, 15 deletions
| diff --git a/src/main/kotlin/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/skytils/skytilsmod/core/Config.kt index f98bc783..ad4d0584 100644 --- a/src/main/kotlin/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/skytils/skytilsmod/core/Config.kt @@ -98,13 +98,6 @@ object Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sortin      var overrideReparty = true      @Property( -        type = PropertyType.SWITCH, name = "Chat Tabs", -        description = "Creates various tabs to organize chat.", -        category = "General", subcategory = "Hypixel" -    ) -    var chatTabs = false - -    @Property(          type = PropertyType.SWITCH, name = "Guild Leave Confirmation",          description = "Requires you to run the /g leave command twice to leave your guild.",          category = "General", subcategory = "Hypixel" @@ -975,6 +968,27 @@ object Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sortin      var hollowChatCoords = false      @Property( +        type = PropertyType.SWITCH, name = "Chat Tabs", +        description = "Creates various tabs to organize chat.", +        category = "Miscellaneous", subcategory = "Chat Tabs" +    ) +    var chatTabs = false + +    @Property( +        type = PropertyType.SWITCH, name = "Pre-fill Chat Commands", +        description = "Auto fills the respective command for each tab.", +        category = "Miscellaneous", subcategory = "Chat Tabs" +    ) +    var preFillChatTabCommands = false + +    @Property( +        type = PropertyType.SWITCH, name = "Auto Switch Chat Channel", +        description = "Automatically types the command to switch to a certain channel.", +        category = "Miscellaneous", subcategory = "Chat Tabs" +    ) +    var autoSwitchChatChannel = false + +    @Property(          type = PropertyType.SWITCH, name = "Fix SBA Chroma",          description = "Fixes SBA chroma with Patcher 1.6",          category = "Miscellaneous", subcategory = "Fixes" diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt index e62a2129..eebf24b0 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/ChatTabs.kt @@ -22,6 +22,7 @@ import gg.essential.universal.UResolution  import net.minecraft.client.gui.GuiChat  import net.minecraft.network.play.server.S02PacketChat  import net.minecraft.util.IChatComponent +import net.minecraftforge.client.event.GuiOpenEvent  import net.minecraftforge.client.event.GuiScreenEvent  import net.minecraftforge.fml.common.eventhandler.EventPriority  import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -31,6 +32,7 @@ import skytils.skytilsmod.Skytils.Companion.mc  import skytils.skytilsmod.events.PacketEvent  import skytils.skytilsmod.gui.elements.CleanButton  import skytils.skytilsmod.mixins.extensions.ExtensionChatStyle +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiChat  import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat  import skytils.skytilsmod.utils.Utils @@ -59,6 +61,19 @@ object ChatTabs {      }      @SubscribeEvent +    fun onOpenGui(event: GuiOpenEvent) { +        if (!Skytils.config.chatTabs || !Skytils.config.preFillChatTabCommands || !Utils.isOnHypixel || event.gui !is GuiChat) return +        if ((event.gui as AccessorGuiChat).defaultInputFieldText.isBlank()) { +            (event.gui as AccessorGuiChat).defaultInputFieldText = when (selectedTab) { +                ChatTab.ALL -> "/ac " +                ChatTab.PARTY -> "/pc " +                ChatTab.GUILD -> "/gc " +                ChatTab.PRIVATE -> "/r " +            } +        } +    } + +    @SubscribeEvent      fun onScreenEvent(event: GuiScreenEvent) {          if (!Skytils.config.chatTabs || !Utils.isOnHypixel || event.gui !is GuiChat) return          val chat = mc.ingameGUI.chatGUI @@ -73,6 +88,16 @@ object ChatTabs {                  }?.let {                      selectedTab = it.key                      mc.ingameGUI.chatGUI.refreshChat() +                    if (Skytils.config.autoSwitchChatChannel) { +                        Skytils.sendMessageQueue.addFirst( +                            when (selectedTab) { +                                ChatTab.ALL -> "/chat a" +                                ChatTab.PARTY -> "/chat p" +                                ChatTab.GUILD -> "/chat g" +                                else -> "" +                            } +                        ) +                    }                  }              }              is GuiScreenEvent.DrawScreenEvent.Pre -> { @@ -90,21 +115,23 @@ object ChatTabs {          mc.ingameGUI.chatGUI.refreshChat()      } -    enum class ChatTab(val button: CleanButton, val isValid: (IChatComponent) -> Boolean) { -        ALL(CleanButton(-69420, 2, 0, 20, 20, "A"), { true }), -        PARTY(CleanButton(-69420, 24, 0, 20, 20, "P"), { +    enum class ChatTab(text: String, val isValid: (IChatComponent) -> Boolean) { +        ALL("A", { true }), +        PARTY("P", {              val formatted = it.formattedText              formatted.startsWith("§r§9Party §8> ") || formatted.startsWith("§r§9P §8> ")          }), -        GUILD(CleanButton(-69420, 46, 0, 20, 20, "G"), { +        GUILD("G", {              val formatted = it.formattedText              formatted.startsWith("§r§2Guild > ") || formatted.startsWith("§r§2G > ")          }), -        PRIVATE(CleanButton(-69420, 68, 0, 20, 20, "PM"), { +        PRIVATE("PM", {              val formatted = it.formattedText              formatted.startsWith("§dTo ") || formatted.startsWith("§dFrom ")          }); +        val button = CleanButton(-69420, 2 + 20 * ordinal, 0, 20, 20, text) +          companion object {              val buttons by lazy { values().associateWith { it.button } }          } diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt index 9d17f385..eff67271 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt @@ -528,10 +528,10 @@ class ItemFeatures {              val alignment =                  if (actualX < UResolution.scaledWidth / 2f) TextAlignment.LEFT_RIGHT else TextAlignment.RIGHT_LEFT              ScreenRenderer.fontRenderer.drawString( -                "§aSelected: §zSkytils Arrow", +                "§aSelected: §rSkytils Arrow",                  if (actualX < UResolution.scaledWidth / 2f) 0f else width.toFloat(),                  0f, -                CommonColors.WHITE, +                CommonColors.RAINBOW,                  alignment,                  TextShadow.NORMAL              ) @@ -540,7 +540,7 @@ class ItemFeatures {          override val height: Int              get() = ScreenRenderer.fontRenderer.FONT_HEIGHT          override val width: Int -            get() = ScreenRenderer.fontRenderer.getStringWidth("§aSelected: §zSkytils Arrow") +            get() = ScreenRenderer.fontRenderer.getStringWidth("§aSelected: §rSkytils Arrow")          override val toggled: Boolean              get() = Skytils.config.showSelectedArrowDisplay | 
