mirror of
https://codeberg.org/moonleay/Gimbal.git
synced 2025-07-17 02:45:45 +02:00
chore: renamed to Gimbal, because I cannot spell apparently
Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
1c7138bb58
commit
c14cdffeed
50 changed files with 322 additions and 279 deletions
44
src/main/java/net/moonleay/gimbal/client/util/ChatUtil.kt
Normal file
44
src/main/java/net/moonleay/gimbal/client/util/ChatUtil.kt
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Gimbal
|
||||
* Copyright (C) 2024 moonleay
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.gimbal.client.util
|
||||
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.client.toast.SystemToast
|
||||
import net.minecraft.text.Text
|
||||
|
||||
object ChatUtil {
|
||||
/**
|
||||
* Note: command arg should contain "/" at the beginning.
|
||||
* */
|
||||
fun sendCommand(command: String, client: MinecraftClient, addToHistory: Boolean = true): Boolean {
|
||||
if (addToHistory) {
|
||||
client.inGameHud.chatHud.addToMessageHistory(command)
|
||||
}
|
||||
return client.player?.sendCommand(command.substring(1))?: false
|
||||
}
|
||||
|
||||
fun addToChatHistory(message: String, client: MinecraftClient) {
|
||||
client.inGameHud.chatHud.addMessage(Text.of(message))
|
||||
}
|
||||
|
||||
fun showToastToSelf(title: String, description: String, client: MinecraftClient) {
|
||||
val toast = SystemToast(SystemToast.Type.PERIODIC_NOTIFICATION, Text.of(title), Text.of(description))
|
||||
client.toastManager.add(toast)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue