Search in sources :

Example 16 with Kit

use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.

the class KitOneTimeCommand method executeCommand.

@Override
public CommandResult executeCommand(final CommandSource player, CommandContext args) throws Exception {
    Kit kitInfo = args.<Kit>getOne(this.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.setOneTime(b);
    KIT_HANDLER.saveKit(kitInfo);
    player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat(b ? "command.kit.onetime.on" : "command.kit.onetime.off", kitInfo.getName()));
    return CommandResult.success();
}
Also used : Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit)

Example 17 with Kit

use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.

the class KitPermissionBypassCommand 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.setIgnoresPermission(b);
    KIT_HANDLER.saveKit(kitInfo);
    player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat(b ? "command.kit.permissionbypass.on" : "command.kit.permissionbypass.off", kitInfo.getName().toLowerCase()));
    return CommandResult.success();
}
Also used : Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit)

Example 18 with Kit

use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.

the class KitRemoveCommand method executeCommand.

@Override
public CommandResult executeCommand(final CommandSource player, CommandContext args) throws Exception {
    Kit kitName = args.<Kit>getOne(KIT_PARAMETER).get();
    KIT_HANDLER.removeKit(kitName.getName());
    player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.remove.success", kitName.getName()));
    return CommandResult.success();
}
Also used : Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit)

Example 19 with Kit

use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.

the class KitSetCommand method executeCommand.

@Override
public CommandResult executeCommand(final Player player, CommandContext args) throws Exception {
    Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
    kitInfo.updateKitInventory(player);
    KIT_HANDLER.saveKit(kitInfo);
    player.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.set.success", kitInfo.getName()));
    return CommandResult.success();
}
Also used : Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit)

Example 20 with Kit

use of io.github.nucleuspowered.nucleus.api.nucleusdata.Kit in project Nucleus by NucleusPowered.

the class KitViewCommand method executeCommand.

@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
    final Kit kitInfo = args.<Kit>getOne(KIT_PARAMETER).get();
    Inventory inventory = Util.getKitInventoryBuilder().property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(plugin.getMessageProvider().getTextMessageWithFormat("command.kit.view.title", kitInfo.getName()))).build(this.plugin);
    List<ItemStack> lis = kitInfo.getStacks().stream().filter(x -> !x.getType().equals(ItemTypes.NONE)).map(ItemStackSnapshot::createStack).collect(Collectors.toList());
    if (this.processTokens) {
        KIT_HANDLER.processTokensInItemStacks(src, lis);
    }
    lis.forEach(inventory::offer);
    return src.openInventory(inventory).map(x -> {
        KIT_HANDLER.addViewer(x);
        return CommandResult.success();
    }).orElseThrow(() -> ReturnMessageException.fromKey("command.kit.view.cantopen", kitInfo.getName()));
}
Also used : Inventory(org.spongepowered.api.item.inventory.Inventory) RegisterCommand(io.github.nucleuspowered.nucleus.internal.annotations.command.RegisterCommand) ItemTypes(org.spongepowered.api.item.ItemTypes) Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit) NonnullByDefault(org.spongepowered.api.util.annotation.NonnullByDefault) Since(io.github.nucleuspowered.nucleus.internal.annotations.Since) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) KitFallbackBase(io.github.nucleuspowered.nucleus.modules.kit.commands.KitFallbackBase) GenericArguments(org.spongepowered.api.command.args.GenericArguments) ItemStack(org.spongepowered.api.item.inventory.ItemStack) CommandContext(org.spongepowered.api.command.args.CommandContext) Text(org.spongepowered.api.text.Text) SuggestedLevel(io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel) Util(io.github.nucleuspowered.nucleus.Util) Permissions(io.github.nucleuspowered.nucleus.internal.annotations.command.Permissions) NoModifiers(io.github.nucleuspowered.nucleus.internal.annotations.command.NoModifiers) CommandResult(org.spongepowered.api.command.CommandResult) KitHandler(io.github.nucleuspowered.nucleus.modules.kit.handlers.KitHandler) ReturnMessageException(io.github.nucleuspowered.nucleus.internal.command.ReturnMessageException) InventoryTitle(org.spongepowered.api.item.inventory.property.InventoryTitle) CommandElement(org.spongepowered.api.command.args.CommandElement) Collectors(java.util.stream.Collectors) Reloadable(io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable) List(java.util.List) AbstractCommand(io.github.nucleuspowered.nucleus.internal.command.AbstractCommand) Player(org.spongepowered.api.entity.living.player.Player) KitArgument(io.github.nucleuspowered.nucleus.argumentparsers.KitArgument) KitConfigAdapter(io.github.nucleuspowered.nucleus.modules.kit.config.KitConfigAdapter) Kit(io.github.nucleuspowered.nucleus.api.nucleusdata.Kit) ItemStack(org.spongepowered.api.item.inventory.ItemStack) Inventory(org.spongepowered.api.item.inventory.Inventory)

Aggregations

Kit (io.github.nucleuspowered.nucleus.api.nucleusdata.Kit)24 Text (org.spongepowered.api.text.Text)7 Player (org.spongepowered.api.entity.living.player.Player)6 ReturnMessageException (io.github.nucleuspowered.nucleus.internal.command.ReturnMessageException)5 NoModifiers (io.github.nucleuspowered.nucleus.internal.annotations.command.NoModifiers)4 Permissions (io.github.nucleuspowered.nucleus.internal.annotations.command.Permissions)4 RegisterCommand (io.github.nucleuspowered.nucleus.internal.annotations.command.RegisterCommand)4 SuggestedLevel (io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel)4 KitFallbackBase (io.github.nucleuspowered.nucleus.modules.kit.commands.KitFallbackBase)4 KitHandler (io.github.nucleuspowered.nucleus.modules.kit.handlers.KitHandler)4 CommandResult (org.spongepowered.api.command.CommandResult)4 CommandContext (org.spongepowered.api.command.args.CommandContext)4 ItemTypes (org.spongepowered.api.item.ItemTypes)4 NonnullByDefault (org.spongepowered.api.util.annotation.NonnullByDefault)4 Lists (com.google.common.collect.Lists)3 Util (io.github.nucleuspowered.nucleus.Util)3 KitRedeemException (io.github.nucleuspowered.nucleus.api.exceptions.KitRedeemException)3 KitArgument (io.github.nucleuspowered.nucleus.argumentparsers.KitArgument)3 Reloadable (io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable)3 KitConfigAdapter (io.github.nucleuspowered.nucleus.modules.kit.config.KitConfigAdapter)3