<commit_before>package com.rpkit.essentials.bukkit

import com.rpkit.core.bukkit.plugin.RPKBukkitPlugin
import com.rpkit.core.database.Database
import com.rpkit.essentials.bukkit.command.*
import com.rpkit.essentials.bukkit.dailyquote.RPKDailyQuoteProviderImpl
import com.rpkit.essentials.bukkit.database.table.RPKDrunkennessTable
import com.rpkit.essentials.bukkit.database.table.RPKLogMessagesEnabledTable
import com.rpkit.essentials.bukkit.database.table.RPKPreviousLocationTable
import com.rpkit.essentials.bukkit.database.table.RPKTrackingEnabledTable
import com.rpkit.essentials.bukkit.drink.RPKDrinkProviderImpl
import com.rpkit.essentials.bukkit.kit.RPKKitImpl
import com.rpkit.essentials.bukkit.kit.RPKKitProviderImpl
import com.rpkit.essentials.bukkit.listener.PlayerJoinListener
import com.rpkit.essentials.bukkit.listener.PlayerQuitListener
import com.rpkit.essentials.bukkit.listener.PlayerTeleportListener
import com.rpkit.essentials.bukkit.locationhistory.RPKLocationHistoryProviderImpl
import com.rpkit.essentials.bukkit.logmessage.RPKLogMessageProvider
import com.rpkit.essentials.bukkit.time.TimeSlowRunnable
import com.rpkit.essentials.bukkit.tracking.RPKTrackingProviderImpl
import org.bukkit.configuration.serialization.ConfigurationSerialization


class RPKEssentialsBukkit: RPKBukkitPlugin() {

    override fun onEnable() {
        ConfigurationSerialization.registerClass(RPKKitImpl::class.java)
        saveDefaultConfig()
        serviceProviders = arrayOf(
                RPKDailyQuoteProviderImpl(this),
                RPKDrinkProviderImpl(this),
                RPKKitProviderImpl(this),
                RPKLocationHistoryProviderImpl(this),
                RPKLogMessageProvider(this),
                RPKTrackingProviderImpl(this)
        )
        TimeSlowRunnable(this).runTaskTimer(this, 100L, 100L)
    }

    override fun registerCommands() {
        getCommand("back").executor = BackCommand(this)
        getCommand("clone").executor = CloneCommand(this)
        getCommand("distance").executor = DistanceCommand(this)
        getCommand("enchant").executor = EnchantCommand(this)
        getCommand("feed").executor = FeedCommand(this)
        getCommand("fly").executor = FlyCommand(this)
        getCommand("getbook").executor = GetBookCommand(this)
        getCommand("getsign").executor = GetSignCommand(this)
        getCommand("heal").executor = HealCommand(this)
        getCommand("inventory").executor = InventoryCommand(this)
        getCommand("item").executor = ItemCommand(this)
        getCommand("itemmeta").executor = ItemMetaCommand(this)
        getCommand("jump").executor = JumpCommand(this)
        getCommand("kit").executor = KitCommand(this)
        getCommand("repair").executor = RepairCommand(this)
        getCommand("runas").executor = RunAsCommand(this)
        getCommand("seen").executor = SeenCommand(this)
        getCommand("setspawn").executor = SetSpawnCommand(this)
        getCommand("smite").executor = SmiteCommand(this)
        getCommand("spawn").executor = SpawnCommand(this)
        getCommand("spawner").executor = SpawnerCommand(this)
        getCommand("spawnmob").executor = SpawnMobCommand(this)
        getCommand("speed").executor = SpeedCommand(this)
        getCommand("sudo").executor = SudoCommand(this)
        getCommand("togglelogmessages").executor = ToggleLogMessagesCommand(this)
        getCommand("toggletracking").executor = ToggleTrackingCommand(this)
        getCommand("track").executor = TrackCommand(this)
        getCommand("unsign").executor = UnsignCommand(this)
    }

    override fun registerListeners() {
        registerListeners(
                PlayerJoinListener(this),
                PlayerQuitListener(this),
                PlayerTeleportListener(this)
        )
    }

    override fun createTables(database: Database) {
        database.addTable(RPKDrunkennessTable(database, this))
        database.addTable(RPKLogMessagesEnabledTable(database, this))
        database.addTable(RPKPreviousLocationTable(database, this))
        database.addTable(RPKTrackingEnabledTable(database, this))
    }

    override fun setDefaultMessages() {
        messages.setDefault("back-valid", "&aTeleported to previous location.")
        messages.setDefault("back-invalid-no-locations", "&cYou have not teleported recently.")
        messages.setDefault("clone-valid", "&aItem cloned.")
        messages.setDefault("clone-invalid-item", "&cYou are not holding any item.")
        messages.setDefault("distance-invalid-untrackable", "&cThat player is not currently trackable.")
        messages.setDefault("distance-invalid-item", "&cYou require \$amount x \$type to use that command.")
        messages.setDefault("distance-invalid-distance", "&cYou are too far away to get the distance to that player.")
        messages.setDefault("distance-valid", "&aDistance to \$character/\$player: \$distance")
        messages.setDefault("distance-untrackable-notification", "&c\$player attempted to check their distance to you. If you wish for them to be able to find you, re-enable tracking with /toggletracking.")
        messages.setDefault("distance-invalid-world", "&cThat player is in a different world.")
        messages.setDefault("distance-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("distance-usage", "&cUsage: /distance [player]")
        messages.setDefault("enchant-valid", "&aSuccessfully enchanted \$amount x \$type with \$enchantment \$level")
        messages.setDefault("enchant-invalid-level", "&cThe enchantment level must be a number.")
        messages.setDefault("enchant-invalid-enchantment", "&cThere is no enchantment by that name.")
        messages.setDefault("enchant-invalid-illegal", "&cThat enchantment is illegal.")
        messages.setDefault("enchant-invalid-item", "&cYou must be holding something in order to enchant it.")
        messages.setDefault("enchant-usage", "&cUsage: /enchant [enchantment] [level]")
        messages.setDefault("feed-notification", "&aHunger refilled.")
        messages.setDefault("feed-valid", "&a\$player's hunger was refilled.")
        messages.setDefault("feed-usage-console", "&cWhen using this command from console, you must specify a player to feed.")
        messages.setDefault("fly-enable-notification", "&aFly mode enabled.")
        messages.setDefault("fly-enable-valid", "&aAllowed \$player to fly.")
        messages.setDefault("fly-disable-notification", "&aFly mode disabled.")
        messages.setDefault("fly-disable-valid", "&aDisallowed \$player to fly.")
        messages.setDefault("fly-usage-console", "&cWhen using this command from console, you must specify a player.")
        messages.setDefault("get-book-valid", "&aHere's a book.")
        messages.setDefault("get-sign-valid", "&aHere's a sign.")
        messages.setDefault("heal-notification", "&aHealed.")
        messages.setDefault("heal-valid", "&aHealed \$player.")
        messages.setDefault("heal-usage-console", "&cWhen using this command from console, you must specify a player to heal.")
        messages.setDefault("inventory-valid", "&aViewing \$player's inventory.")
        messages.setDefault("inventory-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("inventory-usage", "&cUsage: /inventory [player]")
        messages.setDefault("item-invalid-amount", "&cThe amount must be an integer.")
        messages.setDefault("item-valid-plural", "&aCreated \$amount \$types.")
        messages.setDefault("item-valid-singular", "&aCreated a \$type.")
        messages.setDefault("item-invalid-material", "&cCould not find a material by that name.")
        messages.setDefault("item-usage", "&cUsage: /item [type] [amount]")
        messages.setDefault("item-meta-set-name-valid", "&aSet item display name to $name.")
        messages.setDefault("item-meta-add-lore-valid", "&aAdded lore: \"\$lore&a\".")
        messages.setDefault("item-meta-remove-lore-valid", "&cRemoved lore: \"\$lore&a\".")
        messages.setDefault("item-meta-remove-lore-invalid-lore-item", "&cThat item does not have that piece of lore.")
        messages.setDefault("item-meta-remove-lore-invalid-lore", "&cThat item does not have any lore.")
        messages.setDefault("item-meta-usage", "&cUsage: /itemmeta [setname|addlore|removelore] [name|lore]")
        messages.setDefault("item-meta-invalid-item", "&cYou must be holding an item to modify its item meta.")
        messages.setDefault("jump-valid", "&aTeleported to first block in line of sight.")
        messages.setDefault("jump-invalid-block", "&cNo block was found within 64 blocks of your line of sight.")
        messages.setDefault("kit-valid", "&aClaimed \$kit.")
        messages.setDefault("kit-invalid-kit", "&cThere is no kit by that name.")
        messages.setDefault("kit-list-title", "&fKit list:")
        messages.setDefault("kit-list-item", "&f- &7\$kit")
        messages.setDefault("repair-valid", "&aItem repaired.")
        messages.setDefault("repair-invalid-item", "&cYou must be holding an item in order to repair it.")
        messages.setDefault("run-as-valid", "&aDispatched command.")
        messages.setDefault("run-as-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("run-as-usage", "&cUsage: /runas [player] [command]")
        messages.setDefault("seen-online", "&a\$player is online now.")
        messages.setDefault("seen-date", "&a\$player was last seen on \$date at \$time.")
        messages.setDefault("seen-diff", "&a(That's \$days days, \$hours hours, \$minutes minutes, \$seconds seconds ago.)")
        messages.setDefault("seen-never", "&aThat player has never played on this server.")
        messages.setDefault("seen-usage", "&cUsage: /seen [player]")
        messages.setDefault("set-spawn-valid", "&aSpawn location of \$world set.")
        messages.setDefault("smite-usage", "&cUsage: /smite [player]")
        messages.setDefault("smite-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("smite-valid", "&aOpening the heavens on \$player.")<commit_msg>Fix /itemmeta setname default message including the plugin name, closes #208<commit_after>package com.rpkit.essentials.bukkit

import com.rpkit.core.bukkit.plugin.RPKBukkitPlugin
import com.rpkit.core.database.Database
import com.rpkit.essentials.bukkit.command.*
import com.rpkit.essentials.bukkit.dailyquote.RPKDailyQuoteProviderImpl
import com.rpkit.essentials.bukkit.database.table.RPKDrunkennessTable
import com.rpkit.essentials.bukkit.database.table.RPKLogMessagesEnabledTable
import com.rpkit.essentials.bukkit.database.table.RPKPreviousLocationTable
import com.rpkit.essentials.bukkit.database.table.RPKTrackingEnabledTable
import com.rpkit.essentials.bukkit.drink.RPKDrinkProviderImpl
import com.rpkit.essentials.bukkit.kit.RPKKitImpl
import com.rpkit.essentials.bukkit.kit.RPKKitProviderImpl
import com.rpkit.essentials.bukkit.listener.PlayerJoinListener
import com.rpkit.essentials.bukkit.listener.PlayerQuitListener
import com.rpkit.essentials.bukkit.listener.PlayerTeleportListener
import com.rpkit.essentials.bukkit.locationhistory.RPKLocationHistoryProviderImpl
import com.rpkit.essentials.bukkit.logmessage.RPKLogMessageProvider
import com.rpkit.essentials.bukkit.time.TimeSlowRunnable
import com.rpkit.essentials.bukkit.tracking.RPKTrackingProviderImpl
import org.bukkit.configuration.serialization.ConfigurationSerialization


class RPKEssentialsBukkit: RPKBukkitPlugin() {

    override fun onEnable() {
        ConfigurationSerialization.registerClass(RPKKitImpl::class.java)
        saveDefaultConfig()
        serviceProviders = arrayOf(
                RPKDailyQuoteProviderImpl(this),
                RPKDrinkProviderImpl(this),
                RPKKitProviderImpl(this),
                RPKLocationHistoryProviderImpl(this),
                RPKLogMessageProvider(this),
                RPKTrackingProviderImpl(this)
        )
        TimeSlowRunnable(this).runTaskTimer(this, 100L, 100L)
    }

    override fun registerCommands() {
        getCommand("back").executor = BackCommand(this)
        getCommand("clone").executor = CloneCommand(this)
        getCommand("distance").executor = DistanceCommand(this)
        getCommand("enchant").executor = EnchantCommand(this)
        getCommand("feed").executor = FeedCommand(this)
        getCommand("fly").executor = FlyCommand(this)
        getCommand("getbook").executor = GetBookCommand(this)
        getCommand("getsign").executor = GetSignCommand(this)
        getCommand("heal").executor = HealCommand(this)
        getCommand("inventory").executor = InventoryCommand(this)
        getCommand("item").executor = ItemCommand(this)
        getCommand("itemmeta").executor = ItemMetaCommand(this)
        getCommand("jump").executor = JumpCommand(this)
        getCommand("kit").executor = KitCommand(this)
        getCommand("repair").executor = RepairCommand(this)
        getCommand("runas").executor = RunAsCommand(this)
        getCommand("seen").executor = SeenCommand(this)
        getCommand("setspawn").executor = SetSpawnCommand(this)
        getCommand("smite").executor = SmiteCommand(this)
        getCommand("spawn").executor = SpawnCommand(this)
        getCommand("spawner").executor = SpawnerCommand(this)
        getCommand("spawnmob").executor = SpawnMobCommand(this)
        getCommand("speed").executor = SpeedCommand(this)
        getCommand("sudo").executor = SudoCommand(this)
        getCommand("togglelogmessages").executor = ToggleLogMessagesCommand(this)
        getCommand("toggletracking").executor = ToggleTrackingCommand(this)
        getCommand("track").executor = TrackCommand(this)
        getCommand("unsign").executor = UnsignCommand(this)
    }

    override fun registerListeners() {
        registerListeners(
                PlayerJoinListener(this),
                PlayerQuitListener(this),
                PlayerTeleportListener(this)
        )
    }

    override fun createTables(database: Database) {
        database.addTable(RPKDrunkennessTable(database, this))
        database.addTable(RPKLogMessagesEnabledTable(database, this))
        database.addTable(RPKPreviousLocationTable(database, this))
        database.addTable(RPKTrackingEnabledTable(database, this))
    }

    override fun setDefaultMessages() {
        messages.setDefault("back-valid", "&aTeleported to previous location.")
        messages.setDefault("back-invalid-no-locations", "&cYou have not teleported recently.")
        messages.setDefault("clone-valid", "&aItem cloned.")
        messages.setDefault("clone-invalid-item", "&cYou are not holding any item.")
        messages.setDefault("distance-invalid-untrackable", "&cThat player is not currently trackable.")
        messages.setDefault("distance-invalid-item", "&cYou require \$amount x \$type to use that command.")
        messages.setDefault("distance-invalid-distance", "&cYou are too far away to get the distance to that player.")
        messages.setDefault("distance-valid", "&aDistance to \$character/\$player: \$distance")
        messages.setDefault("distance-untrackable-notification", "&c\$player attempted to check their distance to you. If you wish for them to be able to find you, re-enable tracking with /toggletracking.")
        messages.setDefault("distance-invalid-world", "&cThat player is in a different world.")
        messages.setDefault("distance-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("distance-usage", "&cUsage: /distance [player]")
        messages.setDefault("enchant-valid", "&aSuccessfully enchanted \$amount x \$type with \$enchantment \$level")
        messages.setDefault("enchant-invalid-level", "&cThe enchantment level must be a number.")
        messages.setDefault("enchant-invalid-enchantment", "&cThere is no enchantment by that name.")
        messages.setDefault("enchant-invalid-illegal", "&cThat enchantment is illegal.")
        messages.setDefault("enchant-invalid-item", "&cYou must be holding something in order to enchant it.")
        messages.setDefault("enchant-usage", "&cUsage: /enchant [enchantment] [level]")
        messages.setDefault("feed-notification", "&aHunger refilled.")
        messages.setDefault("feed-valid", "&a\$player's hunger was refilled.")
        messages.setDefault("feed-usage-console", "&cWhen using this command from console, you must specify a player to feed.")
        messages.setDefault("fly-enable-notification", "&aFly mode enabled.")
        messages.setDefault("fly-enable-valid", "&aAllowed \$player to fly.")
        messages.setDefault("fly-disable-notification", "&aFly mode disabled.")
        messages.setDefault("fly-disable-valid", "&aDisallowed \$player to fly.")
        messages.setDefault("fly-usage-console", "&cWhen using this command from console, you must specify a player.")
        messages.setDefault("get-book-valid", "&aHere's a book.")
        messages.setDefault("get-sign-valid", "&aHere's a sign.")
        messages.setDefault("heal-notification", "&aHealed.")
        messages.setDefault("heal-valid", "&aHealed \$player.")
        messages.setDefault("heal-usage-console", "&cWhen using this command from console, you must specify a player to heal.")
        messages.setDefault("inventory-valid", "&aViewing \$player's inventory.")
        messages.setDefault("inventory-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("inventory-usage", "&cUsage: /inventory [player]")
        messages.setDefault("item-invalid-amount", "&cThe amount must be an integer.")
        messages.setDefault("item-valid-plural", "&aCreated \$amount \$types.")
        messages.setDefault("item-valid-singular", "&aCreated a \$type.")
        messages.setDefault("item-invalid-material", "&cCould not find a material by that name.")
        messages.setDefault("item-usage", "&cUsage: /item [type] [amount]")
        messages.setDefault("item-meta-set-name-valid", "&aSet item display name to \$name.")
        messages.setDefault("item-meta-add-lore-valid", "&aAdded lore: \"\$lore&a\".")
        messages.setDefault("item-meta-remove-lore-valid", "&cRemoved lore: \"\$lore&a\".")
        messages.setDefault("item-meta-remove-lore-invalid-lore-item", "&cThat item does not have that piece of lore.")
        messages.setDefault("item-meta-remove-lore-invalid-lore", "&cThat item does not have any lore.")
        messages.setDefault("item-meta-usage", "&cUsage: /itemmeta [setname|addlore|removelore] [name|lore]")
        messages.setDefault("item-meta-invalid-item", "&cYou must be holding an item to modify its item meta.")
        messages.setDefault("jump-valid", "&aTeleported to first block in line of sight.")
        messages.setDefault("jump-invalid-block", "&cNo block was found within 64 blocks of your line of sight.")
        messages.setDefault("kit-valid", "&aClaimed \$kit.")
        messages.setDefault("kit-invalid-kit", "&cThere is no kit by that name.")
        messages.setDefault("kit-list-title", "&fKit list:")
        messages.setDefault("kit-list-item", "&f- &7\$kit")
        messages.setDefault("repair-valid", "&aItem repaired.")
        messages.setDefault("repair-invalid-item", "&cYou must be holding an item in order to repair it.")
        messages.setDefault("run-as-valid", "&aDispatched command.")
        messages.setDefault("run-as-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("run-as-usage", "&cUsage: /runas [player] [command]")
        messages.setDefault("seen-online", "&a\$player is online now.")
        messages.setDefault("seen-date", "&a\$player was last seen on \$date at \$time.")
        messages.setDefault("seen-diff", "&a(That's \$days days, \$hours hours, \$minutes minutes, \$seconds seconds ago.)")
        messages.setDefault("seen-never", "&aThat player has never played on this server.")
        messages.setDefault("seen-usage", "&cUsage: /seen [player]")
        messages.setDefault("set-spawn-valid", "&aSpawn location of \$world set.")
        messages.setDefault("smite-usage", "&cUsage: /smite [player]")
        messages.setDefault("smite-invalid-player", "&cThere is no player by that name online.")
        messages.setDefault("smite-valid", "&aOpening the heavens on \$player.")
{'fraction_non_alphanumeric': 0.13104799216454457, 'fraction_numerical': 0.001028403525954946, 'mean_word_length': 3.863300785901405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3025999', 'n_tokens_mistral': 5956, 'n_tokens_neox': 5753, 'n_words': 1201}