update to 1.18.2
This commit is contained in:
@@ -1,36 +1,40 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.extensions.bukkit
|
||||
|
||||
import net.axay.kspigot.chat.KColors
|
||||
import net.axay.kspigot.main.PluginInstance
|
||||
import net.md_5.bungee.api.ChatColor
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.print(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name ?: "INFO", KColors.GRAY)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.info(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name ?: "INFO", KColors.DARKAQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.success(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA)
|
||||
printColoredPrefix(text, KColors.GREEN, plugin?.name ?: "SUCCESS", KColors.DARKAQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.warn(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", KColors.YELLOW)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.error(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED)
|
||||
printColoredPrefix(text, KColors.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", KColors.DARKRED)
|
||||
|
||||
/**
|
||||
* Sends the given message and adds the given prefix with the given color to it.
|
||||
*/
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: ChatColor, prefix: String, prefixColor: ChatColor) =
|
||||
sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: TextColor, prefix: String, prefixColor: TextColor) =
|
||||
sendMessage(Component.text(prefix).color(prefixColor).append(Component.text(text).color(textColor)))
|
||||
|
||||
/**
|
||||
* Dispatches the command given by [commandLine].
|
||||
|
Reference in New Issue
Block a user