From 5f92170d06b27d7c5375630299bd2b61242d9e4d Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Fri, 23 Oct 2020 02:41:49 +0200 Subject: [PATCH] Update PlayerInput.kt --- .../net/axay/kspigot/chat/input/PlayerInput.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/axay/kspigot/chat/input/PlayerInput.kt b/src/main/kotlin/net/axay/kspigot/chat/input/PlayerInput.kt index 8d934716..1087e750 100644 --- a/src/main/kotlin/net/axay/kspigot/chat/input/PlayerInput.kt +++ b/src/main/kotlin/net/axay/kspigot/chat/input/PlayerInput.kt @@ -16,18 +16,22 @@ import org.bukkit.event.Listener import org.bukkit.event.inventory.InventoryClickEvent import org.bukkit.event.player.AsyncPlayerChatEvent -fun Player.awaitChatInput(timeoutSeconds: Int = 1 * 60, callback: (String?) -> Unit) { +fun Player.awaitChatInput( + question: String = "Type your input in the chat!", + timeoutSeconds: Int = 1 * 60, + callback: (String?) -> Unit +) { PlayerInputChat(this, callback, timeoutSeconds) } fun Player.awaitAnvilInput( - timeoutSeconds: Int = 1 * 60, invTitle: String = "Type your input!", startText: String = "RENAME ME", renameItemDescription: List = listOf( "Rename this item to", "submit your input!" ), + timeoutSeconds: Int = 1 * 60, callback: (String?) -> Unit ) { PlayerInputAnvilInv(this, callback, timeoutSeconds, invTitle, startText, renameItemDescription) @@ -64,9 +68,12 @@ internal abstract class PlayerInput( internal class PlayerInputChat( player: Player, callback: (String?) -> Unit, - timeoutSeconds: Int + timeoutSeconds: Int, + question: String ) : PlayerInput(player, callback, timeoutSeconds) { + init { player.sendMessage("${KColors.ORANGERED}$question") } + override val inputListeners = listOf( listen(EventPriority.LOWEST) { if (it.player == player) {