aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/raeids/stratus
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/raeids/stratus')
-rw-r--r--src/main/kotlin/com/raeids/stratus/Stratus.kt37
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatRegexes.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ChatRegexes.kt)2
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatSearchingManager.kt47
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatShortcuts.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ChatShortcuts.kt)6
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatTab.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt)10
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatTabs.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt)7
-rw-r--r--src/main/kotlin/com/raeids/stratus/chat/ChatTabsJson.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt)2
-rw-r--r--src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt20
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt8
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt35
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/CleanButton.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt)2
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/ScreenshotButton.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/ScreenshotButton.kt)5
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/SearchButton.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/CleanSearchButton.kt)21
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/TabButton.kt (renamed from src/main/kotlin/com/raeids/stratus/hook/CleanTabButton.kt)8
-rw-r--r--src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt37
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt41
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/ModCompatHooks.kt20
-rw-r--r--src/main/kotlin/com/raeids/stratus/updater/Updater.kt4
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/ImageTransferable.kt2
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt26
-rw-r--r--src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt3
21 files changed, 200 insertions, 143 deletions
diff --git a/src/main/kotlin/com/raeids/stratus/Stratus.kt b/src/main/kotlin/com/raeids/stratus/Stratus.kt
index 7588749..57ef565 100644
--- a/src/main/kotlin/com/raeids/stratus/Stratus.kt
+++ b/src/main/kotlin/com/raeids/stratus/Stratus.kt
@@ -1,11 +1,11 @@
package com.raeids.stratus
+import com.raeids.stratus.chat.ChatSearchingManager
+import com.raeids.stratus.chat.ChatShortcuts
+import com.raeids.stratus.chat.ChatTabs
import com.raeids.stratus.command.StratusCommand
import com.raeids.stratus.config.StratusConfig
-import com.raeids.stratus.hook.ChatShortcuts
-import com.raeids.stratus.hook.ChatTabs
import com.raeids.stratus.hook.GuiNewChatHook
-import com.raeids.stratus.hook.filterMessages
import com.raeids.stratus.mixin.GuiNewChatAccessor
import com.raeids.stratus.updater.Updater
import com.raeids.stratus.utils.RenderHelper
@@ -48,9 +48,9 @@ object Stratus {
lateinit var jarFile: File
private set
var isPatcher = false
- private set
+ private set
var isBetterChat = false
- private set
+ private set
private val fileFormatter: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH.mm.ss'.png'")
@@ -92,8 +92,16 @@ object Stratus {
fun screenshotLine(line: ChatLine): BufferedImage? {
val hud = Minecraft.getMinecraft().ingameGUI
val chat = hud.chatGUI
- val i = MathHelper.floor_float(chat.chatWidth/chat.chatScale)
- return screenshot(GuiUtilRenderComponents.splitText(line.chatComponent, i, Minecraft.getMinecraft().fontRendererObj, false, false).map { it.formattedText }.reversed(), chat.chatWidth)
+ val i = MathHelper.floor_float(chat.chatWidth / chat.chatScale)
+ return screenshot(
+ GuiUtilRenderComponents.splitText(
+ line.chatComponent,
+ i,
+ Minecraft.getMinecraft().fontRendererObj,
+ false,
+ false
+ ).map { it.formattedText }.reversed(), chat.chatWidth
+ )
}
private fun screenshotChat() {
@@ -104,8 +112,15 @@ object Stratus {
val hud = Minecraft.getMinecraft().ingameGUI
val chat = hud.chatGUI
val chatLines = ArrayList<String>()
- filterMessages((chat as GuiNewChatHook).prevText, (chat as GuiNewChatAccessor).drawnChatLines)?.let { drawnLines ->
- for (i in scrollPos until drawnLines.size.coerceAtMost(scrollPos+GuiNewChat.calculateChatboxHeight(Minecraft.getMinecraft().gameSettings.chatHeightFocused)/9)){
+ ChatSearchingManager.filterMessages(
+ (chat as GuiNewChatHook).prevText,
+ (chat as GuiNewChatAccessor).drawnChatLines
+ )?.let { drawnLines ->
+ for (i in scrollPos until drawnLines.size.coerceAtMost(
+ scrollPos + GuiNewChat.calculateChatboxHeight(
+ Minecraft.getMinecraft().gameSettings.chatHeightFocused
+ ) / 9
+ )) {
chatLines.add(drawnLines[i].chatComponent.formattedText)
}
@@ -122,10 +137,10 @@ object Stratus {
}
val fr: FontRenderer = Minecraft.getMinecraft().fontRendererObj
- val fb: Framebuffer = RenderHelper.createBindFramebuffer(width, messages.size*9)
+ val fb: Framebuffer = RenderHelper.createBindFramebuffer(width, messages.size * 9)
val file = File(Minecraft.getMinecraft().mcDataDir, "screenshots/chat/" + fileFormatter.format(Date()))
- for (i in messages.indices) fr.drawStringWithShadow(messages[i], 0f, (messages.size-1-i)*9f, 0xffffff)
+ for (i in messages.indices) fr.drawStringWithShadow(messages[i], 0f, (messages.size - 1 - i) * 9f, 0xffffff)
val image = RenderHelper.screenshotFramebuffer(fb, file)
Minecraft.getMinecraft().entityRenderer.setupOverlayRendering()
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatRegexes.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatRegexes.kt
index fd743ea..4737177 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatRegexes.kt
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatRegexes.kt
@@ -1,4 +1,4 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.chat
data class ChatRegexes(val regexList: List<String>?) {
val compiledRegexList: MutableList<Regex> = arrayListOf()
diff --git a/src/main/kotlin/com/raeids/stratus/chat/ChatSearchingManager.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatSearchingManager.kt
new file mode 100644
index 0000000..030635b
--- /dev/null
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatSearchingManager.kt
@@ -0,0 +1,47 @@
+package com.raeids.stratus.chat
+
+import com.raeids.stratus.hook.GuiNewChatHook
+import gg.essential.lib.caffeine.cache.Cache
+import gg.essential.lib.caffeine.cache.Caffeine
+import gg.essential.universal.wrappers.message.UTextComponent
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.ChatLine
+import java.util.concurrent.LinkedBlockingQueue
+import java.util.concurrent.ThreadPoolExecutor
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicInteger
+
+object ChatSearchingManager {
+ private var counter: AtomicInteger = AtomicInteger(0)
+ private var POOL: ThreadPoolExecutor = ThreadPoolExecutor(
+ 50, 50,
+ 0L, TimeUnit.SECONDS,
+ LinkedBlockingQueue()
+ ) { r ->
+ Thread(
+ r,
+ "Chat Filter Cache Thread ${counter.incrementAndGet()}"
+ )
+ }
+
+ @JvmStatic
+ val cache: Cache<String, List<ChatLine>> = Caffeine.newBuilder().executor(POOL).maximumSize(5000).build()
+
+ @JvmStatic
+ fun filterMessages(text: String, list: List<ChatLine>): List<ChatLine>? {
+ if (text.isBlank()) return list
+ val cached = cache.getIfPresent(text)
+ return cached ?: run {
+ cache.put(text, list.filter {
+ UTextComponent.stripFormatting(it.chatComponent.unformattedText).lowercase()
+ .contains(text.lowercase())
+ })
+ cache.getIfPresent(text)
+ }
+ }
+
+ @JvmStatic
+ fun setPrevText(text: String) {
+ (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).prevText = text
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatShortcuts.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatShortcuts.kt
index 10a2af9..68fc18e 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatShortcuts.kt
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatShortcuts.kt
@@ -1,4 +1,4 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.chat
import com.google.gson.JsonObject
import com.google.gson.JsonParser
@@ -49,7 +49,9 @@ object ChatShortcuts {
fun handleSentCommand(command: String): String {
shortcuts.forEach {
- if (command == it.first || (command.startsWith(it.first) && command.substringAfter(it.first).startsWith(" "))) {
+ if (command == it.first || (command.startsWith(it.first) && command.substringAfter(it.first)
+ .startsWith(" "))
+ ) {
return command.replaceFirst(it.first, it.second)
}
}
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatTab.kt
index fa56a54..ed6712c 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTab.kt
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatTab.kt
@@ -1,6 +1,7 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.chat
import com.google.gson.annotations.SerializedName
+import com.raeids.stratus.gui.components.TabButton
import kotlinx.coroutines.runBlocking
import net.minecraft.client.Minecraft
import net.minecraft.util.EnumChatFormatting
@@ -17,14 +18,14 @@ data class ChatTab(
@SerializedName("regex") val uncompiledRegex: List<String>?,
val prefix: String
) {
- lateinit var button: CleanTabButton
+ lateinit var button: TabButton
lateinit var compiledRegex: ChatRegexes
//Ugly hack to make GSON not make button / regex null
fun initialize() {
compiledRegex = ChatRegexes(uncompiledRegex)
val width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(name)
- button = CleanTabButton(653452, runBlocking {
+ button = TabButton(653452, runBlocking {
val returnValue = x - 2
x += 6 + width
return@runBlocking returnValue
@@ -35,7 +36,8 @@ data class ChatTab(
if (startsWith == null && equals == null && endsWith == null && contains == null && uncompiledRegex == null) {
return true
}
- val message = if (unformatted) EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.unformattedText) else chatComponent.formattedText
+ val message =
+ if (unformatted) EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.unformattedText) else chatComponent.formattedText
equals?.forEach {
if (message == it) {
return true
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatTabs.kt
index 8d03ed6..68e1d23 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTabs.kt
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatTabs.kt
@@ -1,6 +1,9 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.chat
-import com.google.gson.*
+import com.google.gson.GsonBuilder
+import com.google.gson.JsonArray
+import com.google.gson.JsonObject
+import com.google.gson.JsonParser
import com.raeids.stratus.Stratus
import net.minecraft.client.Minecraft
import net.minecraft.util.IChatComponent
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt b/src/main/kotlin/com/raeids/stratus/chat/ChatTabsJson.kt
index b3a5e4c..020c8fc 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatTabsJson.kt
+++ b/src/main/kotlin/com/raeids/stratus/chat/ChatTabsJson.kt
@@ -1,4 +1,4 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.chat
import com.google.gson.JsonArray
import com.google.gson.annotations.SerializedName
diff --git a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
index 8600416..d67bfd0 100644
--- a/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
+++ b/src/main/kotlin/com/raeids/stratus/config/StratusConfig.kt
@@ -1,10 +1,10 @@
package com.raeids.stratus.config
import com.raeids.stratus.Stratus
+import com.raeids.stratus.chat.ChatShortcuts
+import com.raeids.stratus.chat.ChatTab
+import com.raeids.stratus.chat.ChatTabs
import com.raeids.stratus.gui.ChatShortcutViewGui
-import com.raeids.stratus.hook.ChatShortcuts
-import com.raeids.stratus.hook.ChatTab
-import com.raeids.stratus.hook.ChatTabs
import com.raeids.stratus.updater.DownloadGui
import com.raeids.stratus.updater.Updater
import gg.essential.api.EssentialAPI
@@ -43,14 +43,14 @@ object StratusConfig : Vigilant(File(Stratus.modDir, "${Stratus.ID}.toml"), Stra
category = "Tabs"
)
var chatTabs = true
- get() {
- if (!field) return false
- return if (hypixelOnlyChatTabs) {
- EssentialAPI.getMinecraftUtil().isHypixel()
- } else {
- true
+ get() {
+ if (!field) return false
+ return if (hypixelOnlyChatTabs) {
+ EssentialAPI.getMinecraftUtil().isHypixel()
+ } else {
+ true
+ }
}
- }
@Property(
type = PropertyType.SWITCH,
diff --git a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
index ce64c6a..351c07e 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutEditGui.kt
@@ -1,6 +1,6 @@
package com.raeids.stratus.gui
-import com.raeids.stratus.hook.ChatShortcuts
+import com.raeids.stratus.chat.ChatShortcuts
import gg.essential.api.EssentialAPI
import gg.essential.api.gui.buildConfirmationModal
import gg.essential.elementa.WindowScreen
@@ -15,7 +15,8 @@ import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.ButtonComponent
import gg.essential.vigilance.gui.settings.TextComponent
-class ChatShortcutEditGui(private var alias: String, private var command: String, private val editing: Boolean): WindowScreen(restoreCurrentGuiOnClose = true) {
+class ChatShortcutEditGui(private var alias: String, private var command: String, private val editing: Boolean) :
+ WindowScreen(restoreCurrentGuiOnClose = true) {
private val initialAlias = alias
private val initialCommand = command
@@ -69,7 +70,8 @@ class ChatShortcutEditGui(private var alias: String, private var command: String
} childOf window
}
- inner class ChatShortcutConfirmGui(private var alias: String, private var command: String): WindowScreen(restoreCurrentGuiOnClose = true) {
+ inner class ChatShortcutConfirmGui(private var alias: String, private var command: String) :
+ WindowScreen(restoreCurrentGuiOnClose = true) {
override fun initScreen(width: Int, height: Int) {
super.initScreen(width, height)
EssentialAPI.getEssentialComponentFactory().buildConfirmationModal {
diff --git a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
index ba8c771..06dfcbd 100644
--- a/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/ChatShortcutViewGui.kt
@@ -1,20 +1,16 @@
package com.raeids.stratus.gui
-import com.raeids.stratus.hook.ChatShortcuts
+import com.raeids.stratus.chat.ChatShortcuts
+import com.raeids.stratus.gui.components.TextBlock
import gg.essential.api.EssentialAPI
import gg.essential.elementa.WindowScreen
import gg.essential.elementa.components.UIBlock
-import gg.essential.elementa.components.UIText
import gg.essential.elementa.constraints.CenterConstraint
-import gg.essential.elementa.constraints.ChildBasedSizeConstraint
import gg.essential.elementa.constraints.RelativeWindowConstraint
import gg.essential.elementa.constraints.SiblingConstraint
import gg.essential.elementa.dsl.*
-import gg.essential.elementa.effects.OutlineEffect
-import gg.essential.elementa.state.BasicState
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.ButtonComponent
-import gg.essential.vigilance.gui.settings.SettingComponent
class ChatShortcutViewGui : WindowScreen() {
override fun initScreen(width: Int, height: Int) {
@@ -57,31 +53,4 @@ class ChatShortcutViewGui : WindowScreen() {
y = 80.percent()
} childOf window
}
-}
-
-class TextBlock(
- text: String
-) : SettingComponent() {
- private val textHolder = UIBlock().constrain {
- width = ChildBasedSizeConstraint() + 6.pixels()
- height = ChildBasedSizeConstraint() + 6.pixels()
- color = VigilancePalette.getDarkHighlight().toConstraint()
- } childOf this effect OutlineEffect(
- VigilancePalette.getDivider(),
- 1f
- ).bindColor(BasicState(VigilancePalette.getDivider()))
-
- private val textInput: UIText = UIText(text).constrain {
- x = 3.pixels()
- y = 3.pixels()
- }
-
- init {
- textInput childOf textHolder
-
- constrain {
- width = ChildBasedSizeConstraint()
- height = ChildBasedSizeConstraint()
- }
- }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt b/src/main/kotlin/com/raeids/stratus/gui/components/CleanButton.kt
index bc4db34..7ec29d4 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/CleanButton.kt
@@ -1,4 +1,4 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.gui.components
import club.sk1er.patcher.config.PatcherConfig
import com.raeids.stratus.Stratus
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ScreenshotButton.kt b/src/main/kotlin/com/raeids/stratus/gui/components/ScreenshotButton.kt
index 70c64c2..9e6fa1f 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/ScreenshotButton.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/ScreenshotButton.kt
@@ -1,4 +1,4 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.gui.components
import com.raeids.stratus.Stratus
import com.raeids.stratus.mixin.GuiNewChatAccessor
@@ -10,7 +10,8 @@ import net.minecraft.client.gui.GuiChat
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
-class ScreenshotButton: CleanButton(448318, { UResolution.scaledWidth - 28}, { UResolution.scaledHeight - 27}, 12, 12, "") {
+class ScreenshotButton :
+ CleanButton(448318, { UResolution.scaledWidth - 28 }, { UResolution.scaledHeight - 27 }, 12, 12, "") {
override fun onMousePress() {
val chat = Minecraft.getMinecraft().ingameGUI.chatGUI
diff --git a/src/main/kotlin/com/raeids/stratus/hook/CleanSearchButton.kt b/src/main/kotlin/com/raeids/stratus/gui/components/SearchButton.kt
index 7a68c75..3180482 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/CleanSearchButton.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/SearchButton.kt
@@ -1,6 +1,7 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.gui.components
import com.raeids.stratus.Stratus
+import com.raeids.stratus.hook.GuiNewChatHook
import gg.essential.universal.UResolution
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Gui
@@ -8,7 +9,8 @@ import net.minecraft.client.gui.GuiTextField
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
-class CleanSearchButton: CleanButton(3993935, {UResolution.scaledWidth - 14}, {UResolution.scaledHeight - 27}, 12, 12, "") {
+class SearchButton :
+ CleanButton(3993935, { UResolution.scaledWidth - 14 }, { UResolution.scaledHeight - 27 }, 12, 12, "") {
val inputField = SearchTextField()
private var chatBox = false
@@ -30,17 +32,24 @@ class CleanSearchButton: CleanButton(3993935, {UResolution.scaledWidth - 14}, {U
if (visible) {
mc.textureManager.bindTexture(ResourceLocation(Stratus.ID, "search.png"))
if (isEnabled()) {
- GlStateManager.color(224f/255f, 224f/255f, 224f/255f)
+ GlStateManager.color(224f / 255f, 224f / 255f, 224f / 255f)
} else if (mouseX >= xPosition && mouseX <= xPosition + 10 && mouseY >= yPosition && mouseY <= yPosition + 10) {
- GlStateManager.color(1f, 1f, 160f/255f)
+ GlStateManager.color(1f, 1f, 160f / 255f)
} else {
GlStateManager.color(1f, 1f, 1f)
}
- Gui.drawModalRectWithCustomSizedTexture(xPosition+1, yPosition+1, 0f, 0f, 10, 10, 10f, 10f)
+ Gui.drawModalRectWithCustomSizedTexture(xPosition + 1, yPosition + 1, 0f, 0f, 10, 10, 10f, 10f)
}
}
- inner class SearchTextField: GuiTextField(69420, Minecraft.getMinecraft().fontRendererObj, UResolution.scaledWidth * 4 / 5 - 60, UResolution.scaledHeight - 27, UResolution.scaledWidth / 5, 12) {
+ inner class SearchTextField : GuiTextField(
+ 69420,
+ Minecraft.getMinecraft().fontRendererObj,
+ UResolution.scaledWidth * 4 / 5 - 60,
+ UResolution.scaledHeight - 27,
+ UResolution.scaledWidth / 5,
+ 12
+ ) {
init {
maxStringLength = 100
diff --git a/src/main/kotlin/com/raeids/stratus/hook/CleanTabButton.kt b/src/main/kotlin/com/raeids/stratus/gui/components/TabButton.kt
index 0277dd8..48c399a 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/CleanTabButton.kt
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/TabButton.kt
@@ -1,10 +1,12 @@
-package com.raeids.stratus.hook
+package com.raeids.stratus.gui.components
+import com.raeids.stratus.chat.ChatTab
+import com.raeids.stratus.chat.ChatTabs
import gg.essential.universal.UResolution
-class CleanTabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val chatTab: ChatTab) :
+class TabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val chatTab: ChatTab) :
CleanButton(buttonId, { x }, {
- UResolution.scaledHeight - 26
+ UResolution.scaledHeight - 26
}, widthIn, heightIn, chatTab.name) {
override fun onMousePress() {
diff --git a/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt b/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
new file mode 100644
index 0000000..9b36fa4
--- /dev/null
+++ b/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
@@ -0,0 +1,37 @@
+package com.raeids.stratus.gui.components
+
+import gg.essential.elementa.components.UIBlock
+import gg.essential.elementa.components.UIText
+import gg.essential.elementa.constraints.ChildBasedSizeConstraint
+import gg.essential.elementa.dsl.*
+import gg.essential.elementa.effects.OutlineEffect
+import gg.essential.elementa.state.BasicState
+import gg.essential.vigilance.gui.VigilancePalette
+import gg.essential.vigilance.gui.settings.SettingComponent
+
+class TextBlock(
+ text: String
+) : SettingComponent() {
+ private val textHolder = UIBlock() constrain {
+ width = ChildBasedSizeConstraint() + 6.pixels()
+ height = ChildBasedSizeConstraint() + 6.pixels()
+ color = VigilancePalette.getDarkHighlight().toConstraint()
+ } childOf this effect OutlineEffect(
+ VigilancePalette.getDivider(),
+ 1f
+ ).bindColor(BasicState(VigilancePalette.getDivider()))
+
+ private val textInput: UIText = UIText(text) constrain {
+ x = 3.pixels()
+ y = 3.pixels()
+ }
+
+ init {
+ textInput childOf textHolder
+
+ constrain {
+ width = ChildBasedSizeConstraint()
+ height = ChildBasedSizeConstraint()
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt b/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
deleted file mode 100644
index 6dd4904..0000000
--- a/src/main/kotlin/com/raeids/stratus/hook/ChatSearching.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.raeids.stratus.hook
-
-import gg.essential.lib.caffeine.cache.Cache
-import gg.essential.lib.caffeine.cache.Caffeine
-import gg.essential.universal.wrappers.message.UTextComponent
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.ChatLine
-import java.util.concurrent.LinkedBlockingQueue
-import java.util.concurrent.ThreadPoolExecutor
-import java.util.concurrent.TimeUnit
-import java.util.concurrent.atomic.AtomicInteger
-
-private var counter: AtomicInteger = AtomicInteger(0)
-private var POOL: ThreadPoolExecutor = ThreadPoolExecutor(
- 50, 50,
- 0L, TimeUnit.SECONDS,
- LinkedBlockingQueue()
-) { r ->
- Thread(
- r,
- "Chat Filter Cache Thread ${counter.incrementAndGet()}"
- )
-}
-
-val cache: Cache<String, List<ChatLine>> = Caffeine.newBuilder().executor(POOL).maximumSize(5000).build()
-
-fun filterMessages(text: String, list: List<ChatLine>): List<ChatLine>? {
- if (text.isBlank()) return list
- val cached = cache.getIfPresent(text)
- return cached ?: run {
- cache.put(text, list.filter {
- UTextComponent.stripFormatting(it.chatComponent.unformattedText).lowercase()
- .contains(text.lowercase())
- })
- cache.getIfPresent(text)
- }
-}
-
-fun setPrevText(text: String) {
- (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).prevText = text
-} \ No newline at end of file
diff --git a/src/main/kotlin/com/raeids/stratus/hook/ModCompatHooks.kt b/src/main/kotlin/com/raeids/stratus/hook/ModCompatHooks.kt
deleted file mode 100644
index e2ac629..0000000
--- a/src/main/kotlin/com/raeids/stratus/hook/ModCompatHooks.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.raeids.stratus.hook
-
-import club.sk1er.patcher.config.PatcherConfig
-import com.llamalad7.betterchat.BetterChat
-
-// This exists because mixin doesn't like dummy classes
-object ModCompatHooks {
- @JvmStatic
- val xOffset
- get() = BetterChat.getSettings().xOffset
-
- @JvmStatic
- val yOffset
- get() = BetterChat.getSettings().yOffset
-
- @JvmStatic
- val chatPosition
- get() = PatcherConfig.chatPosition
-
-}
diff --git a/src/main/kotlin/com/raeids/stratus/updater/Updater.kt b/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
index 2f48cdb..11368fd 100644
--- a/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
+++ b/src/main/kotlin/com/raeids/stratus/updater/Updater.kt
@@ -27,7 +27,9 @@ object Updater {
DefaultArtifactVersion(Stratus.VER.substringBefore("-"))
val latestVersion = DefaultArtifactVersion(latestTag!!.substringAfter("v").substringBefore("-"))
if (currentVersion >= latestVersion) {
- return@runAsync
+ if (!Stratus.VER.contains("-")) {
+ return@runAsync
+ }
}
updateUrl =
latestRelease["assets"].asJsonArray[0].asJsonObject["browser_download_url"]
diff --git a/src/main/kotlin/com/raeids/stratus/utils/ImageTransferable.kt b/src/main/kotlin/com/raeids/stratus/utils/ImageTransferable.kt
index 81571a5..a8fe9fb 100644
--- a/src/main/kotlin/com/raeids/stratus/utils/ImageTransferable.kt
+++ b/src/main/kotlin/com/raeids/stratus/utils/ImageTransferable.kt
@@ -5,7 +5,7 @@ import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.Transferable
import java.awt.datatransfer.UnsupportedFlavorException
-class ImageTransferable(private val image: Image): Transferable {
+data class ImageTransferable(private val image: Image) : Transferable {
override fun getTransferDataFlavors(): Array<DataFlavor> {
return arrayOf(DataFlavor.imageFlavor)
diff --git a/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt b/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt
new file mode 100644
index 0000000..48463a6
--- /dev/null
+++ b/src/main/kotlin/com/raeids/stratus/utils/ModCompatHooks.kt
@@ -0,0 +1,26 @@
+package com.raeids.stratus.utils
+
+import club.sk1er.patcher.config.PatcherConfig
+import com.llamalad7.betterchat.BetterChat
+import com.raeids.stratus.Stratus.isBetterChat
+import com.raeids.stratus.Stratus.isPatcher
+
+// This exists because mixin doesn't like dummy classes
+object ModCompatHooks {
+ @JvmStatic
+ val xOffset
+ get() = if (isBetterChat) BetterChat.getSettings().xOffset else 0
+
+ @JvmStatic
+ val yOffset
+ get() = if (isBetterChat) BetterChat.getSettings().yOffset else 0
+
+ @JvmStatic
+ val chatPosition
+ get() = if (isPatcher && PatcherConfig.chatPosition) 12 else 0
+
+ @JvmStatic
+ val extendedChatLength
+ get() = if (isPatcher) 32667 else 0
+
+}
diff --git a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
index 664f5de..95de4d8 100644
--- a/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
+++ b/src/main/kotlin/com/raeids/stratus/utils/RenderHelper.kt
@@ -144,7 +144,8 @@ object RenderHelper {
e.printStackTrace()
}
}
- val pixels: IntArray = bufferedImage.getRGB(0, 0, bufferedImage.width, bufferedImage.height, null, 0, bufferedImage.width)
+ val pixels: IntArray =
+ bufferedImage.getRGB(0, 0, bufferedImage.width, bufferedImage.height, null, 0, bufferedImage.width)
val newImage = BufferedImage(bufferedImage.width, bufferedImage.height, BufferedImage.TYPE_INT_RGB)
newImage.setRGB(0, 0, newImage.width, newImage.height, pixels, 0, newImage.width)