Update KSpigotChat.kt
This commit is contained in:
@@ -4,7 +4,7 @@ package net.axay.kspigot.chat
|
|||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor
|
import net.md_5.bungee.api.ChatColor
|
||||||
import net.md_5.bungee.api.chat.*
|
import net.md_5.bungee.api.chat.*
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.command.CommandSender
|
||||||
|
|
||||||
object KSpigotChat {
|
object KSpigotChat {
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ object KSpigotChat {
|
|||||||
return KSpigotComponentBuilder().apply(builder).create()
|
return KSpigotComponentBuilder().apply(builder).create()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Player.sendMessage(vararg components: BaseComponent) {
|
fun CommandSender.sendMessage(vararg components: BaseComponent) {
|
||||||
this.spigot().sendMessage(*components)
|
this.spigot().sendMessage(*components)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,17 +20,12 @@ object KSpigotChat {
|
|||||||
* Takes objects of the type [String] or [ChatColor],
|
* Takes objects of the type [String] or [ChatColor],
|
||||||
* combines them to a message and sends it to the player.
|
* combines them to a message and sends it to the player.
|
||||||
*/
|
*/
|
||||||
fun Player.sendMessage(vararg messageParts: Any) {
|
fun CommandSender.sendMessage(vararg messageParts: Any) {
|
||||||
sendMessage(buildComponent {
|
sendMessage(buildComponent {
|
||||||
|
|
||||||
var currentColor = ChatColor.WHITE
|
var currentColor = ChatColor.WHITE
|
||||||
val currentMessage = StringBuilder()
|
val currentMessage = StringBuilder()
|
||||||
|
|
||||||
for (messagePart in messageParts.withIndex()) {
|
|
||||||
|
|
||||||
val index = messagePart.index
|
|
||||||
val value = messagePart.value
|
|
||||||
|
|
||||||
fun buildText() {
|
fun buildText() {
|
||||||
text {
|
text {
|
||||||
text = currentMessage.toString()
|
text = currentMessage.toString()
|
||||||
@@ -39,6 +34,11 @@ object KSpigotChat {
|
|||||||
currentMessage.clear()
|
currentMessage.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (messagePart in messageParts.withIndex()) {
|
||||||
|
|
||||||
|
val index = messagePart.index
|
||||||
|
val value = messagePart.value
|
||||||
|
|
||||||
if (value is String) {
|
if (value is String) {
|
||||||
currentMessage.append(value)
|
currentMessage.append(value)
|
||||||
if (index == messageParts.lastIndex)
|
if (index == messageParts.lastIndex)
|
||||||
|
Reference in New Issue
Block a user