Search in sources :

Example 21 with Text

use of net.md_5.bungee.api.chat.hover.content.Text in project Denizen-For-Bukkit by DenizenScript.

the class HoverFormatHelper method processHoverInput.

public static boolean processHoverInput(HoverEvent.Action action, TextComponent hoverableText, String input) {
    Content content;
    if (action == HoverEvent.Action.SHOW_ITEM) {
        ItemTag item = ItemTag.valueOf(FormattedTextHelper.unescape(input), CoreUtilities.noDebugContext);
        if (item == null) {
            return true;
        }
        // TODO: Why is there not a direct conversion method for Spigot ItemStack -> BungeeChat Item?
        String itemNbt = NMSHandler.getItemHelper().getRawHoverText(item.getItemStack());
        content = new Item(item.getBukkitMaterial().getKey().toString(), item.getAmount(), net.md_5.bungee.api.chat.ItemTag.ofNbt(itemNbt));
    } else if (action == HoverEvent.Action.SHOW_ENTITY) {
        EntityTag entity = EntityTag.valueOf(FormattedTextHelper.unescape(input), CoreUtilities.basicContext);
        if (entity == null) {
            return true;
        }
        BaseComponent name = null;
        if (entity.getBukkitEntity() != null && entity.getBukkitEntity().isCustomNameVisible()) {
            name = new TextComponent();
            for (BaseComponent component : FormattedTextHelper.parse(entity.getBukkitEntity().getCustomName(), ChatColor.WHITE)) {
                name.addExtra(component);
            }
        }
        content = new Entity(entity.getBukkitEntityType().getKey().toString(), entity.getUUID().toString(), name);
    } else {
        content = new Text(FormattedTextHelper.parse(FormattedTextHelper.unescape(input), ChatColor.WHITE));
    }
    hoverableText.setHoverEvent(new HoverEvent(action, content));
    return false;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Item(net.md_5.bungee.api.chat.hover.content.Item) Entity(net.md_5.bungee.api.chat.hover.content.Entity) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) Content(net.md_5.bungee.api.chat.hover.content.Content) EntityTag(com.denizenscript.denizen.objects.EntityTag) Text(net.md_5.bungee.api.chat.hover.content.Text) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 22 with Text

use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.

the class VoteCache method addVote.

public void addVote(String server, int num, OfflineBungeeVote voteData) {
    Configuration section = getData().getSection("VoteCache." + server + "." + num);
    section.set("Name", voteData.getPlayerName());
    section.set("Service", voteData.getService());
    section.set("UUID", voteData.getUuid());
    section.set("Time", voteData.getTime());
    section.set("Real", voteData.isRealVote());
    section.set("Text", voteData.getText());
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration)

Example 23 with Text

use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.

the class VoteCache method addVoteOnline.

public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
    Configuration section = getData().getSection("OnlineCache." + player + "." + num);
    section.set("Name", voteData.getPlayerName());
    section.set("Service", voteData.getService());
    section.set("UUID", voteData.getUuid());
    section.set("Time", voteData.getTime());
    section.set("Real", voteData.isRealVote());
    section.set("Text", voteData.getText());
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration)

Example 24 with Text

use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.

the class AdminVoteHelp method adminHelpText.

/**
 * Admin help text.
 *
 * @param sender the sender
 * @return the array list
 */
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
    ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
    HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
    boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
    for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
        if (!requirePerms || cmdHandle.hasPerm(sender)) {
            unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
        }
    }
    ArrayList<String> unsortedList = new ArrayList<String>();
    unsortedList.addAll(unsorted.keySet());
    Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
    for (String cmd : unsortedList) {
        msg.add(unsorted.get(cmd));
    }
    return msg;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandHandler(com.bencodez.advancedcore.api.command.CommandHandler)

Example 25 with Text

use of net.md_5.bungee.api.chat.hover.content.Text in project solinia3-core by mixxit.

the class PlayerUtils method sendCharCreationNoMod.

private static void sendCharCreationNoMod(Player sender) {
    ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
    BookMeta bookMeta = (BookMeta) book.getItemMeta();
    bookMeta.setTitle("Creation");
    bookMeta.setAuthor("Server");
    try {
        CharacterCreation choices = StateManager.getInstance().getConfigurationManager().getCharacterCreationChoices();
        String pageText = "";
        BaseComponent[] introPage = new ComponentBuilder(ChatColor.RED + "Race/Class Selection\n" + ChatColor.RESET + "---------------\n" + "\n" + "Please cycle through\n" + "our choice of races\n" + "and classes\n" + "\n" + "When you are ready \n" + "click " + ChatColor.BLUE + "SELECT" + ChatColor.RESET + " on the page\n").create();
        bookMeta.spigot().addPage(introPage);
        for (String choiceKey : choices.raceChoices.keySet()) {
            RaceChoice choice = choices.raceChoices.get(choiceKey);
            int passiveId = StateManager.getInstance().getConfigurationManager().getRace(choice.RaceId).getPassiveAbilityId();
            ISoliniaSpell passiveSpell = StateManager.getInstance().getConfigurationManager().getSpell(passiveId);
            String header = ChatColor.RED + "" + choice.RaceName + " " + choice.ClassName + ChatColor.RESET + "\n";
            String hover = "[" + ChatColor.RED + "Hover for More Info" + ChatColor.RESET + "]\n";
            String text = "";
            text += "\n";
            text += "STR " + ChatColor.BLUE + choice.STR + ChatColor.RESET + " STA " + ChatColor.BLUE + choice.STA + ChatColor.RESET + " AGI " + ChatColor.BLUE + choice.AGI + ChatColor.RESET + "\n";
            text += "DEX " + ChatColor.BLUE + choice.DEX + ChatColor.RESET + " INT " + ChatColor.BLUE + choice.INT + ChatColor.RESET + " WIS " + ChatColor.BLUE + choice.WIS + ChatColor.RESET + "\n";
            text += "CHA " + ChatColor.BLUE + choice.CHA + ChatColor.RESET + "\n";
            text += "\n";
            text += "Racial Benefit: " + ChatColor.RED + passiveSpell.getName() + ChatColor.RESET + "\n";
            text += "\n";
            String details = ChatColor.GOLD + choice.RaceName + ChatColor.RESET + System.lineSeparator() + "Recommended Alignment: " + ChatColor.GOLD + choice.Alignment + ChatColor.RESET + System.lineSeparator() + choice.RaceDescription + System.lineSeparator() + ChatColor.GOLD + choice.ClassName + ChatColor.RESET + System.lineSeparator() + choice.ClassDescription;
            String click = "\n[" + ChatColor.BLUE + "SELECT" + ChatColor.RESET + "]\n";
            BaseComponent[] racePage = new ComponentBuilder(header).append(new ComponentBuilder(hover).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create())).create()).append(new ComponentBuilder(text).create()).append(new ComponentBuilder(click).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/createcharactershort " + choice.RaceId + " " + choice.ClassId)).create()).create();
            // 
            // )
            bookMeta.spigot().addPage(racePage);
        }
        /*			        .event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://spigotmc.org"))
			        .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Go to the spigot website!").create()))
			        .create();*/
        book.setItemMeta(bookMeta);
        sender.openBook(book);
    } catch (CoreStateInitException e) {
    }
}
Also used : HoverEvent(net.md_5.bungee.api.chat.HoverEvent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) PacketOpenCharacterCreation(com.solinia.solinia.Models.PacketOpenCharacterCreation) CharacterCreation(com.solinia.solinia.Models.CharacterCreation) RaceChoice(com.solinia.solinia.Models.RaceChoice) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) BookMeta(org.bukkit.inventory.meta.BookMeta) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)13 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)10 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)10 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)4 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)4 DataValueString (com.bencodez.advancedcore.api.user.usercache.value.DataValueString)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)3 Text (net.md_5.bungee.api.chat.hover.content.Text)3 CommandHandler (com.Ben12345rocks.AdvancedCore.Objects.CommandHandler)2 FormatScriptContainer (com.denizenscript.denizen.scripts.containers.core.FormatScriptContainer)2 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)2 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)2 SQLException (java.sql.SQLException)2 List (java.util.List)2 UUID (java.util.UUID)2 ChatColor (net.md_5.bungee.api.ChatColor)2 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)2 Configuration (net.md_5.bungee.config.Configuration)2