<commit_before>package com.projectcitybuild.spigot.modules.bans.commands

import com.okkero.skedule.BukkitDispatcher
import com.projectcitybuild.core.contracts.Commandable
import com.projectcitybuild.core.contracts.Environment
import com.projectcitybuild.spigot.extensions.getOfflinePlayer
import com.projectcitybuild.spigot.modules.bans.actions.CheckBanStatusAction
import kotlinx.coroutines.experimental.launch
import org.bukkit.command.CommandSender
import java.util.*

class BanStatusCommand : Commandable {
    override var environment: Environment? = null
    override val label: String = "status"

    override fun execute(sender: CommandSender, args: Array<String>, isConsole: Boolean): Boolean {
        val environment = environment ?: throw Exception("Environment is null")
        val plugin = environment.plugin ?: throw Exception("Plugin has already been deallocated")

        launch(BukkitDispatcher(plugin, async = true)) {
            val targetPlayerName = args.first()
            val playerUUID = sender.server.getOfflinePlayer(name = targetPlayerName, environment = environment)
            if (playerUUID == null) {
                sender.sendMessage("Error: Failed to retrieve UUID of given player")
                return@launch
            }

            val action = CheckBanStatusAction(environment)
            val result = action.execute(
                    playerId = playerUUID
            )
            if (result is CheckBanStatusAction.Result.FAILED) {
                when (result.reason) {
                    CheckBanStatusAction.Failure.DESERIALIZE_FAILED -> {
                        sender.sendMessage("Error: Bad response received from the ban server. Please contact an admin")
                    }
                }
            }
            if (result is CheckBanStatusAction.Result.SUCCESS) {
                if (result.ban == null) {
                    sender.sendMessage("Player is not currently banned")
                } else {
                    sender.sendMessage(result.ban.reason)
                }
            }
        }
        return true
    }
}<commit_msg>Add ban details to status check<commit_after>package com.projectcitybuild.spigot.modules.bans.commands

import com.okkero.skedule.BukkitDispatcher
import com.projectcitybuild.core.contracts.Commandable
import com.projectcitybuild.core.contracts.Environment
import com.projectcitybuild.spigot.extensions.getOfflinePlayer
import com.projectcitybuild.spigot.modules.bans.actions.CheckBanStatusAction
import kotlinx.coroutines.experimental.launch
import org.bukkit.command.CommandSender

class BanStatusCommand : Commandable {
    override var environment: Environment? = null
    override val label: String = "status"

    override fun execute(sender: CommandSender, args: Array<String>, isConsole: Boolean): Boolean {
        val environment = environment ?: throw Exception("Environment is null")
        val plugin = environment.plugin ?: throw Exception("Plugin has already been deallocated")

        launch(BukkitDispatcher(plugin, async = true)) {
            val targetPlayerName = args.first()
            val playerUUID = sender.server.getOfflinePlayer(name = targetPlayerName, environment = environment)
            if (playerUUID == null) {
                sender.sendMessage("Error: Failed to retrieve UUID of given player")
                return@launch
            }

            val action = CheckBanStatusAction(environment)
            val result = action.execute(
                    playerId = playerUUID
            )
            if (result is CheckBanStatusAction.Result.FAILED) {
                when (result.reason) {
                    CheckBanStatusAction.Failure.DESERIALIZE_FAILED -> {
                        sender.sendMessage("Error: Bad response received from the ban server. Please contact an admin")
                    }
                }
            }
            if (result is CheckBanStatusAction.Result.SUCCESS) {
                if (result.ban == null) {
                    sender.sendMessage("Player is not currently banned")
                } else {
                    sender.sendMessage("""
                        $targetPlayerName is currently banned.
                        ---
                        Reason: ${result.ban.reason}
                        Date: ${result.ban.createdAt}
                        Expires: ${result.ban.expiresAt ?: "Never"}
                    """)
                }
            }
        }
        return true
    }
}
{'fraction_non_alphanumeric': 0.07932639042765345, 'fraction_numerical': 0.0, 'mean_word_length': 2.1045392022008254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2148090', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1063, 'n_words': 260}