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();
}
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();
}
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();
}
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();
}
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()));
}
Aggregations