<commit_before>package com.ericgrandt;

import com.ericgrandt.wrappers.CommandBuilder;
import com.ericgrandt.commands.CommandRegister;
import com.ericgrandt.config.DefaultConfiguration;
import com.ericgrandt.data.AccountData;
import com.ericgrandt.data.CurrencyData;
import com.ericgrandt.data.Database;
import com.ericgrandt.player.PlayerListener;
import com.ericgrandt.services.AccountService;
import com.ericgrandt.services.TEEconomyService;
import com.google.inject.Inject;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.asset.Asset;
import org.spongepowered.api.asset.AssetId;
import org.spongepowered.api.command.Command;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.ConstructPluginEvent;
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
import org.spongepowered.api.event.lifecycle.StartedEngineEvent;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.reference.ConfigurationReference;
import org.spongepowered.configurate.reference.ValueReference;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.jvm.Plugin;

@Plugin("totaleconomy")
public class TotalEconomy {
    private final Logger logger = LogManager.getLogger("TotalEconomy");

    private final ConfigurationReference<CommentedConfigurationNode> reference;
    private ValueReference<DefaultConfiguration, CommentedConfigurationNode> config;

    @Inject
    private PluginContainer pluginContainer;

    @Inject
    @AssetId("schema/mysql.sql")
    private Asset mysqlSchema;

    private static TotalEconomy plugin;
    private Database database;
    private TEEconomyService economyService;
    private AccountService accountService;

    @Inject
    public TotalEconomy(final @DefaultConfig(sharedRoot = false) ConfigurationReference<CommentedConfigurationNode> reference) {
        plugin = this;
        this.reference = reference;
    }

    @Listener
    public void onConstructPlugin(ConstructPluginEvent event) {
        try {
            config = reference.referenceTo(DefaultConfiguration.class);
            this.reference.save();
        } catch (final ConfigurateException ex) {
            logger.error("Unable to load test configuration", ex);
        }

        database = new Database(logger, plugin);
        database.setup();

        AccountData accountData = new AccountData(logger, database);
        CurrencyData currencyData = new CurrencyData(logger, database);

        accountService = new AccountService(accountData);
        economyService = new TEEconomyService(accountData, currencyData);
    }

    @Listener
    public void onServerStarting(final StartingEngineEvent<Server> event) {
        Sponge.eventManager().registerListeners(pluginContainer, new PlayerListener(economyService));
    }

    @Listener
    public void onRegisterCommands(final RegisterCommandEvent<Command.Parameterized> event) {
        CommandRegister commandRegister = new CommandRegister(
            pluginContainer,
            economyService,
            accountService,
            new CommandBuilder()
        );
        commandRegister.registerCommands(event);
    }

    @Listener
    public void onServerStarted(StartedEngineEvent<Server> event) {<commit_msg>Register EconomyService (#389)<commit_after>package com.ericgrandt;

import com.ericgrandt.wrappers.CommandBuilder;
import com.ericgrandt.commands.CommandRegister;
import com.ericgrandt.config.DefaultConfiguration;
import com.ericgrandt.data.AccountData;
import com.ericgrandt.data.CurrencyData;
import com.ericgrandt.data.Database;
import com.ericgrandt.player.PlayerListener;
import com.ericgrandt.services.AccountService;
import com.ericgrandt.services.TEEconomyService;
import com.google.inject.Inject;

import java.util.function.Supplier;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Server;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.asset.Asset;
import org.spongepowered.api.asset.AssetId;
import org.spongepowered.api.command.Command;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.ConstructPluginEvent;
import org.spongepowered.api.event.lifecycle.ProvideServiceEvent;
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
import org.spongepowered.api.event.lifecycle.StartedEngineEvent;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.api.service.economy.EconomyService;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.reference.ConfigurationReference;
import org.spongepowered.configurate.reference.ValueReference;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.jvm.Plugin;

@Plugin("totaleconomy")
public class TotalEconomy {
    private final Logger logger = LogManager.getLogger("TotalEconomy");

    private final ConfigurationReference<CommentedConfigurationNode> reference;
    private ValueReference<DefaultConfiguration, CommentedConfigurationNode> config;

    @Inject
    private PluginContainer pluginContainer;

    @Inject
    @AssetId("schema/mysql.sql")
    private Asset mysqlSchema;

    private static TotalEconomy plugin;
    private Database database;
    private TEEconomyService economyService;
    private AccountService accountService;

    @Inject
    public TotalEconomy(final @DefaultConfig(sharedRoot = false) ConfigurationReference<CommentedConfigurationNode> reference) {
        plugin = this;
        this.reference = reference;
    }

    @Listener
    public void onConstructPlugin(ConstructPluginEvent event) {
        try {
            config = reference.referenceTo(DefaultConfiguration.class);
            this.reference.save();
        } catch (final ConfigurateException ex) {
            logger.error("Unable to load test configuration", ex);
        }

        database = new Database(logger, plugin);
        database.setup();

        AccountData accountData = new AccountData(logger, database);
        CurrencyData currencyData = new CurrencyData(logger, database);

        accountService = new AccountService(accountData);
        economyService = new TEEconomyService(accountData, currencyData);
    }

    @Listener
    public void onServerStarting(final StartingEngineEvent<Server> event) {
        Sponge.eventManager().registerListeners(pluginContainer, new PlayerListener(economyService));
    }
   
    @Listener
    public void onProvideService(ProvideServiceEvent<EconomyService> event) {
        Supplier<EconomyService> economySupplier = new Supplier<EconomyService>() {
            @Override
            public EconomyService get() {
                return economyService;
            }
        };
        event.suggest(economySupplier);
    }

    @Listener
    public void onRegisterCommands(final RegisterCommandEvent<Command.Parameterized> event) {
        CommandRegister commandRegister = new CommandRegister(
            pluginContainer,
            economyService,
            accountService,
            new CommandBuilder()
        );
        commandRegister.registerCommands(event);
    }

    @Listener
    public void onServerStarted(StartedEngineEvent<Server> event) {
{'fraction_non_alphanumeric': 0.08104271518905665, 'fraction_numerical': 0.0009033423667570009, 'mean_word_length': 4.393180236604036, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '5518306', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2018, 'n_words': 386}