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() { run(true); }
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 0) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("no_params")); return; } if (plugin.getApiClient() == null) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("need_secret_key")); return; } if (plugin.getDuePlayerFetcher().inProgress()) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("already_checking_for_purchases")); return; } plugin.getPlatform().executeAsync(() -> plugin.getDuePlayerFetcher().run(false)); sender.sendMessage(TextFormat.GREEN + plugin.getI18n().get("forcecheck_queued")); }
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if (plugin.getApiClient() == null) { return; } QueuedPlayer qp = plugin.getDuePlayerFetcher().fetchAndRemoveDuePlayer(event.getPlayer().getName()); if (qp != null) { plugin.getPlayerJoinCheckTask().queue(qp); } } }
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 0) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("no_params")); return; } if (plugin.getApiClient() == null) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("need_secret_key")); return; } if (plugin.getDuePlayerFetcher().inProgress()) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("already_checking_for_purchases")); return; } plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new RecentPurchaseSignUpdateFetcher(plugin)); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("sign_update_queued")); }
writer.println("Players in queue: " + duePlayerFetcher.getDuePlayers()); if (listingUpdateTask != null) { writer.println("Listing update last completed: " + listingUpdateTask.getLastUpdate());
processOnlinePlayers(); } finally { inProgress.set(false);
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { if (plugin.getApiClient() == null) { sender.sendMessage(Text.builder(plugin.getI18n().get("need_secret_key")).color(TextColors.RED).build()); return CommandResult.success(); } if (plugin.getDuePlayerFetcher().inProgress()) { sender.sendMessage(Text.builder(plugin.getI18n().get("already_checking_for_purchases")).color(TextColors.RED).build()); return CommandResult.success(); } Sponge.getScheduler().createTaskBuilder().execute(() -> plugin.getDuePlayerFetcher().run(false)).async().submit(plugin); sender.sendMessage(Text.builder(plugin.getI18n().get("forcecheck_queued")).color(TextColors.GREEN).build()); return CommandResult.success(); } }
@Listener public void onPlayerJoinEvent(ClientConnectionEvent.Join event) { if (plugin.getApiClient() == null) { return; } QueuedPlayer qp = plugin.getDuePlayerFetcher().fetchAndRemoveDuePlayer(event.getTargetEntity().getName()); if (qp != null) { plugin.getPlayerJoinCheckTask().queue(qp); } } }
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 0) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("no_params")); return; } if (plugin.getApiClient() == null) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("need_secret_key")); return; } if (plugin.getDuePlayerFetcher().inProgress()) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("already_checking_for_purchases")); return; } plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { plugin.getDuePlayerFetcher().run(false); } }); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("forcecheck_queued")); }
@Override public void run() { plugin.getDuePlayerFetcher().run(false); } });
this.duePlayerFetcherTask = getServer().getScheduler().runTaskLaterAsynchronously(this, duePlayerFetcher = new DuePlayerFetcher(platform, configuration.isVerbose()), 20); completedCommandsTask = new PostCompletedCommandsTask(platform);
@EventHandler public void onPostLogin(PostLoginEvent event) { if (plugin.getApiClient() == null) { return; } QueuedPlayer qp = plugin.getDuePlayerFetcher().fetchAndRemoveDuePlayer(event.getPlayer().getName()); if (qp != null) { plugin.getPlayerJoinCheckTask().queue(qp); } } }
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 0) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("no_params")); return; } if (plugin.getApiClient() == null) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("need_secret_key")); return; } if (plugin.getDuePlayerFetcher().inProgress()) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("already_checking_for_purchases")); return; } plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() { @Override public void run() { plugin.getDuePlayerFetcher().run(false); } }); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("forcecheck_queued")); }
@Override public void run() { plugin.getDuePlayerFetcher().run(false); } });
platform.executeAsyncLater(duePlayerFetcher = new DuePlayerFetcher(platform, configuration.isVerbose()), 1, TimeUnit.SECONDS); completedCommandsTask = new PostCompletedCommandsTask(platform); commandExecutor = new QueuedCommandExecutor(platform, completedCommandsTask);
@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { if (plugin.getApiClient() == null) { return; } QueuedPlayer qp = plugin.getDuePlayerFetcher().fetchAndRemoveDuePlayer(event.getPlayer().getName()); if (qp != null) { plugin.getPlayerJoinCheckTask().queue(qp); } }
@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); } });
getProxy().getScheduler().schedule(this, duePlayerFetcher = new DuePlayerFetcher(platform, configuration.isVerbose()), 1, TimeUnit.SECONDS); completedCommandsTask = new PostCompletedCommandsTask(platform); commandExecutor = new QueuedCommandExecutor(platform, completedCommandsTask);
@Override public void run() { String currentKey = plugin.getConfiguration().getServerKey(); ApiClient client = new ProductionApiClient(args[0], plugin.getHttpClient()); try { plugin.updateInformation(client); } catch (Exception e) { plugin.getLogger().log(Level.SEVERE, "Unable to verify secret", e); sender.sendMessage(ChatColor.RED + plugin.getI18n().get("secret_does_not_work")); return; } ServerInformation information = plugin.getServerInformation(); plugin.setApiClient(client); plugin.getListingUpdateTask().run(); plugin.getConfiguration().setServerKey(args[0]); try { plugin.saveConfiguration(); } catch (IOException e) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("secret_cant_be_saved")); } sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("secret_success", information.getServer().getName(), information.getAccount().getName())); boolean repeatChecks = false; if (currentKey == "INVALID") { repeatChecks = true; } plugin.getDuePlayerFetcher().run(repeatChecks); } });