A small DSL to make building a conversation in Bukkit easy.

Related tags

Kotlin konversation
Overview

Konversation

Konversation provides a simple builder to construct chains of prompts to be used in the conversation API present in Bukkit. Bukkit only provides abstract base classes without any generic implementations. As such, a user would need to create their own implementations for each and every prompt. Because of this, it is often not easy to see the flow of prompts or the entire configured conversation. Because they'd each be their own implementation, it would create a lot of fragmentation. The result of this is that the entire API is neglected and other options will be used.

This tries to help build an easy-to-understand flow for a conversation, making it easy to follow and create. Konversation provides a small builder DSL for building the chain of prompts. It supports all the prompts that are already in the Bukkit API, but also allows adding custom prompts. There are some limitations, which are listed in the limitations below. At this stage, not all options from the existing inputs are exposed in this DSL, but will be exposed over time. An example for this would be failure messages.

Example

val firstPrompt = buildPrompts {
    message("Welcome to this survey!")
    message("This dialog will guide your through.")
    text("Please enter your name:") { input, context ->
        if(input.isEmpty()) {
            retry()
        } else {
            context["name"] = input
        }
    }
    select("Please specify your minecraft gaming experience:", "Beginner", "Advanced", "Expert") { input, context ->
        context["experience"] = input
    }
    custom(
        { "Rate your experience between 1 and 10:" },
        { input -> 
            try {
                val number = Integer.valueOf(input)
                number >= 1 && number <= 10
            } catch(ex: NumberFormatException) {
                false
            }
        },
        Integer::valueOf
    ) { value, context ->
        context["rating"] = value
    }
    message("Thank you for taking this survey!") { context ->
        val name: String = context["name"]!!
        val experience: String = context["experience"]!!
        val rating: Int = context["rating"]!!
        SurveryCollector.collectEntry(name, experience, rating)
    }
}

This prompt can then be used in the ConversationFactory as the initial prompt.

Getting It

You can get library from my repository:

<repository>
    <id>eternalwings</id>
    <url>https://repo.eternalwings.de/releases/</url>
</repository>

with this artifact:

<dependency>
    <groupId>de.eternalwings.bukkit</groupId>
    <artifactId>konversation</artifactId>
    <version>1.0.0</version>
</dependency>

Limitations

In the conversations api, you can - at any time - just return "null" or "END_OF_INPUT". We don't currently provide such a shortcut.

In the conversations api, the prompt you return might be any prompt and thus also a prompt that was used earlier. So far, we only support retrying the current prompt which might be a little limiting.

You might also like...
Kotlin Dsl for Android RecyclerView

KRecyclerDsl Kotlin Dsl for Android RecyclerView Exemple Sample project recyclerView.adapter = dataClassAdapterMyView, MyDataClass(R.layout.my_view,

The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.

Lychee (ex. reactive-properties) Lychee is a library to rule all the data. ToC Approach to declaring data Properties Other data-binding libraries Prop

Nice and simple DSL for Espresso in Kotlin
Nice and simple DSL for Espresso in Kotlin

Kakao Nice and simple DSL for Espresso in Kotlin Introduction At Agoda, we have more than 1000 automated tests to ensure our application's quality and

DSL for constructing the drawables in Kotlin instead of in XML

Android Drawable Kotlin DSL DSL for constructing the drawables in Kotlin instead of in XML Examples Shape drawables ?xml version="1.0" encoding="utf-

Lightweight Kotlin DSL dependency injection library
Lightweight Kotlin DSL dependency injection library

Warehouse DSL Warehouse is a lightweight Kotlin DSL dependency injection library this library has an extremely faster learning curve and more human fr

Code generation of Kotlin DSL for AWS CDK

Code generation of Kotlin DSL for AWS CDK

Regular expression DSL on Kotlin

Examples Characters Construct Equivalent Matches x character(Char) The character x \\ character('\\') The backslash character \0n octal(OctalValue(7))

Kotlin Object Notation - Lightweight DSL to build fluid JSON trees

Kotlin Object Notation Lightweight kotlin MPP DSL for building JSON trees Setup Just drop the dependency in your commonMain sourceSet kotlin { sourc

Kotlin DSL for Junit5

Kupiter is Kotlin DSL for Junit5. Current API is only for dynamic tests. Get it repositories { maven { url 'https://jitpack.io' } } dependencies

Owner
Tim Hagemann
Software Engineer. Linux friend. Automation enthusiast.
Tim Hagemann
Simple cron command runner for Bukkit 1.17+

Cron Runner Description / 설명 Simple cron command runner for Bukkit 1.17+ Bukkit 1.17 이상을 위한 간단한 cron 명령어 실행기 입니다. Configuration Guide (config.yml) deb

Patrick 3 Sep 24, 2021
Coroutine for Bukkit

Heartbeat Coroutines 두근두근 ❤️ 코루틴 Coroutine for Paper Features Bukkit의 mainHeartBeat(GameLoop)에서 dispatch되는 Coroutine JavaPlugin 생명주기의 CoroutineScope 유

null 22 Dec 18, 2022
Slime World Format implementation written in Kotlin with Zstd for bukkit.

Slime Korld Easily create many slime worlds with the Slime Korld. What is Slime Korld? Slime Korld is a bukkit library written in Kotlin to make minec

Luiz Otávio 11 Nov 15, 2022
A collection of small utility functions to make it easier to deal with some otherwise nullable APIs on Android.

requireKTX requireKTX is a collection of small utility functions to make it easier to deal with some otherwise nullable APIs on Android, using the sam

Márton Braun 82 Oct 1, 2022
Kotlin parser library with an easy-to-use DSL

Pratt Library for parsing expressions and a beautiful Kotlin DSL Just define your operators and operands with the Kotlin DSL and the parser is ready!

furetur 9 Oct 17, 2022
A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

Nek.12 4 Oct 31, 2022
A simple and easy adapter for RecyclerView. You don't have to make adapters and view holders anymore. Slush will help you.

한국어 No more boilerplate adapters and view holders. Slush will make using RecyclerView easy and fast. The goal of this project is to make RecyclerView,

SeungHyun 26 Sep 13, 2022
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = ❤️

kotlin-android-template ?? A simple Github template that lets you create an Android/Kotlin project and be up and running in a few seconds. This templa

Nicola Corti 1.5k Jan 3, 2023
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.

MaterialDrawerKt Create navigation drawers in your Activities and Fragments without having to write any XML, in pure Kotlin code, with access to all t

Márton Braun 517 Nov 19, 2022
{ } Declarative Kotlin DSL for choreographing Android transitions

Transition X Kotlin DSL for choreographing Android Transitions TransitionManager makes it easy to animate simple changes to layout without needing to

Arunkumar 520 Dec 16, 2022