summaryrefslogtreewikicommitdiff
path: root/core/src/command/Confirm.kt
blob: 359f490a0a303855327d9a134f711be80b616c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cat.freya.khs.command

import cat.freya.khs.Khs
import cat.freya.khs.REQUESTS
import cat.freya.khs.command.util.Command
import cat.freya.khs.player.Player

class KhsConfirm : Command {
    override val label = "confirm"
    override val usage = listOf<String>()
    override val description = "Confirm a request of a previously run command"

    override fun execute(plugin: Khs, player: Player, args: List<String>) {
        val request = REQUESTS.remove(player.uuid)

        if (request == null) {
            player.message(plugin.locale.prefix.error + plugin.locale.confirm.none)
            return
        }

        if (request.expired) {
            player.message(plugin.locale.prefix.error + plugin.locale.confirm.timedOut)
            return
        }

        request.fn()
    }

    override fun autoComplete(plugin: Khs, parameter: String, typed: String): List<String> {
        return listOf()
    }
}