use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitSetCooldownCommand method executeCommand.
@Override
public CommandResult executeCommand(final CommandSource player, CommandContext args) throws Exception {
Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
long seconds = args.<Long>getOne(duration).get();
kitInfo.setCooldown(Duration.ofSeconds(seconds));
KIT_HANDLER.saveKit(kitInfo);
player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.setcooldown.success", kitInfo.getName(), Util.getTimeStringFromSeconds(seconds)));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitSetFirstJoinCommand 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).orElse(false);
// This Kit is a reference back to the version in list, so we don't need
// to update it explicitly
kitInfo.setFirstJoinKit(b);
KIT_HANDLER.saveKit(kitInfo);
player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat(b ? "command.kit.setfirstjoin.on" : "command.kit.setfirstjoin.off", kitInfo.getName()));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitClearCommandCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
kitInfo.setCommands(Lists.newArrayList());
KIT_HANDLER.saveKit(kitInfo);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.command.clear.command", kitInfo.getName()));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitCommandCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
// List all commands on a kit.
Kit kit = args.<Kit>getOne(KIT_PARAMETER).get();
List<String> commands = kit.getCommands();
if (commands.isEmpty()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.command.nocommands", kit.getName()));
} else {
List<Text> cc = Lists.newArrayList();
for (int i = 0; i < commands.size(); i++) {
Text t = plugin.getMessageProvider().getTextMessageWithFormat("command.kit.command.commands.entry", String.valueOf(i + 1), commands.get(i));
if (src.hasPermission(removePermission)) {
t = Text.of(Text.builder().append(removeIcon).onClick(TextActions.runCommand("/nucleus:kit command remove " + kit.getName() + " " + commands.get(i))).onHover(TextActions.showText(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.command.removehover"))).build(), " ", t);
}
cc.add(t);
}
Util.getPaginationBuilder(src).title(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.command.commands.title", kit.getName())).contents(cc).sendTo(src);
}
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.
the class KitEditCommandCommand method executeCommand.
@Override
protected CommandResult executeCommand(Player src, CommandContext args) throws Exception {
final Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
List<String> commands = kitInfo.getCommands();
if (commands.size() > 9 * 6) {
throw ReturnMessageException.fromKey("command.kit.command.edit.toomany", kitInfo.getName());
}
// Create an inventory with signed books.
Random r = new Random();
List<ItemStack> books = commands.stream().map(x -> {
ItemStack stack = ItemStack.of(ItemTypes.WRITTEN_BOOK, 1);
Text command = Text.of(x);
stack.offer(Keys.DISPLAY_NAME, command);
stack.offer(Keys.BOOK_PAGES, Lists.newArrayList(command));
// So books don't stack.
stack.offer(Keys.BOOK_AUTHOR, Text.of(kitInfo.getName(), "-", r.nextInt()));
return stack;
}).collect(Collectors.toList());
// Create Inventory GUI.
final InventoryTitle title = InventoryTitle.of(Text.of("Kit Commands: ", kitInfo.getName()));
final Inventory inventory = Inventory.builder().of(InventoryArchetypes.DOUBLE_CHEST).property(InventoryTitle.PROPERTY_NAME, title).build(plugin);
books.forEach(inventory::offer);
src.openInventory(inventory).ifPresent(x -> KIT_HANDLER.addKitCommandInventoryToListener(Tuple.of(kitInfo, inventory), x));
return CommandResult.success();
}
Aggregations