Search in sources :

Example 1 with Command

use of me.saiintbrisson.minecraft.command.annotation.Command in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onConverterCommand.

@Command(name = "nexteconomy.converter", permission = "nexteconomy.admin", usage = "/ne converter <conversor>", async = true)
public void onConverterCommand(Context<CommandSender> context, String option) {
    if (!conversorManager.checkConversorAvailability(context.getSender()))
        return;
    val conversor = conversorManager.getByName(option);
    if (conversor == null) {
        context.sendMessage(ColorUtil.colored("&cConversor inválido, conversores válidos: " + conversorManager.availableConversors()));
        return;
    }
    val stopwatch = Stopwatch.createStarted();
    conversorManager.setConverting(true);
    accountStorage.flushData();
    val accounts = conversor.lookupPlayers();
    if (accounts == null || accounts.isEmpty()) {
        context.sendMessage(ColorUtil.colored("&cOPS! Não tem nenhum dado para converter ou a conexão é inválida."));
        conversorManager.setConverting(false);
        return;
    }
    conversorManager.startConversion(context.getSender(), accounts, conversor.getConversorName(), stopwatch);
}
Also used : lombok.val(lombok.val) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Example 2 with Command

use of me.saiintbrisson.minecraft.command.annotation.Command 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 3 with Command

use of me.saiintbrisson.minecraft.command.annotation.Command in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onBackupCommand.

@Command(name = "nexteconomy.backup", permission = "nexteconomy.admin", async = true)
public void onBackupCommand(Context<CommandSender> context, @Optional String name) {
    context.sendMessage(ColorUtil.colored("&aIniciando criação do backup."));
    val backup = backupManager.createBackup(context.getSender(), name, accountStorage.getAccountRepository(), false, true);
    if (backup.getResponseType() == ResponseType.NAME_IN_USE) {
        context.sendMessage(ColorUtil.colored("&cJá existe um backup com este nome", "&a&LDICA: &fDeixe o nome vazio para gerar um backup com a data e hora atual."));
        return;
    }
    if (backup.getResponseType() == ResponseType.BACKUP_IN_PROGRESS) {
        context.sendMessage(ColorUtil.colored("&cJá existe um backup em andamento."));
    }
}
Also used : lombok.val(lombok.val) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Example 4 with Command

use of me.saiintbrisson.minecraft.command.annotation.Command in project NextEconomy by NextPlugins.

the class NextEconomyCommand method onRankingDebug.

@Command(name = "nexteconomy.rankingdebug", permission = "nexteconomy.admin", async = true)
public void onRankingDebug(Context<CommandSender> context) {
    val pluginManager = Bukkit.getPluginManager();
    if (!pluginManager.isPluginEnabled("HolographicDisplays")) {
        context.sendMessage(ColorUtil.colored("&cO plugin HolographicDisplays precisa estar ativo para usar esta função."));
        return;
    }
    val citizensEnabled = pluginManager.isPluginEnabled("Citizens");
    for (val world : Bukkit.getWorlds()) {
        for (val entity : world.getEntities()) {
            if (!entity.hasMetadata("nexteconomy"))
                continue;
            if (citizensEnabled) {
                val npc = CitizensAPI.getNPCRegistry().getNPC(entity);
                if (npc != null) {
                    CitizensAPI.getNPCRegistry().deregister(npc);
                    continue;
                }
            }
            entity.remove();
        }
    }
    HologramsAPI.getHolograms(NextEconomy.getInstance()).forEach(Hologram::delete);
    if (citizensEnabled) {
        try {
            for (val npc : CitizensAPI.getNPCRegistry()) {
                if (!npc.data().has("nexteconomy"))
                    continue;
                npc.despawn();
                npc.destroy();
            }
        } catch (Exception exception) {
            for (val id : NPCRunnable.NPCS) {
                val npc = CitizensAPI.getNPCRegistry().getById(id);
                if (npc == null)
                    continue;
                CitizensAPI.getNPCRegistry().deregister(npc);
            }
        }
        NPCRunnable.NPCS.clear();
    }
    context.sendMessage(ColorUtil.colored("&aTodos os NPCs, ArmorStands e Hologramas foram limpos com sucesso."));
}
Also used : lombok.val(lombok.val) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Example 5 with Command

use of me.saiintbrisson.minecraft.command.annotation.Command in project NextEconomy by NextPlugins.

the class PurseCommand method onPurseGiveCommand.

@Command(name = "bolsa.give", aliases = { "add" }, target = CommandTarget.ALL, usage = "/bolsa give <player> <amount>", permission = "nexteconomy.purse.give", async = true)
public void onPurseGiveCommand(Context<CommandSender> context, OfflinePlayer player, String amount) {
    val sender = context.getSender();
    val parse = NumberUtils.parse(amount);
    if (parse < 1) {
        sender.sendMessage(MessageValue.get(MessageValue::invalidMoney));
        return;
    }
    val offlineAccount = NextEconomy.getInstance().getAccountStorage().findAccount(player);
    if (offlineAccount == null) {
        sender.sendMessage(MessageValue.get(MessageValue::invalidTarget));
        return;
    }
    val value = parse * PurseAPI.getInstance().getPurseMultiplier();
    val moneyGiveEvent = new MoneyGiveEvent(sender, player, value, parse);
    Bukkit.getPluginManager().callEvent(moneyGiveEvent);
}
Also used : lombok.val(lombok.val) MoneyGiveEvent(com.nextplugins.economy.api.event.operations.MoneyGiveEvent) Command(me.saiintbrisson.minecraft.command.annotation.Command)

Aggregations

lombok.val (lombok.val)21 Command (me.saiintbrisson.minecraft.command.annotation.Command)21 MessageValue (com.nextplugins.economy.configuration.MessageValue)7 OfflinePlayer (org.bukkit.OfflinePlayer)3 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)3 Player (org.bukkit.entity.Player)3 MoneyGiveEvent (com.nextplugins.economy.api.event.operations.MoneyGiveEvent)2 RankingValue (com.nextplugins.economy.configuration.RankingValue)2 Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 SQLExecutor (com.henryfabio.sqlprovider.executor.SQLExecutor)1 MoneyChangeEvent (com.nextplugins.economy.api.event.operations.MoneyChangeEvent)1 MoneySetEvent (com.nextplugins.economy.api.event.operations.MoneySetEvent)1 MoneyWithdrawEvent (com.nextplugins.economy.api.event.operations.MoneyWithdrawEvent)1 TransactionRequestEvent (com.nextplugins.economy.api.event.transaction.TransactionRequestEvent)1 FeatureValue (com.nextplugins.economy.configuration.FeatureValue)1 AccountRepository (com.nextplugins.economy.dao.repository.AccountRepository)1 File (java.io.File)1 IOException (java.io.IOException)1 lombok.var (lombok.var)1