<commit_before>package flavor.pie.pieconomy

import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.LoadingCache
import flavor.pie.kludge.*
import org.spongepowered.api.service.context.ContextCalculator
import org.spongepowered.api.service.economy.Currency
import org.spongepowered.api.service.economy.EconomyService
import org.spongepowered.api.service.economy.account.Account
import org.spongepowered.api.service.economy.account.UniqueAccount
import java.util.Optional
import java.util.UUID
import java.util.concurrent.TimeUnit

class PieconomyService : EconomyService {
    val cache: LoadingCache<UUID, PieconomyPlayerAccount> = Caffeine.newBuilder()
            .expireAfterAccess(5, TimeUnit.MINUTES).build(::PieconomyPlayerAccount)

    val serverAccounts: MutableMap<String, PieconomyServerAccount> = HashMap()

    override fun getOrCreateAccount(uuid: UUID): Optional<UniqueAccount> = cache[uuid].optional

    override fun getOrCreateAccount(identifier: String): Optional<Account> = Optional.empty()

    override fun registerContextCalculator(calculator: ContextCalculator<Account>?) {}

    override fun getDefaultCurrency(): Currency = config.defaultCurrency

    override fun getCurrencies(): Set<Currency> = GameRegistry.getAllOf(Currency::class.java).toSet()

    override fun hasAccount(uuid: UUID): Boolean = uuid.user() != null

    override fun hasAccount(identifier: String): Boolean = false

}<commit_msg>Whoops, pretend that's part of 0.1.0<commit_after>package flavor.pie.pieconomy

import com.github.benmanes.caffeine.cache.Caffeine
import com.github.benmanes.caffeine.cache.LoadingCache
import flavor.pie.kludge.*
import org.spongepowered.api.service.context.ContextCalculator
import org.spongepowered.api.service.economy.Currency
import org.spongepowered.api.service.economy.EconomyService
import org.spongepowered.api.service.economy.account.Account
import org.spongepowered.api.service.economy.account.UniqueAccount
import java.util.Optional
import java.util.UUID
import java.util.concurrent.TimeUnit

class PieconomyService : EconomyService {
    val cache: LoadingCache<UUID, PieconomyPlayerAccount> = Caffeine.newBuilder()
            .expireAfterAccess(5, TimeUnit.MINUTES).build(::PieconomyPlayerAccount)

    val serverAccounts: MutableMap<String, PieconomyServerAccount> = HashMap()

    override fun getOrCreateAccount(uuid: UUID): Optional<UniqueAccount> = cache[uuid].optional

    override fun getOrCreateAccount(identifier: String): Optional<Account> = serverAccounts.values.first { it.name == identifier }.optional

    override fun registerContextCalculator(calculator: ContextCalculator<Account>?) {}

    override fun getDefaultCurrency(): Currency = config.defaultCurrency

    override fun getCurrencies(): Set<Currency> = GameRegistry.getAllOf(Currency::class.java).toSet()

    override fun hasAccount(uuid: UUID): Boolean = uuid.user() != null

    override fun hasAccount(identifier: String): Boolean = serverAccounts.values.any { it.name == identifier }

}
{'fraction_non_alphanumeric': 0.09977026583524778, 'fraction_numerical': 0.0016409583196586807, 'mean_word_length': 5.895927601809955, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6342693', 'n_tokens_mistral': 902, 'n_tokens_neox': 868, 'n_words': 166}