use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitEditCommand method executeCommand.
@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
final Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
if (KIT_HANDLER.isOpen(kitInfo.getName())) {
throw new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.edit.current", kitInfo.getName()));
}
Inventory inventory = Util.getKitInventoryBuilder().property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.edit.title", kitInfo.getName()))).build(plugin);
kitInfo.getStacks().stream().filter(x -> !x.getType().equals(ItemTypes.NONE)).forEach(x -> inventory.offer(x.createStack()));
Optional<Container> openedInventory = src.openInventory(inventory);
if (openedInventory.isPresent()) {
KIT_HANDLER.addKitInventoryToListener(Tuple.of(kitInfo, inventory), openedInventory.get());
return CommandResult.success();
}
throw ReturnMessageException.fromKey("command.kit.edit.cantopen", kitInfo.getName());
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitInfoCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Kit kit = args.<Kit>getOne(KIT_PARAMETER).get();
MessageProvider mp = this.plugin.getMessageProvider();
Util.getPaginationBuilder(src).title(mp.getTextMessageWithFormat("command.kit.info.title", kit.getName())).contents(addViewHover(mp, kit), addCommandHover(mp, kit), mp.getTextMessageWithFormat("command.kit.info.sep"), mp.getTextMessageWithFormat("command.kit.info.firstjoin", yesno(mp, kit.isFirstJoinKit())), mp.getTextMessageWithFormat("command.kit.info.cost", String.valueOf(kit.getCost())), mp.getTextMessageWithFormat("command.kit.info.cooldown", kit.getCooldown().map(x -> Util.getTimeStringFromSeconds(x.getSeconds())).orElse(mp.getMessageWithFormat("standard.none"))), mp.getTextMessageWithFormat("command.kit.info.onetime", yesno(mp, kit.isOneTime())), mp.getTextMessageWithFormat("command.kit.info.autoredeem", yesno(mp, kit.isAutoRedeem())), mp.getTextMessageWithFormat("command.kit.info.hidden", yesno(mp, kit.isHiddenFromList())), mp.getTextMessageWithFormat("command.kit.info.displayredeem", yesno(mp, kit.isAutoRedeem())), mp.getTextMessageWithFormat("command.kit.info.ignoresperm", yesno(mp, kit.ignoresPermission()))).sendTo(src);
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitRedeemMessageCommand method executeCommand.
@Override
public CommandResult executeCommand(final CommandSource player, CommandContext args) throws Exception {
Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
boolean b = args.<Boolean>getOne(toggle).get();
// This Kit is a reference back to the version in list, so we don't need
// to update it explicitly
kitInfo.setDisplayMessageOnRedeem(b);
KIT_HANDLER.saveKit(kitInfo);
player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat(b ? "command.kit.displaymessage.on" : "command.kit.displaymessage.off", kitInfo.getName()));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitResetUsageCommand method executeCommand.
@Override
public CommandResult executeCommand(final CommandSource player, CommandContext args) throws Exception {
Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
User u = args.<User>getOne(user).get();
KitUserDataModule inu = Nucleus.getNucleus().getUserDataManager().getUnchecked(u).get(KitUserDataModule.class);
if (Util.getKeyIgnoreCase(inu.getKitLastUsedTime(), kitInfo.getName()).isPresent()) {
// Remove the key.
inu.removeKitLastUsedTime(kitInfo.getName().toLowerCase());
player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.resetuser.success", u.getName(), kitInfo.getName()));
return CommandResult.success();
}
throw ReturnMessageException.fromKey("command.kit.resetuser.empty", u.getName(), kitInfo.getName());
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitCostCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Kit kit = args.<Kit>getOne(KIT_PARAMETER).get();
double cost = args.<Double>getOne(costKey).get();
if (cost < 0) {
cost = 0;
}
kit.setCost(cost);
KIT_HANDLER.saveKit(kit);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.cost.success", kit.getName(), String.valueOf(cost)));
return CommandResult.success();
}
Aggregations