<commit_before>package com.deanveloper.kbukkit

import org.bukkit.Bukkit
import org.bukkit.entity.Player
import java.lang.ref.SoftReference
import java.util.*

/**
 * API for players through delegation
 *
 * @author <NAME>
 */
open class CustomPlayer protected constructor(player: Player) : Player by player {
    init {
        idMap.put(uniqueId, this)
        nameMap.put(name, this)

        KBukkitRunnable {
            idMap.remove(uniqueId)
            nameMap.remove(name)
        }.runTaskLater(KBukkitPlugin.instance, 20L)
    }

    companion object Handler {
        private val idMap = mutableMapOf<UUID, CustomPlayer>()
        private val nameMap = mutableMapOf<String, CustomPlayer>()

        @JvmStatic operator fun get(index: UUID): CustomPlayer {
            return idMap[index] ?: CustomPlayer(Bukkit.getPlayer(index)!!)
        }

        @JvmStatic operator fun get(index: String): CustomPlayer {
            return nameMap[index] ?: CustomPlayer(Bukkit.getPlayer(index)!!)
        }
    }
}<commit_msg>CustomPlayer is now easily usable<commit_after>package com.deanveloper.kbukkit

import org.bukkit.Bukkit
import org.bukkit.entity.Player
import java.util.*

/**
 * API for players through delegation
 *
 * @author <NAME>
 */
open class CustomPlayer protected constructor(player: Player) : Player by player {
    init {
        idMap.put(uniqueId, this)
        nameMap.put(name, this)
    }

    companion object : CustomPlayerCompanion<CustomPlayer>({ CustomPlayer(it) })
}

open class CustomPlayerCompanion<T : CustomPlayer>(val factory: (Player) -> T) {
    protected val idMap = WeakHashMap<UUID, T>()
    protected val nameMap = WeakHashMap<String, T>()

    operator fun get(player: Player): T = this[player.uniqueId]

    operator fun get(index: UUID): T {
        return idMap[index] ?: factory(Bukkit.getPlayer(index)!!)
    }

    operator fun get(index: String): CustomPlayer {
        return nameMap[index] ?: factory(Bukkit.getPlayer(index)!!)
    }
}
{'fraction_non_alphanumeric': 0.11105527638190955, 'fraction_numerical': 0.0010050251256281408, 'mean_word_length': 3.290948275862069, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, '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': '976734', 'n_tokens_mistral': 622, 'n_tokens_neox': 599, 'n_words': 143}