@Override public void run() { if (platform.getApiClient() == null) { // no API client return; } try { listing.set(platform.getApiClient().retrieveListing()); } catch (IOException | ApiException e) { platform.log(Level.SEVERE, "Error whilst retrieving listing", e); return; } lastUpdate.set(new Date()); if (updateTask != null) { updateTask.run(); } }
public void initializeTasks() { try { serverInformation = platform.getApiClient().getServerInformation(); } catch (IOException | ApiException e) { throw new RuntimeException("Can't fetch account information", e); } executorService.schedule(playerFetcher = new DuePlayerFetcher(platform, verbose), 1, TimeUnit.SECONDS); }
@Override public void run() { List<Integer> commandsToPost = new ArrayList<>(); while (commandsToPost.size() < MAXIMUM_COMMANDS_TO_POST) { Integer posted = completed.poll(); if (posted == null) break; commandsToPost.add(posted); } if (!commandsToPost.isEmpty()) { try { platform.getApiClient().deleteCommand(commandsToPost); } catch (IOException | ApiException e) { platform.log(Level.SEVERE, "Unable to mark commands as completed", e); // TODO: Retry? } } }
public void flush() { if (!completed.isEmpty()) { for (List<Integer> list : Lists.partition(new ArrayList<>(completed), MAXIMUM_COMMANDS_TO_POST)) { try { platform.getApiClient().deleteCommand(list); } catch (IOException | ApiException e) { platform.log(Level.SEVERE, "Unable to mark commands as completed", e); break; } } } } }
@Override public void run() { if (platform.getApiClient() == null) { return; // no API client } QueueInformation information; try { // Retrieve offline command queue. information = platform.getApiClient().retrieveOfflineQueue(); } catch (IOException | ApiException e) { platform.log(Level.SEVERE, "Could not fetch command queue", e); return; } // Queue commands for later. for (QueuedCommand command : information.getCommands()) { platform.getExecutor().queue(new ToRunQueuedCommand(command.getPlayer(), command, false)); } } }
platform.getPlatformInformation().getVersion()); writer.println(); writer.println("Connected to Buycraft? " + (platform.getApiClient() != null)); ServerInformation information = platform.getServerInformation(); writer.println("Web store information found? " + (information != null));
public void run(boolean scheduleAgain) { if (platform.getApiClient() == null) { return; // no API client do { try { information = platform.getApiClient().retrieveDueQueue(); if(information == null){ return;
@Override public void run() { QueueInformation information; try { information = platform.getApiClient().getPlayerQueue(player.getId()); } catch (IOException | ApiException e) { // TODO: Implement retry logic. platform.log(Level.SEVERE, "Could not fetch command queue for player", e); return; } platform.log(Level.INFO, String.format("Fetched %d commands for player '%s'.", information.getCommands().size(), player.getName())); // Queue commands for later. for (QueuedCommand command : information.getCommands()) { platform.getExecutor().queue(new ToRunQueuedCommand(player, command, true)); } } }