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);
}
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);
}
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."));
}
}
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."));
}
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);
}
Aggregations