Fixed tab-to-reply
Expanded on the ContentAPI to include the ability to use all input dialogue types.
This commit is contained in:
@@ -956,8 +956,25 @@ object ContentAPI {
|
|||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: (value: Any) -> Unit){
|
fun sendInputDialogue(player: Player, numeric: Boolean, prompt: String, handler: (value: Any) -> Unit){
|
||||||
player.dialogueInterpreter.sendInput(!numeric, prompt)
|
if(numeric) sendInputDialogue(player, InputType.NUMERIC, prompt, handler)
|
||||||
player.setAttribute("runscript",handler) //Handled in RunScriptPacketHandler
|
else sendInputDialogue(player, InputType.STRING_SHORT, prompt, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send input dialogues based on type. Some dialogues are special and can't be covered by the other sendInputDialogue method
|
||||||
|
* @param player the player to send the input dialogue to
|
||||||
|
* @param type the input type to send - an enum is available for this called InputType
|
||||||
|
* @param prompt what to prompt the player
|
||||||
|
* @param handler the method that handles the value from the input dialogue
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun sendInputDialogue(player: Player, type: InputType, prompt: String, handler: (value: Any) -> Unit){
|
||||||
|
when(type){
|
||||||
|
InputType.NUMERIC, InputType.STRING_SHORT -> player.dialogueInterpreter.sendInput(type != InputType.NUMERIC, prompt)
|
||||||
|
InputType.STRING_LONG -> player.dialogueInterpreter.sendLongInput(prompt)
|
||||||
|
InputType.MESSAGE -> player.dialogueInterpreter.sendMessageInput(prompt)
|
||||||
|
}
|
||||||
|
player.setAttribute("runscript", handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
enum class InputType {
|
||||||
|
NUMERIC,
|
||||||
|
STRING_SHORT,
|
||||||
|
STRING_LONG,
|
||||||
|
MESSAGE
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package rs09.game.system.command.sets
|
package rs09.game.system.command.sets
|
||||||
|
|
||||||
import api.ContentAPI
|
import api.ContentAPI
|
||||||
|
import api.InputType
|
||||||
import core.cache.def.impl.ItemDefinition
|
import core.cache.def.impl.ItemDefinition
|
||||||
import core.cache.def.impl.NPCDefinition
|
import core.cache.def.impl.NPCDefinition
|
||||||
import core.cache.def.impl.SceneryDefinition
|
import core.cache.def.impl.SceneryDefinition
|
||||||
@@ -201,7 +202,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
|||||||
if (player.attributes.containsKey("replyTo")) {
|
if (player.attributes.containsKey("replyTo")) {
|
||||||
player.setAttribute("keepDialogueAlive", true)
|
player.setAttribute("keepDialogueAlive", true)
|
||||||
val replyTo = player.getAttribute("replyTo", "").replace("_".toRegex(), " ")
|
val replyTo = player.getAttribute("replyTo", "").replace("_".toRegex(), " ")
|
||||||
ContentAPI.sendInputDialogue(player, false ,StringUtils.formatDisplayName(replyTo)){value ->
|
ContentAPI.sendInputDialogue(player, InputType.MESSAGE ,StringUtils.formatDisplayName(replyTo)){ value ->
|
||||||
CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), value as String)
|
CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), value as String)
|
||||||
player.removeAttribute("keepDialogueAlive")
|
player.removeAttribute("keepDialogueAlive")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user