Search in sources :

Example 1 with SQLExecutor

use of com.henryfabio.sqlprovider.executor.SQLExecutor in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onSwipeDataCommand.

@Command(name = "nexteconomy.swipedata", permission = "nexteconomy.admin", usage = "/ne swipedata <tomysql, tosqlite>", async = true)
public void onSwipeDataCommand(Context<CommandSender> context, String option) {
    if (!conversorManager.checkConversorAvailability(context.getSender()))
        return;
    if (!option.equalsIgnoreCase("tomysql") && !option.equalsIgnoreCase("tosqlite")) {
        context.sendMessage(ColorUtil.colored("&cConversores válidos: tomysql, tosqlite"));
        return;
    }
    val stopwatch = Stopwatch.createStarted();
    conversorManager.setConverting(true);
    val jdbcUrl = NextEconomy.getInstance().getSqlConnector().getDatabaseType().getJdbcUrl();
    if (option.equalsIgnoreCase("tomysql") && !jdbcUrl.contains("mysql")) {
        context.sendMessage(ColorUtil.colored("&cVocê precisa habilitar o mysql na config e reiniciar o servidor antes."));
        return;
    } else if (option.equalsIgnoreCase("tosqlite") && !jdbcUrl.contains("sqlite")) {
        context.sendMessage(ColorUtil.colored("&cVocê precisa desabilitar o mysql na config e reiniciar o servidor antes."));
        return;
    }
    val type = option.equalsIgnoreCase("tomysql") ? "SQLite" : "MySQL";
    val sqlProvider = SQLProvider.of(NextEconomy.getInstance());
    val sqlConnector = sqlProvider.setup(type);
    if (sqlConnector == null) {
        context.sendMessage(ColorUtil.colored("&cVocê não configurou a conexão do " + type + " corretamente."));
        return;
    }
    val repository = new AccountRepository(new SQLExecutor(sqlConnector));
    accountStorage.flushData();
    val accounts = repository.selectAll("");
    if (accounts.isEmpty()) {
        context.sendMessage(ColorUtil.colored("&cOPS! Não tem nenhum dado para converter."));
        return;
    }
    conversorManager.startConversion(context.getSender(), accounts, "Enviando para " + type, stopwatch);
}
Also used : lombok.val(lombok.val) SQLExecutor(com.henryfabio.sqlprovider.executor.SQLExecutor) AccountRepository(com.nextplugins.economy.dao.repository.AccountRepository) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Example 2 with SQLExecutor

use of com.henryfabio.sqlprovider.executor.SQLExecutor in project NextEconomy by NextPlugins.

the class NextEconomy method onEnable.

@Override
public void onEnable() {
    getLogger().info("Iniciando carregamento do plugin.");
    val loadTime = Stopwatch.createStarted();
    if (updateChecker.canUpdate()) {
        val lastRelease = updateChecker.getLastRelease();
        getLogger().info("");
        getLogger().info("[NextUpdate] ATENÇÃO!");
        getLogger().info("[NextUpdate] Você está usando uma versão antiga do NextEconomy!");
        getLogger().info("[NextUpdate] Nova versão: " + lastRelease.getVersion());
        getLogger().info("[NextUpdate] Baixe aqui: " + lastRelease.getDownloadURL());
        getLogger().info("");
    } else {
        getLogger().info("[NextUpdate] Olá! Vim aqui revisar se a versão do NextEconomy está atualizada, e pelo visto sim! Obrigado por usar nossos plugins!");
    }
    sqlConnector = SQLProvider.of(this).setup(null);
    sqlExecutor = new SQLExecutor(sqlConnector);
    accountRepository = new AccountRepository(sqlExecutor);
    accountStorage = new AccountStorage(accountRepository);
    conversorManager = new ConversorManager(accountRepository);
    rankingStorage = new RankingStorage();
    backupManager = new BackupManager();
    locationManager = new LocationManager();
    groupWrapperManager = new GroupWrapperManager();
    interactionRegistry = new InteractionRegistry();
    discordCommandRegistry = new DiscordCommandRegistry();
    rankingChatBody = new RankingChatBody();
    internalTitleAPI = InternalAPIMapping.create();
    val nickValue = getConfig().getString("plugin.configuration.save-method", "NICK");
    val nickMode = nickValue.equalsIgnoreCase("NICK");
    accountStorage.init(nickMode);
    interactionRegistry.init();
    InventoryManager.enable(this);
    ConfigurationRegistry.of(this).register();
    CommandRegistry.of(this).register();
    VaultHookRegistry.of(this).register();
    MetricProvider.of(this).register();
    InventoryRegistry.of(this).register();
    ConversorRegistry.of(this).register();
    Bukkit.getScheduler().runTaskLater(this, () -> {
        PlaceholderRegistry.of(this).register();
        CustomRankingRegistry.of(this).register();
        ListenerRegistry.of(this).register();
        if (!PurseAPI.init())
            getLogger().info("Sistema de bolsa de valores desativado.");
        else
            // force purse update
            PurseAPI.getInstance();
        groupWrapperManager.init();
        // bump money top one time and add, if enabled, stands/npcs
        rankingStorage.updateRanking(true);
        registerPayDiscordManager();
        discordCommandRegistry.init();
        purgeBackups();
    }, 150L);
    loadTime.stop();
    getLogger().log(Level.INFO, "Plugin inicializado com sucesso. ({0})", loadTime);
}
Also used : lombok.val(lombok.val) LocationManager(com.nextplugins.economy.ranking.manager.LocationManager) RankingStorage(com.nextplugins.economy.ranking.storage.RankingStorage) RankingChatBody(com.nextplugins.economy.ranking.util.RankingChatBody) SQLExecutor(com.henryfabio.sqlprovider.executor.SQLExecutor) AccountRepository(com.nextplugins.economy.dao.repository.AccountRepository) ConversorManager(com.nextplugins.economy.api.conversor.ConversorManager) InteractionRegistry(com.nextplugins.economy.model.interactions.registry.InteractionRegistry) DiscordCommandRegistry(com.nextplugins.economy.command.discord.registry.DiscordCommandRegistry) BackupManager(com.nextplugins.economy.api.backup.BackupManager) GroupWrapperManager(com.nextplugins.economy.api.group.GroupWrapperManager) AccountStorage(com.nextplugins.economy.model.account.storage.AccountStorage)

Example 3 with SQLExecutor

use of com.henryfabio.sqlprovider.executor.SQLExecutor in project NextEconomy by NextPlugins.

the class ConversorRegistry method register.

public void register() {
    val config = plugin.getConversorsConfig();
    val conversorManager = plugin.getConversorManager();
    for (val type : values.entrySet()) {
        val conversorName = type.getKey();
        val value = type.getValue();
        value.setConversorName(conversorName);
        if (!config.contains(conversorName)) {
            conversorManager.registerConversor(type.getValue());
            continue;
        }
        val configurationSection = config.getConfigurationSection(conversorName);
        if (configurationSection == null || !configurationSection.getBoolean("use"))
            continue;
        val connector = new SQLExecutor(configureSqlProvider(configurationSection));
        val tableName = configurationSection.getString("connection.table");
        value.setExecutor(connector);
        value.setTable(tableName);
        conversorManager.registerConversor(value);
        plugin.getLogger().info("[Converter] Registrado o conversor " + type.getKey());
    }
}
Also used : lombok.val(lombok.val) SQLExecutor(com.henryfabio.sqlprovider.executor.SQLExecutor)

Aggregations

SQLExecutor (com.henryfabio.sqlprovider.executor.SQLExecutor)3 lombok.val (lombok.val)3 AccountRepository (com.nextplugins.economy.dao.repository.AccountRepository)2 BackupManager (com.nextplugins.economy.api.backup.BackupManager)1 ConversorManager (com.nextplugins.economy.api.conversor.ConversorManager)1 GroupWrapperManager (com.nextplugins.economy.api.group.GroupWrapperManager)1 DiscordCommandRegistry (com.nextplugins.economy.command.discord.registry.DiscordCommandRegistry)1 AccountStorage (com.nextplugins.economy.model.account.storage.AccountStorage)1 InteractionRegistry (com.nextplugins.economy.model.interactions.registry.InteractionRegistry)1 LocationManager (com.nextplugins.economy.ranking.manager.LocationManager)1 RankingStorage (com.nextplugins.economy.ranking.storage.RankingStorage)1 RankingChatBody (com.nextplugins.economy.ranking.util.RankingChatBody)1 Command (me.saiintbrisson.minecraft.command.annotation.Command)1