use of io.github.nucleuspowered.nucleus.internal.command.ContinueMode in project Nucleus by NucleusPowered.
the class WarpCommand method preProcessChecks.
@Override
protected ContinueMode preProcessChecks(final CommandSource source, CommandContext args) {
if (args.<Player>getOne(playerKey).map(x -> !(source instanceof Player) || x.getUniqueId().equals(((Player) source).getUniqueId())).orElse(false)) {
// Bypass cooldowns
args.putArg(NoModifiersArgument.NO_COOLDOWN_ARGUMENT, true);
return ContinueMode.CONTINUE;
}
if (!plugin.getEconHelper().economyServiceExists() || permissions.testCostExempt(source) || args.hasAny("y")) {
return ContinueMode.CONTINUE;
}
Warp wd = args.<Warp>getOne(warpNameArg).get();
Optional<Double> i = wd.getCost();
double cost = i.orElse(this.defaultCost);
if (cost <= 0) {
return ContinueMode.CONTINUE;
}
String costWithUnit = plugin.getEconHelper().getCurrencySymbol(cost);
if (plugin.getEconHelper().hasBalance((Player) source, cost)) {
String command = String.format("/warp -y %s", wd.getName());
source.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.warp.cost.details", wd.getName(), costWithUnit));
source.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.warp.cost.clickaccept").toBuilder().onClick(TextActions.runCommand(command)).onHover(TextActions.showText(plugin.getMessageProvider().getTextMessageWithFormat("command.warp.cost.clickhover", command))).append(plugin.getMessageProvider().getTextMessageWithFormat("command.warp.cost.alt")).build());
} else {
source.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.warp.cost.nomoney", wd.getName(), costWithUnit));
}
return ContinueMode.STOP;
}
Aggregations