diff options
| author | ShanaSplatoon <132563986+ShanaSplatoon@users.noreply.github.com> | 2023-05-07 17:05:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-07 17:05:45 +0200 |
| commit | 88ada6aa82c8672b81ca4c30d74296c451a3f26e (patch) | |
| tree | 9e42b081df4dc7e658f42bd0549034ee9b5bdcd8 /src/main/java/at/hannibal2/skyhanni/utils | |
| parent | 23c8e2ad407d1889cdb4af38c64f0155f33bb105 (diff) | |
| download | SkyHanni-88ada6aa82c8672b81ca4c30d74296c451a3f26e.tar.gz SkyHanni-88ada6aa82c8672b81ca4c30d74296c451a3f26e.tar.bz2 SkyHanni-88ada6aa82c8672b81ca4c30d74296c451a3f26e.zip | |
Added Inquis Share (#95)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 12 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 4a67184f2..df636e0ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -234,13 +234,17 @@ object LorenzUtils { return this } - private var lastCommandSent = 0L + private var lastMessageSent = 0L fun sendCommandToServer(command: String) { - if (System.currentTimeMillis() > lastCommandSent + 2_000) { - lastCommandSent = System.currentTimeMillis() + sendMessageToServer("/$command") + } + + fun sendMessageToServer(message: String) { + if (System.currentTimeMillis() > lastMessageSent + 2_000) { + lastMessageSent = System.currentTimeMillis() val thePlayer = Minecraft.getMinecraft().thePlayer - thePlayer.sendChatMessage("/$command") + thePlayer.sendChatMessage(message) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 06187da3c..b13dbc59a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -57,9 +57,19 @@ object StringUtils { fun String.matchRegex(@Language("RegExp") regex: String): Boolean = regex.toRegex().matches(this) - private fun String.removeAtBeginning(text: String): String = if (this.startsWith(text)) substring(text.length) else this + private fun String.removeAtBeginning(text: String): String = + if (this.startsWith(text)) substring(text.length) else this // TODO find better name for this method inline fun <T> Pattern.matchMatcher(text: String, consumer: Matcher.() -> T) = matcher(text).let { if (it.matches()) consumer(it) else null } + + fun String.cleanPlayerName(): String { + val split = split(" ") + return if (split.size > 1) { + split[1].removeColor() + } else { + split[0].removeColor() + } + } } |
