<commit_before>package com.masahirosaito.spigot.homes.commands

import com.masahirosaito.spigot.homes.exceptions.NotHavePermissionException
import org.bukkit.entity.Player

interface PlayerCommand : BaseCommand {
    val permissions: List<String>

    fun fee(): Double

    fun execute(player: Player, args: List<String>)

    fun onCommand(player: Player, args: List<String>) {
        checkConfig()
        checkPermission(player)
        checkArgs(args)
        checkBalance(player)
        execute(player, args)
        payFee(player)
    }

    private fun payFee(player: Player) {
        plugin.econ?.let { economy ->
            val r = economy.withdrawPlayer(player, fee())
            if (r.transactionSuccess()) {
                send(player, buildString {
                    append("You were given ${economy.format(r.amount)}")
                    append(" and now have ${economy.format(r.balance)}")
                })
            } else {
                throw Exception("An error occurred: ${r.errorMessage}")
            }
        }
    }

    private fun checkBalance(player: Player) {
        plugin.econ?.let {
            if (it.getBalance(player) - fee() < 0)
                throw Exception("You have not enough money to execute this command (fee: ${fee()})")
        }
    }

    private fun checkPermission(player: Player) {
        if (!permissions.isEmpty()) {
            permissions.forEach {
                if (!player.hasPermission(it)) throw NotHavePermissionException(it)
            }
        }
    }
}
<commit_msg>Fix fee command message<commit_after>package com.masahirosaito.spigot.homes.commands

import com.masahirosaito.spigot.homes.exceptions.NotHavePermissionException
import org.bukkit.entity.Player

interface PlayerCommand : BaseCommand {
    val permissions: List<String>

    fun fee(): Double

    fun execute(player: Player, args: List<String>)

    fun onCommand(player: Player, args: List<String>) {
        checkConfig()
        checkPermission(player)
        checkArgs(args)
        checkBalance(player)
        execute(player, args)
        payFee(player)
    }

    private fun payFee(player: Player) {
        plugin.econ?.let { economy ->
            val r = economy.withdrawPlayer(player, fee())
            if (r.transactionSuccess()) {
                send(player, buildString {
                    append("You paid ${economy.format(r.amount)}")
                    append(" and now have ${economy.format(r.balance)}")
                })
            } else {
                throw Exception("An error occurred: ${r.errorMessage}")
            }
        }
    }

    private fun checkBalance(player: Player) {
        plugin.econ?.let {
            if (it.getBalance(player) - fee() < 0)
                throw Exception("You have not enough money to execute this command (fee: ${fee()})")
        }
    }

    private fun checkPermission(player: Player) {
        if (!permissions.isEmpty()) {
            permissions.forEach {
                if (!player.hasPermission(it)) throw NotHavePermissionException(it)
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.1107533805537669, 'fraction_numerical': 0.000643915003219575, 'mean_word_length': 2.079286422200198, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5453449', 'n_tokens_mistral': 857, 'n_tokens_neox': 836, 'n_words': 188}