Search in sources :

Example 61 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project EliteMobs by MagmaGuy.

the class StatsPage method statsPage.

protected static TextComponent statsPage(Player targetPlayer) {
    TextComponent textComponent = new TextComponent();
    for (int i = 0; i < 13; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getStatsTextLines()[i].replace("$money", EconomyHandler.checkCurrency(targetPlayer.getUniqueId()) + "").replace("$guildtier", PlayerStatusScreen.convertLightColorsToBlack(AdventurersGuildConfig.getShortenedRankName(GuildRank.getGuildPrestigeRank(targetPlayer), GuildRank.getActiveGuildRank(targetPlayer)))).replace("$kills", PlayerData.getKills(targetPlayer.getUniqueId()) + "").replace("$highestkill", PlayerData.getHighestLevelKilled(targetPlayer.getUniqueId()) + "").replace("$deaths", PlayerData.getDeaths(targetPlayer.getUniqueId()) + "").replace("$quests", PlayerData.getQuestsCompleted(targetPlayer.getUniqueId()) + "").replace("$score", PlayerData.getScore(targetPlayer.getUniqueId()) + "") + "\n");
        if (!PlayerStatusMenuConfig.getStatsHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getStatsHoverLines()[i]);
        if (!PlayerStatusMenuConfig.getStatsCommandLines()[i].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getStatsCommandLines()[i]));
        textComponent.addExtra(line);
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent)

Example 62 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project EliteMobs by MagmaGuy.

the class CommandsPage method commandsPage.

protected static TextComponent commandsPage() {
    TextComponent textComponent = new TextComponent();
    for (int i = 0; i < 13; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getCommandsTextLines()[i] + "\n");
        if (!PlayerStatusMenuConfig.getCommandsHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getCommandsHoverLines()[i]);
        if (!PlayerStatusMenuConfig.getCommandsCommandLines()[i].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getCommandsCommandLines()[i]));
        textComponent.addExtra(line);
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent)

Example 63 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project EliteMobs by MagmaGuy.

the class GearPage method gearPage.

protected static TextComponent gearPage(Player targetPlayer) {
    TextComponent textComponent = new TextComponent();
    for (int i = 0; i < 13; i++) {
        TextComponent line;
        if (!PlayerStatusMenuConfig.getGearTextLines()[i].contains("{")) {
            line = new TextComponent(parseGearPlaceholders(PlayerStatusMenuConfig.getGearTextLines()[i], targetPlayer) + "\n");
            gearMultiComponentLine(textComponent, line, i, targetPlayer, false, 0);
        } else {
            TextComponent prePlaceholderElements = new TextComponent(parseGearPlaceholders(PlayerStatusMenuConfig.getGearTextLines()[i].split("\\{")[0], targetPlayer));
            gearMultiComponentLine(textComponent, prePlaceholderElements, i, targetPlayer, false, 0);
            for (int j = 0; j < PlayerStatusMenuConfig.getGearTextLines()[i].split("\\{").length; j++) {
                TextComponent placeholderString = new TextComponent(parseGearPlaceholders(PlayerStatusMenuConfig.getGearTextLines()[i].split("\\{")[j].split("}")[0], targetPlayer));
                gearMultiComponentLine(textComponent, placeholderString, i, targetPlayer, true, j);
                if (PlayerStatusMenuConfig.getGearTextLines()[i].split("}").length > j && PlayerStatusMenuConfig.getGearTextLines()[i].split("}")[j].contains("{")) {
                    TextComponent spaceBetweenPlaceholders = new TextComponent(parseGearPlaceholders(PlayerStatusMenuConfig.getGearTextLines()[i].split("}")[j].split("\\{")[0], targetPlayer));
                    gearMultiComponentLine(textComponent, spaceBetweenPlaceholders, i, targetPlayer, false, 0);
                }
            }
            TextComponent spaceAfterPlaceholders = new TextComponent("\n");
            gearMultiComponentLine(textComponent, spaceAfterPlaceholders, i, targetPlayer, false, 0);
        }
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent)

Example 64 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project EliteMobs by MagmaGuy.

the class BookMaker method generateBook.

public static ItemStack generateBook(Player player, TextComponent[] pages) {
    ItemStack writtenBook = new ItemStack(Material.WRITTEN_BOOK);
    BookMeta bookMeta = (BookMeta) writtenBook.getItemMeta();
    bookMeta.setTitle("EliteMobs Book");
    bookMeta.setAuthor("MagmaGuy");
    /*
        for some reason the spigot api isn't respecting the whole 1 page per array element, so this converts it to a
        format that actually works
         */
    for (TextComponent textComponent : pages) {
        TextComponent[] stupid = new TextComponent[1];
        stupid[0] = textComponent;
        bookMeta.spigot().addPage(stupid);
    }
    writtenBook.setItemMeta(bookMeta);
    player.openBook(writtenBook);
    return writtenBook;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ItemStack(org.bukkit.inventory.ItemStack) BookMeta(org.bukkit.inventory.meta.BookMeta)

Example 65 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project EliteMobs by MagmaGuy.

the class DebugScreen method generateEntry.

private static TextComponent generateEntry(CustomBossEntity customBossEntity, String argument, Player player) {
    if (!customBossEntity.getCustomBossesConfigFields().getFilename().contains(argument) && !customBossEntity.getCustomBossesConfigFields().getName().toLowerCase().contains(argument.toLowerCase()))
        return null;
    TextComponent page = new TextComponent();
    page.addExtra(customBossEntity.getCustomBossesConfigFields().getFilename() + "\n");
    page.addExtra("Name: " + ChatColorConverter.convert(customBossEntity.getCustomBossesConfigFields().getName()) + ChatColor.BLACK + "\n");
    page.addExtra("Level: " + customBossEntity.getCustomBossesConfigFields().getLevel() + "\n");
    if (customBossEntity.getLivingEntity() != null) {
        page.addExtra("Is Alive (MC): " + !customBossEntity.getLivingEntity().isDead() + "\n");
        page.addExtra(SpigotMessage.commandHoverMessage(ChatColor.BLUE + "XYZ: " + "\n", customBossEntity.getLocation().getBlockX() + ", " + customBossEntity.getLocation().getBlockY() + ", " + customBossEntity.getLocation().getBlockZ() + "\n" + ChatColor.BLUE + "Click to teleport! (if alive)", "/em debugtp " + customBossEntity.getEliteUUID().toString()));
        page.addExtra("Has AI: " + !customBossEntity.getLivingEntity().hasAI() + "\n");
    } else
        page.addExtra("Is Alive (MC): false\n");
    if (customBossEntity.getLocation() != null && player.getWorld().equals(customBossEntity.getLocation().getWorld()))
        page.addExtra(SpigotMessage.hoverMessage(ChatColor.BLUE + "Spawn distance", "Spawn distance: X=" + (int) (player.getLocation().getX() - customBossEntity.getSpawnLocation().getX()) + " | Y=" + (int) (player.getLocation().getY() - customBossEntity.getSpawnLocation().getY()) + " | Z=" + (int) (player.getLocation().getZ() - customBossEntity.getSpawnLocation().getZ()) + "\n"));
    page.addExtra("Is Persistent: " + customBossEntity.getCustomBossesConfigFields().isPersistent() + "\n");
    if (customBossEntity instanceof RegionalBossEntity) {
        page.addExtra("Is Respawning: " + ((RegionalBossEntity) customBossEntity).isRespawning() + "\n");
    }
    page.addExtra(SpigotMessage.commandHoverMessage(ChatColor.BLUE + "Boss trace!", "Remember, it requires debug mode to be on! This is used for advanced debugging, ask on discord if you want to know more about it.", "/elitemobs trace " + customBossEntity.getEliteUUID().toString()));
    return page;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)78 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)21 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)15 Player (org.bukkit.entity.Player)14 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)12 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)12 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)12 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)11 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)6 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)6 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)5 ChatColor (net.md_5.bungee.api.ChatColor)5 ItemStack (org.bukkit.inventory.ItemStack)5 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)4 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)4 DecimalFormat (java.text.DecimalFormat)4 HashMap (java.util.HashMap)4