Search in sources :

Example 21 with HoverEvent

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

the class LangFormatter method handleHover.

@Nonnull
private static HoverEvent handleHover(@Nonnull String token) {
    String[] args = token.split(":");
    HoverEvent hoverEvent;
    if (args.length < 2)
        throw new VoxelGameLibException("Can't parse hover action (too few args) " + token);
    switch(args[1]) {
        case "show_text":
            hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, parseFormat(token.replace("hover:show_text:", "")));
            break;
        case "show_item":
            hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_ITEM, parseFormat(token.replace("hover:show_item:", "")));
            break;
        case "show_entity":
            hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_ENTITY, parseFormat(token.replace("hover:show_entity:", "")));
            break;
        default:
            throw new VoxelGameLibException("Can't parse hover action (invalid type " + args[1] + ") " + token);
    }
    return hoverEvent;
}
Also used : HoverEvent(net.kyori.text.event.HoverEvent) VoxelGameLibException(com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException) Nonnull(javax.annotation.Nonnull)

Aggregations

HoverEvent (net.kyori.text.event.HoverEvent)21 TextComponent (net.kyori.text.TextComponent)20 ClickEvent (net.kyori.text.event.ClickEvent)13 List (java.util.List)11 Message (me.lucko.luckperms.common.locale.message.Message)11 Sender (me.lucko.luckperms.common.sender.Sender)11 CommandPermission (me.lucko.luckperms.common.command.access.CommandPermission)10 LocaleManager (me.lucko.luckperms.common.locale.LocaleManager)10 LuckPermsPlugin (me.lucko.luckperms.common.plugin.LuckPermsPlugin)10 CommandResult (me.lucko.luckperms.common.command.CommandResult)9 MessageUtils (me.lucko.luckperms.common.command.utils.MessageUtils)9 CommandSpec (me.lucko.luckperms.common.locale.command.CommandSpec)9 Predicates (me.lucko.luckperms.common.utils.Predicates)9 TextUtils (me.lucko.luckperms.common.utils.TextUtils)9 ArrayList (java.util.ArrayList)8 CommandManager (me.lucko.luckperms.common.command.CommandManager)8 Consumer (java.util.function.Consumer)7 Node (me.lucko.luckperms.api.Node)7 Map (java.util.Map)6 MutableContextSet (me.lucko.luckperms.api.context.MutableContextSet)6