use of com.nextplugins.economy.dao.repository.AccountRepository 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);
}
use of com.nextplugins.economy.dao.repository.AccountRepository 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);
}
Aggregations