@Override public void run() { QueuedPlayer qp = queuedPlayers.poll(); if (qp != null) { platform.executeAsync(new PlayerCommandExecutor(qp, platform)); } }
platform.log(Level.INFO, "Executing commands that can be completed now..."); platform.executeAsync(new ImmediateCommandExecutor(platform));
private void createCoupon(final CommandSender sender, String[] args) { String[] stripped = Arrays.copyOfRange(args, 1, args.length); final Coupon coupon; try { coupon = CouponUtil.parseArguments(stripped); } catch (Exception e) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("coupon_creation_arg_parse_failure", e.getMessage())); return; } plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().createCoupon(coupon); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("coupon_creation_success", coupon.getCode())); } catch (ApiException | IOException e) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("generic_api_operation_error")); } } }); }
private void createCoupon(final CommandSender sender, String[] args) { String[] stripped = Arrays.copyOfRange(args, 1, args.length); final Coupon coupon; try { coupon = CouponUtil.parseArguments(stripped); } catch (Exception e) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("coupon_creation_arg_parse_failure", e.getMessage())); return; } plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().createCoupon(coupon); sender.sendMessage(TextFormat.GREEN + plugin.getI18n().get("coupon_creation_success", coupon.getCode())); } catch (ApiException | IOException e) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("generic_api_operation_error")); } } }); }
private void createCoupon(final CommandSender sender, String[] args) { String[] stripped = Arrays.copyOfRange(args, 1, args.length); final Coupon coupon; try { coupon = CouponUtil.parseArguments(stripped); } catch (Exception e) { sender.sendMessage(e.getMessage()); sender.sendMessage(ChatColor.RED + plugin.getI18n().get("coupon_creation_arg_parse_failure", e.getMessage())); return; } plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().createCoupon(coupon); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("coupon_creation_success", coupon.getCode())); } catch (ApiException | IOException e) { sender.sendMessage(ChatColor.RED + e.getMessage()); } } }); }
private void deleteCoupon(final CommandSender sender, String[] args) { if (args.length != 2) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("no_coupon_specified")); return; } final String code = args[1]; plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().deleteCoupon(code); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("coupon_deleted")); } catch (ApiException | IOException e) { sender.sendMessage(ChatColor.RED + e.getMessage()); return; } } }); }
private void deleteCoupon(final CommandSender sender, String[] args) { if (args.length != 2) { sender.sendMessage(ChatColor.RED + plugin.getI18n().get("no_coupon_specified")); return; } final String code = args[1]; plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().deleteCoupon(code); sender.sendMessage(ChatColor.GREEN + plugin.getI18n().get("coupon_deleted")); } catch (ApiException | IOException e) { sender.sendMessage(ChatColor.RED + e.getMessage()); return; } } }); }
private void deleteCoupon(final CommandSender sender, String[] args) { if (args.length != 2) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("no_coupon_specified")); return; } final String code = args[1]; plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().deleteCoupon(code); sender.sendMessage(TextFormat.GREEN + plugin.getI18n().get("coupon_deleted")); } catch (ApiException | IOException e) { sender.sendMessage(TextFormat.RED + e.getMessage()); return; } } }); }
@Listener public void onRightClickBlock(InteractBlockEvent.Secondary event){ BlockSnapshot b = event.getTargetBlock(); if (!(b.getState().getType().equals(BlockTypes.WALL_SIGN) || b.getState().getType().equals(BlockTypes.STANDING_SIGN))) { return; } Player p = event.getCause().first(Player.class).get(); SerializedBlockLocation sbl = SpongeSerializedBlockLocation.create(b.getLocation().get()); for (SavedBuyNowSign s : plugin.getBuyNowSignStorage().getSigns()) { if (s.getLocation().equals(sbl)) { // Signs are rate limited (per player) in order to limit API calls issued. Long ts = signCooldowns.get(p.getUniqueId()); long now = System.currentTimeMillis(); if (ts == null || ts + COOLDOWN_MS <= now) { signCooldowns.put(p.getUniqueId(), now); plugin.getPlatform().executeAsync(new SendCheckoutLinkTask(plugin, s.getPackageId(), p)); } return; } } } }
public CommandResult createCoupon(CommandSource source, CommandContext ctx) throws CommandException { Collection<String> argsList = ctx.getAll("args"); String[] argsArray = argsList.toArray(new String[argsList.size()]); final Coupon coupon; try { coupon = CouponUtil.parseArguments(argsArray); } catch (Exception e) { source.sendMessage(Text.builder(plugin.getI18n().get("coupon_creation_arg_parse_failure", e.getMessage())) .color(TextColors.RED) .build()); return CommandResult.empty(); } plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() { try { plugin.getApiClient().createCoupon(coupon); source.sendMessage(Text.builder(plugin.getI18n().get("coupon_creation_success", coupon.getCode())) .color(TextColors.GREEN) .build()); } catch (ApiException | IOException e) { source.sendMessage(Text.builder(plugin.getI18n().get("generic_api_operation_error")) .color(TextColors.RED) .build()); } } }); return CommandResult.empty(); }
plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() {
@Override public void execute(final CommandSender sender, String[] args) { sender.sendMessage(TextFormat.YELLOW + plugin.getI18n().get("report_wait")); plugin.getPlatform().executeAsync(() -> { ReportBuilder builder = ReportBuilder.builder() .client(plugin.getHttpClient()) .configuration(plugin.getConfiguration()) .platform(plugin.getPlatform()) .duePlayerFetcher(plugin.getDuePlayerFetcher()) .ip(plugin.getServer().getIp()) .port(plugin.getServer().getPort()) .serverOnlineMode(false) .build(); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); String filename = "report-" + f.format(new Date()) + ".txt"; Path p = plugin.getDataFolder().toPath().resolve(filename); String generated = builder.generate(); try (BufferedWriter w = Files.newBufferedWriter(p, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) { w.write(generated); sender.sendMessage(TextFormat.YELLOW + plugin.getI18n().get("report_saved", p.toAbsolutePath().toString())); } catch (IOException e) { sender.sendMessage(TextFormat.RED + plugin.getI18n().get("report_cant_save")); plugin.getLogger().info(generated); } }); }
src.sendMessage(Text.builder(plugin.getI18n().get("report_wait")).color(TextColors.RED).build()); plugin.getPlatform().executeAsync(() -> { String serverIP = (Sponge.getServer().getBoundAddress().isPresent()) ? Sponge.getServer().getBoundAddress().get().getHostName() : "?"; int serverPort = (Sponge.getServer().getBoundAddress().isPresent()) ? Sponge.getServer().getBoundAddress().get().getPort() : -1;
private void sendPaginatedMessage(Node node, CommandSource source) { PaginationService paginationService = Sponge.getServiceManager().provide(PaginationService.class).get(); PaginationList.Builder builder = paginationService.builder(); List<Text> contents = node.getSubcategories().stream() .map(category -> Text.builder("> " + category.getName()).color(TextColors.GRAY).onClick(TextActions.executeCallback(commandSource -> { if (commandSource instanceof Player) { sendPaginatedMessage(node.getChild(category), source); } })).build()).collect(Collectors.toList()); for (Package p : node.getPackages()) { contents.add(Text.builder(p.getName()).color(TextColors.WHITE).append(Text.builder(" - ").color(TextColors.GRAY).build()) .append(Text.builder("$x".replace("$", plugin.getServerInformation().getAccount().getCurrency().getSymbol()) .replace("x", "" + p.getEffectivePrice())).color(TextColors.GREEN).build()) .onClick(TextActions.executeCallback(commandSource -> { if (commandSource instanceof Player) { plugin.getPlatform().executeAsync(new SendCheckoutLinkTask(plugin, p.getId(), (Player) commandSource)); } })).build()); } builder.title(Text.builder(plugin.getI18n().get("sponge_listing")).color(TextColors.AQUA).build()).contents(contents).padding(Text.of("-")).sendTo(source); }
plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() {
@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(); } }
src.sendMessage(Text.builder(plugin.getI18n().get("secret_need_key")).color(TextColors.RED).build()); } else { plugin.getPlatform().executeAsync(new Runnable() { @Override public void run() {
plugin.getPlatform().executeAsync(new BuyNowSignUpdater(plugin));
@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")); }
plugin.getPlatform().executeAsync(new SignUpdater(plugin));