/* * 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 . */ 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) } }