diff options
author | inglettronald <inglettronald@gmail.com> | 2023-06-08 19:56:41 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-06-08 19:56:41 -0500 |
commit | 4e4043e5408038dde4c862da82d8a0a9bb40e950 (patch) | |
tree | ba21698d9ab371b54abaeb4b179356a0cd8ff839 /src/main/kotlin/com/dulkirfabric/util | |
parent | 4c66db32ac1f7ae1c260195fc50acf39831dd88b (diff) | |
download | DulkirMod-Fabric-4e4043e5408038dde4c862da82d8a0a9bb40e950.tar.gz DulkirMod-Fabric-4e4043e5408038dde4c862da82d8a0a9bb40e950.tar.bz2 DulkirMod-Fabric-4e4043e5408038dde4c862da82d8a0a9bb40e950.zip |
initial commit
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/TextUtils.kt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt new file mode 100644 index 0000000..6f904ac --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/TextUtils.kt @@ -0,0 +1,31 @@ +package com.dulkirfabric.util + +import com.dulkirfabric.DulkirModFabric.mc +import net.minecraft.text.Text + +object TextUtils { + const val CHAT_PREFIX = "§f<§3DulkirMod§f>§r" + fun info(text: String, prefix: Boolean = true) { + if (mc.player == null) return + + val textPrefix = if (prefix) "${CHAT_PREFIX} " else "" + mc.inGameHud.chatHud.addMessage(Text.literal("$textPrefix$text§r")) + } + + fun toggledMessage(message: String, state: Boolean) { + val stateText = if (state) "§aON" else "§cOFF" + info("§9Toggled $message §8[$stateText§8]§r") + } + + fun sendPartyChatMessage(message: String) { + this.sendCommand("/pc $message") + } + + fun sendMessage(message: String) { + mc.player?.networkHandler?.sendChatMessage(message) + } + + fun sendCommand(command: String) { + mc.player?.networkHandler?.sendChatCommand(command) + } +}
\ No newline at end of file |