diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyCommands.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyCommands.kt index 63fa195..435a07e 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyCommands.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/ChattyCommands.kt @@ -320,6 +320,9 @@ class ChattyCommands : IdofrontCommandExecutor(), TabCompleter { } } + private fun Player.sendFormattedMessage(message: String, optionalPlayer: Player? = null) = + this.sendMessage(translatePlaceholders((optionalPlayer ?: this), message).serialize().miniMsg()) + private fun Player.handleSendingPrivateMessage(player: Player, arguments: List, isReply: Boolean = false) { if (!chattyConfig.privateMessages.enabled) { this.sendFormattedMessage(chattyMessages.privateMessages.disabled) @@ -343,25 +346,7 @@ class ChattyCommands : IdofrontCommandExecutor(), TabCompleter { } } - private fun Player.swapChannelCommand(channelId: String) { - val newChannel = getChannelFromId(channelId) - if (newChannel == null) { - sendFormattedMessage(chattyMessages.channels.noChannelWithName) - } else if (!checkPermission(newChannel.permission)) { - sendFormattedMessage(chattyMessages.channels.missingChannelPermission) - } else { - chattyData.channelId = channelId - chattyData.lastChannelUsed = channelId - sendFormattedMessage(chattyMessages.channels.channelChanged) - } - } - - private fun Player.sendFormattedMessage(message: String) = - this.sendMessage(translatePlaceholders(this, message).serialize().miniMsg()) - - private fun Player.sendFormattedMessage(message: String, optionalPlayer: Player? = null) = - this.sendMessage(translatePlaceholders((optionalPlayer ?: this), message).serialize().miniMsg()) private fun Player.sendFormattedPrivateMessage(messageFormat: String, message: String, receiver: Player) = this.sendMessage((translatePlaceholders(receiver, messageFormat).serialize() + message).miniMsg()) diff --git a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt index d1635bb..fbdf09e 100644 --- a/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt +++ b/chatty-paper/src/main/kotlin/com/mineinabyss/chatty/helpers/ChatHelpers.kt @@ -187,3 +187,22 @@ fun List.toSentence() = this.joinToString(" ") fun String.toPlayer(): Player? { return Bukkit.getPlayer(this) } + +fun Player.swapChannelCommand(channelId: String) { + val newChannel = getChannelFromId(channelId) + + if (newChannel == null) { + sendFormattedMessage(chattyMessages.channels.noChannelWithName) + } else if (!checkPermission(newChannel.permission)) { + sendFormattedMessage(chattyMessages.channels.missingChannelPermission) + } else { + chattyData.channelId = channelId + chattyData.lastChannelUsed = channelId + sendFormattedMessage(chattyMessages.channels.channelChanged) + } +} + +fun Player.sendFormattedMessage(message: String) = + this.sendMessage(translatePlaceholders(this, message).serialize().miniMsg()) + +