@Override public void run() { for (SavedBuyNowSign sign : plugin.getBuyNowSignStorage().getSigns()) { Package p = plugin.getListingUpdateTask().getPackageById(sign.getPackageId()); if (p == null) { plugin.getLogger().error(String.format("Sign at %d, %d, %d in world %s does not have a valid package assigned to it.",
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { if (plugin.getApiClient() == null) { sender.sendMessage(Text.builder(plugin.getI18n().get("generic_api_operation_error")).color(TextColors.RED).build()); return CommandResult.success(); } if (plugin.getListingUpdateTask().getListing() == null) { sender.sendMessage(Text.builder("We're currently retrieving the listing. Sit tight!").color(TextColors.RED).build()); return CommandResult.success(); } sendPaginatedMessage(new Node(plugin.getListingUpdateTask().getListing().getCategories(), ImmutableList.of(), plugin.getI18n().get("categories"), null), sender); return CommandResult.success(); }
.ip(serverIP) .port(serverPort) .listingUpdateTask(plugin.getListingUpdateTask()) .serverOnlineMode(Sponge.getServer().getOnlineMode()) .build();
@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { if (plugin.getApiClient() == null) { src.sendMessage(Text.builder(plugin.getI18n().get("need_secret_key")).color(TextColors.RED).build()); } else { plugin.getPlatform().executeAsync(plugin.getListingUpdateTask()); src.sendMessage(Text.builder(plugin.getI18n().get("refresh_queued")).color(TextColors.GREEN).build()); } return CommandResult.success(); } }
@Override public void run() { String currentKey = plugin.getConfiguration().getServerKey(); ApiClient client = new ProductionApiClient((String) args.getOne("secret").get(), plugin.getHttpClient()); try { plugin.updateInformation(client); } catch (IOException | ApiException e) { plugin.getLogger().error("Unable to verify secret", e); src.sendMessage(Text.builder(plugin.getI18n().get("secret_does_not_work")).color(TextColors.RED).build()); return; } ServerInformation information = plugin.getServerInformation(); plugin.setApiClient(client); plugin.getListingUpdateTask().run(); plugin.getConfiguration().setServerKey((String) args.getOne("secret").get()); try { plugin.saveConfiguration(); } catch (IOException e) { src.sendMessage(Text.builder(plugin.getI18n().get("secret_cant_be_saved")).color(TextColors.RED).build()); } src.sendMessage(Text.builder(plugin.getI18n().get("secret_success", information.getServer().getName(), information.getAccount().getName())).color(TextColors.GREEN).build()); boolean repeatChecks = false; if (currentKey == "INVALID") { repeatChecks = true; } plugin.getDuePlayerFetcher().run(repeatChecks); } });