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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations