diff options
-rw-r--r-- | src/main/kotlin/dulkirmod/features/Croesus.kt | 23 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/chat/Bridge.kt | 21 |
2 files changed, 40 insertions, 4 deletions
diff --git a/src/main/kotlin/dulkirmod/features/Croesus.kt b/src/main/kotlin/dulkirmod/features/Croesus.kt index e38616c..36bf3ee 100644 --- a/src/main/kotlin/dulkirmod/features/Croesus.kt +++ b/src/main/kotlin/dulkirmod/features/Croesus.kt @@ -12,10 +12,12 @@ import net.minecraftforge.fml.common.gameevent.TickEvent class Croesus { var lastGuiOpenEvent: Long = 0 + var lastPageNumber = 1 @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { val lastInCroesus = inCroesusBool + var pageNumber = 1 if (!Config.hideOpenedChests) return if (mc.currentScreen == null || !(mc.currentScreen is GuiChest)) { @@ -24,6 +26,14 @@ class Croesus { } inCroesusBool = (ContainerNameUtil.currentGuiChestName == "Croesus") + if (inCroesusBool) { + pageNumber = findPageNumber() + } + + // weird way of detecting page turn + if(lastPageNumber != pageNumber) + lastGuiOpenEvent = System.currentTimeMillis() + if (inCroesusBool && !lastInCroesus) { lastGuiOpenEvent = System.currentTimeMillis() } @@ -35,9 +45,8 @@ class Croesus { if (slotIn.stack == null) continue val stack = slotIn.stack - if (stack.getSubCompound("display", true)?.getTagList("Lore", 8) == null) continue - val tagList: NBTTagList = stack.getSubCompound("display", true).getTagList("Lore", 8) + val tagList: NBTTagList = stack.getSubCompound("display", false)?.getTagList("Lore", 8) ?: continue for (j in 0 until tagList.tagCount()) { if (tagList.getStringTagAt(j) == "§aChests have been opened!") boolArray[i - 9] = true } @@ -45,6 +54,16 @@ class Croesus { } } + private fun findPageNumber(): Int { + val stackPrev = mc.thePlayer.openContainer.getSlot(45).stack ?: return lastPageNumber + + val stackPrevLore = stackPrev.getSubCompound("display", false)?.getTagList("Lore", 8) ?: return 1 + + if (stackPrevLore.getStringTagAt(0).contains("1")) return 2 + + return 3 + } + companion object { var inCroesusBool: Boolean = false var boolArray = BooleanArray(36) { false } diff --git a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt index 88430af..326ab96 100644 --- a/src/main/kotlin/dulkirmod/features/chat/Bridge.kt +++ b/src/main/kotlin/dulkirmod/features/chat/Bridge.kt @@ -8,9 +8,11 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent object Bridge { private val guildFormat = - "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: (\\w+) > .+".toRegex() + "^(§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() + "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([\\w ]+): .+".toRegex() + private val otherAltFormat = + "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9]\\[[A-Z]+])?§f: ([\\w ]+) » .+".toRegex() fun handle(event: ClientChatReceivedEvent) { val message = event.message.unformattedText @@ -44,5 +46,20 @@ object Bridge { ).setChatStyle(event.message.siblings[1].chatStyle.createShallowCopy()) } } + + else if (otherAltFormat matches message && Config.bridgeBot) { + val matchResult = otherAltFormat.find(message) + val (prefix, name, playerName) = matchResult!!.destructured + if (Utils.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 |