Search in sources :

Example 31 with MessageProvider

use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.

the class PowertoolCommand method viewPowertool.

private CommandResult viewPowertool(Player src, PowertoolUserDataModule user, ItemStack item) {
    Optional<List<String>> cmds = user.getPowertoolForItem(item.getType());
    MessageProvider mp = plugin.getMessageProvider();
    if (cmds.isPresent() && !cmds.get().isEmpty()) {
        Util.getPaginationBuilder(src).contents(cmds.get().stream().map(f -> Text.of(TextColors.YELLOW, f)).collect(Collectors.toList())).title(mp.getTextMessageWithTextFormat("command.powertool.viewcmdstitle", Text.of(item), Text.of(item.getType().getId()))).sendTo(src);
    } else {
        src.sendMessage(mp.getTextMessageWithTextFormat("command.powertool.nocmds", Text.of(item)));
    }
    return CommandResult.success();
}
Also used : MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) List(java.util.List)

Example 32 with MessageProvider

use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.

the class TogglePowertoolCommand method executeCommand.

@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
    PowertoolUserDataModule user = Nucleus.getNucleus().getUserDataManager().getUnchecked(src).get(PowertoolUserDataModule.class);
    // If specified - get the key. Else, the inverse of what we have now.
    boolean toggle = args.<Boolean>getOne(toggleKey).orElse(!user.isPowertoolToggled());
    user.setPowertoolToggle(toggle);
    MessageProvider mp = plugin.getMessageProvider();
    src.sendMessage(mp.getTextMessageWithFormat("command.powertool.toggle", mp.getMessageWithFormat(toggle ? "standard.enabled" : "standard.disabled")));
    return CommandResult.success();
}
Also used : MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) PowertoolUserDataModule(io.github.nucleuspowered.nucleus.modules.powertool.datamodules.PowertoolUserDataModule)

Example 33 with MessageProvider

use of io.github.nucleuspowered.nucleus.internal.messages.MessageProvider in project Nucleus by NucleusPowered.

the class ListWarpCommand method createMain.

private void createMain(final CommandSource src, final Map<WarpCategory, List<Warp>> warps) {
    List<Text> lt = warps.keySet().stream().filter(Objects::nonNull).sorted(Comparator.comparing(WarpCategory::getId)).map(s -> {
        Text.Builder t = Text.builder("> ").color(TextColors.GREEN).style(TextStyles.ITALIC).append(s.getDisplayName()).onClick(TextActions.executeCallback(source -> createSub(source, s, warps)));
        s.getDescription().ifPresent(x -> t.append(Text.of(" - ")).append(Text.of(TextColors.RESET, TextStyles.NONE, x)));
        return t.build();
    }).collect(Collectors.toList());
    // Uncategorised
    if (warps.containsKey(null)) {
        lt.add(Text.builder("> " + this.defaultName).color(TextColors.GREEN).style(TextStyles.ITALIC).onClick(TextActions.executeCallback(source -> createSub(source, null, warps))).build());
    }
    MessageProvider messageProvider = plugin.getMessageProvider();
    Util.getPaginationBuilder(src).header(messageProvider.getTextMessageWithFormat("command.warps.list.headercategory")).title(messageProvider.getTextMessageWithFormat("command.warps.list.maincategory")).padding(Text.of(TextColors.GREEN, "-")).contents(lt).sendTo(src);
}
Also used : RegisterCommand(io.github.nucleuspowered.nucleus.internal.annotations.command.RegisterCommand) NonnullByDefault(org.spongepowered.api.util.annotation.NonnullByDefault) GenericArguments(org.spongepowered.api.command.args.GenericArguments) RunAsync(io.github.nucleuspowered.nucleus.internal.annotations.RunAsync) Warp(io.github.nucleuspowered.nucleus.api.nucleusdata.Warp) PermissionRegistry(io.github.nucleuspowered.nucleus.internal.PermissionRegistry) CommandContext(org.spongepowered.api.command.args.CommandContext) Text(org.spongepowered.api.text.Text) WarpHandler(io.github.nucleuspowered.nucleus.modules.warp.handlers.WarpHandler) WarpCategory(io.github.nucleuspowered.nucleus.api.nucleusdata.WarpCategory) WarpConfigAdapter(io.github.nucleuspowered.nucleus.modules.warp.config.WarpConfigAdapter) Map(java.util.Map) SuggestedLevel(io.github.nucleuspowered.nucleus.internal.permissions.SuggestedLevel) Util(io.github.nucleuspowered.nucleus.Util) Permissions(io.github.nucleuspowered.nucleus.internal.annotations.command.Permissions) TextColors(org.spongepowered.api.text.format.TextColors) Nullable(javax.annotation.Nullable) CommandResult(org.spongepowered.api.command.CommandResult) TextActions(org.spongepowered.api.text.action.TextActions) Location(org.spongepowered.api.world.Location) CommandSource(org.spongepowered.api.command.CommandSource) TextStyles(org.spongepowered.api.text.format.TextStyles) WarpConfig(io.github.nucleuspowered.nucleus.modules.warp.config.WarpConfig) Set(java.util.Set) CommandElement(org.spongepowered.api.command.args.CommandElement) Collectors(java.util.stream.Collectors) Reloadable(io.github.nucleuspowered.nucleus.internal.interfaces.Reloadable) Objects(java.util.Objects) List(java.util.List) AbstractCommand(io.github.nucleuspowered.nucleus.internal.command.AbstractCommand) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) World(org.spongepowered.api.world.World) Optional(java.util.Optional) Comparator(java.util.Comparator) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) Text(org.spongepowered.api.text.Text)

Aggregations

MessageProvider (io.github.nucleuspowered.nucleus.internal.messages.MessageProvider)33 Text (org.spongepowered.api.text.Text)18 Nucleus (io.github.nucleuspowered.nucleus.Nucleus)10 List (java.util.List)10 Util (io.github.nucleuspowered.nucleus.Util)8 Collectors (java.util.stream.Collectors)8 CommandSource (org.spongepowered.api.command.CommandSource)8 AbstractCommand (io.github.nucleuspowered.nucleus.internal.command.AbstractCommand)7 Nullable (javax.annotation.Nullable)7 CommandResult (org.spongepowered.api.command.CommandResult)7 CommandContext (org.spongepowered.api.command.args.CommandContext)7 NonnullByDefault (org.spongepowered.api.util.annotation.NonnullByDefault)7 Permissions (io.github.nucleuspowered.nucleus.internal.annotations.command.Permissions)6 RegisterCommand (io.github.nucleuspowered.nucleus.internal.annotations.command.RegisterCommand)6 Optional (java.util.Optional)6 Sponge (org.spongepowered.api.Sponge)6 User (org.spongepowered.api.entity.living.player.User)6 TextActions (org.spongepowered.api.text.action.TextActions)6 RunAsync (io.github.nucleuspowered.nucleus.internal.annotations.RunAsync)5 ReturnMessageException (io.github.nucleuspowered.nucleus.internal.command.ReturnMessageException)5