Search in sources :

Example 1 with ClickEvent

use of net.kyori.text.event.ClickEvent in project VoxelGamesLibv2 by VoxelGamesLib.

the class WorldCreator method author.

@Subcommand("author")
@CommandPermission("%admin")
public void author(@Nonnull User sender, @Nonnull String author) {
    if (step != 5) {
        Lang.msg(sender, LangKey.WORLD_CREATOR_WRONG_STEP, step, 5);
        return;
    }
    this.author = author;
    Lang.msg(sender, LangKey.WORLD_CREATOR_AUTHOR_SET, author);
    for (GameMode mode : gameHandler.getGameModes()) {
        sender.sendMessage(TextComponent.of(mode.getName() + " ").color(TextColor.YELLOW).clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/worldcreator gamemode " + mode.getName())));
    }
    Lang.msg(sender, LangKey.WORLD_CREATOR_DONE_QUERY, "/worldcreator gamemode done");
    step = 6;
}
Also used : GameMode(com.voxelgameslib.voxelgameslib.game.GameMode) ClickEvent(net.kyori.text.event.ClickEvent) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 2 with ClickEvent

use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.

the class SearchCommand method makeFancy.

private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, HolderType holderType, String label, HeldPermission<?> perm) {
    HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline("&3> " + (perm.asNode().getValuePrimitive() ? "&a" : "&c") + perm.asNode().getPermission(), " ", "&7Click to remove this node from " + holderName), CommandManager.AMPERSAND_CHAR));
    String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, holderType, false);
    ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
    return component -> {
        component.hoverEvent(hoverEvent);
        component.clickEvent(clickEvent);
    };
}
Also used : TextUtils(me.lucko.luckperms.common.utils.TextUtils) LocaleManager(me.lucko.luckperms.common.locale.LocaleManager) SingleCommand(me.lucko.luckperms.common.command.abstraction.SingleCommand) HoverEvent(net.kyori.text.event.HoverEvent) Function(java.util.function.Function) ArgumentParser(me.lucko.luckperms.common.command.utils.ArgumentParser) ArrayList(java.util.ArrayList) DateUtil(me.lucko.luckperms.common.utils.DateUtil) CommandSpec(me.lucko.luckperms.common.locale.command.CommandSpec) ClickEvent(net.kyori.text.event.ClickEvent) Map(java.util.Map) Message(me.lucko.luckperms.common.locale.message.Message) HolderType(me.lucko.luckperms.common.references.HolderType) LuckPermsPlugin(me.lucko.luckperms.common.plugin.LuckPermsPlugin) HeldPermission(me.lucko.luckperms.api.HeldPermission) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) CommandManager(me.lucko.luckperms.common.command.CommandManager) LoadingCache(com.github.benmanes.caffeine.cache.LoadingCache) MessageUtils(me.lucko.luckperms.common.command.utils.MessageUtils) NodeFactory(me.lucko.luckperms.common.node.NodeFactory) Sender(me.lucko.luckperms.common.sender.Sender) UUID(java.util.UUID) Iterators(me.lucko.luckperms.common.utils.Iterators) TextComponent(net.kyori.text.TextComponent) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) CommandResult(me.lucko.luckperms.common.command.CommandResult) Consumer(java.util.function.Consumer) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission) List(java.util.List) TabCompletions(me.lucko.luckperms.common.command.utils.TabCompletions) BuildableComponent(net.kyori.text.BuildableComponent) Node(me.lucko.luckperms.api.Node) Predicates(me.lucko.luckperms.common.utils.Predicates) HoverEvent(net.kyori.text.event.HoverEvent) ClickEvent(net.kyori.text.event.ClickEvent)

Example 3 with ClickEvent

use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.

the class TreeCommand method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
    String selection = ".";
    String player = null;
    if (!args.isEmpty()) {
        selection = args.get(0);
    }
    if (args.size() > 1) {
        player = args.get(1);
    }
    User user;
    if (player != null) {
        UUID u = Uuids.parseNullable(player);
        if (u != null) {
            user = plugin.getUserManager().getIfLoaded(u);
        } else {
            user = plugin.getUserManager().getByUsername(player);
        }
        if (user == null) {
            Message.USER_NOT_ONLINE.send(sender, player);
            return CommandResult.STATE_ERROR;
        }
    } else {
        user = null;
    }
    TreeView view = new TreeView(plugin.getPermissionVault(), selection);
    if (!view.hasData()) {
        Message.TREE_EMPTY.send(sender);
        return CommandResult.FAILURE;
    }
    Message.TREE_UPLOAD_START.send(sender);
    PermissionCache permissionData = user == null ? null : user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts()));
    String id = view.uploadPasteData(sender, user, permissionData);
    String url = plugin.getConfiguration().get(ConfigKeys.TREE_VIEWER_URL_PATTERN) + "?" + id;
    Message.TREE_URL.send(sender);
    Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))).build();
    sender.sendMessage(message);
    return CommandResult.SUCCESS;
}
Also used : HoverEvent(net.kyori.text.event.HoverEvent) User(me.lucko.luckperms.common.model.User) ClickEvent(net.kyori.text.event.ClickEvent) TreeView(me.lucko.luckperms.common.treeview.TreeView) PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) UUID(java.util.UUID) TextComponent(net.kyori.text.TextComponent) Component(net.kyori.text.Component)

Example 4 with ClickEvent

use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.

the class VerboseCommand method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
    if (args.isEmpty()) {
        sendUsage(sender, label);
        return CommandResult.INVALID_ARGS;
    }
    String mode = args.get(0).toLowerCase();
    if (mode.equals("on") || mode.equals("true") || mode.equals("record")) {
        List<String> filters = new ArrayList<>();
        if (args.size() != 1) {
            filters.addAll(args.subList(1, args.size()));
        }
        String filter = filters.isEmpty() ? "" : filters.stream().collect(Collectors.joining(" "));
        VerboseFilter parsedFilter;
        try {
            parsedFilter = VerboseFilter.parse(filter);
        } catch (InvalidFilterException e) {
            e.printStackTrace();
            Message.VERBOSE_INVALID_FILTER.send(sender, filter);
            return CommandResult.FAILURE;
        }
        boolean notify = !mode.equals("record");
        plugin.getVerboseHandler().registerListener(sender, parsedFilter, notify);
        if (notify) {
            if (!filter.equals("")) {
                Message.VERBOSE_ON_QUERY.send(sender, filter);
            } else {
                Message.VERBOSE_ON.send(sender);
            }
        } else {
            if (!filter.equals("")) {
                Message.VERBOSE_RECORDING_ON_QUERY.send(sender, filter);
            } else {
                Message.VERBOSE_RECORDING_ON.send(sender);
            }
        }
        return CommandResult.SUCCESS;
    }
    if (mode.equals("off") || mode.equals("false") || mode.equals("paste") || mode.equals("upload")) {
        VerboseListener listener = plugin.getVerboseHandler().unregisterListener(sender.getUuid());
        if (mode.equals("paste") || mode.equals("upload")) {
            if (listener == null) {
                Message.VERBOSE_OFF.send(sender);
            } else {
                Message.VERBOSE_UPLOAD_START.send(sender);
                String id = listener.uploadPasteData();
                String url = plugin.getConfiguration().get(ConfigKeys.VERBOSE_VIEWER_URL_PATTERN) + "?" + id;
                Message.VERBOSE_RESULTS_URL.send(sender);
                Component message = TextComponent.builder(url).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(url))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the results page.").color(TextColor.GRAY))).build();
                sender.sendMessage(message);
                return CommandResult.SUCCESS;
            }
        } else {
            Message.VERBOSE_OFF.send(sender);
        }
        return CommandResult.SUCCESS;
    }
    sendUsage(sender, label);
    return CommandResult.INVALID_ARGS;
}
Also used : HoverEvent(net.kyori.text.event.HoverEvent) InvalidFilterException(me.lucko.luckperms.common.verbose.InvalidFilterException) ClickEvent(net.kyori.text.event.ClickEvent) ArrayList(java.util.ArrayList) VerboseListener(me.lucko.luckperms.common.verbose.VerboseListener) TextComponent(net.kyori.text.TextComponent) Component(net.kyori.text.Component) VerboseFilter(me.lucko.luckperms.common.verbose.VerboseFilter)

Example 5 with ClickEvent

use of net.kyori.text.event.ClickEvent in project LuckPerms by lucko.

the class DebugCommand method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
    Message.DEBUG_START.send(sender);
    StringBuilder sb = new StringBuilder();
    sb.append("LuckPerms Debug Output\n\n\n");
    BiConsumer<String, JObject> builder = (name, content) -> {
        sb.append("-- ").append(name).append(" --\n");
        sb.append(GSON.toJson(content.toJson()));
        sb.append("\n\n");
    };
    builder.accept("platform.json", getPlatformData(plugin));
    builder.accept("storage.json", getStorageData(plugin));
    builder.accept("context.json", getContextData(plugin));
    builder.accept("players.json", getPlayersData(plugin));
    Pastebin.Paste paste = StandardPastebin.HASTEBIN.postPlain(sb.toString());
    Message.DEBUG_URL.send(sender);
    Component message = TextComponent.builder(paste.url()).color(TextColor.AQUA).clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(paste.url()))).hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the debugging data.").color(TextColor.GRAY))).build();
    sender.sendMessage(message);
    return CommandResult.SUCCESS;
}
Also used : LookupSetting(me.lucko.luckperms.api.LookupSetting) PermissionProcessor(me.lucko.luckperms.common.processors.PermissionProcessor) Contexts(me.lucko.luckperms.api.Contexts) MetaStackElement(me.lucko.luckperms.api.metastacking.MetaStackElement) LocaleManager(me.lucko.luckperms.common.locale.LocaleManager) SingleCommand(me.lucko.luckperms.common.command.abstraction.SingleCommand) HoverEvent(net.kyori.text.event.HoverEvent) GsonBuilder(com.google.gson.GsonBuilder) CommandSpec(me.lucko.luckperms.common.locale.command.CommandSpec) TextColor(net.kyori.text.format.TextColor) Gson(com.google.gson.Gson) ClickEvent(net.kyori.text.event.ClickEvent) Map(java.util.Map) Message(me.lucko.luckperms.common.locale.message.Message) BiConsumer(java.util.function.BiConsumer) LuckPermsPlugin(me.lucko.luckperms.common.plugin.LuckPermsPlugin) JObject(me.lucko.luckperms.common.utils.gson.JObject) Pastebin(me.lucko.luckperms.common.web.Pastebin) ProxiedContextCalculator(me.lucko.luckperms.common.contexts.ProxiedContextCalculator) Collection(java.util.Collection) PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) Set(java.util.Set) Sender(me.lucko.luckperms.common.sender.Sender) UUID(java.util.UUID) StaticContextCalculator(me.lucko.luckperms.api.context.StaticContextCalculator) ContextSetJsonSerializer(me.lucko.luckperms.common.contexts.ContextSetJsonSerializer) TextComponent(net.kyori.text.TextComponent) JArray(me.lucko.luckperms.common.utils.gson.JArray) Collectors(java.util.stream.Collectors) CommandResult(me.lucko.luckperms.common.command.CommandResult) StandardPastebin(me.lucko.luckperms.common.web.StandardPastebin) MetaContexts(me.lucko.luckperms.api.caching.MetaContexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache) CommandPermission(me.lucko.luckperms.common.command.access.CommandPermission) List(java.util.List) Component(net.kyori.text.Component) MetaStackDefinition(me.lucko.luckperms.api.metastacking.MetaStackDefinition) ContextCalculator(me.lucko.luckperms.api.context.ContextCalculator) User(me.lucko.luckperms.common.model.User) Predicates(me.lucko.luckperms.common.utils.Predicates) HoverEvent(net.kyori.text.event.HoverEvent) ClickEvent(net.kyori.text.event.ClickEvent) JObject(me.lucko.luckperms.common.utils.gson.JObject) TextComponent(net.kyori.text.TextComponent) Component(net.kyori.text.Component) Pastebin(me.lucko.luckperms.common.web.Pastebin) StandardPastebin(me.lucko.luckperms.common.web.StandardPastebin)

Aggregations

ClickEvent (net.kyori.text.event.ClickEvent)15 TextComponent (net.kyori.text.TextComponent)13 HoverEvent (net.kyori.text.event.HoverEvent)13 List (java.util.List)10 CommandPermission (me.lucko.luckperms.common.command.access.CommandPermission)10 LocaleManager (me.lucko.luckperms.common.locale.LocaleManager)10 Message (me.lucko.luckperms.common.locale.message.Message)10 LuckPermsPlugin (me.lucko.luckperms.common.plugin.LuckPermsPlugin)10 Sender (me.lucko.luckperms.common.sender.Sender)10 CommandResult (me.lucko.luckperms.common.command.CommandResult)9 CommandSpec (me.lucko.luckperms.common.locale.command.CommandSpec)9 Predicates (me.lucko.luckperms.common.utils.Predicates)9 MessageUtils (me.lucko.luckperms.common.command.utils.MessageUtils)8 TextUtils (me.lucko.luckperms.common.utils.TextUtils)8 ArrayList (java.util.ArrayList)7 CommandManager (me.lucko.luckperms.common.command.CommandManager)7 Consumer (java.util.function.Consumer)6 ArgumentPermissions (me.lucko.luckperms.common.command.access.ArgumentPermissions)6 ArgumentParser (me.lucko.luckperms.common.command.utils.ArgumentParser)6 NodeFactory (me.lucko.luckperms.common.node.NodeFactory)6