Search in sources :

Example 56 with TextComponent

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

the class Minidungeon method installSchematicMinidungeon.

private void installSchematicMinidungeon(Player player) {
    player.performCommand("schematic load " + dungeonPackagerConfigFields.getSchematicName());
    new BukkitRunnable() {

        @Override
        public void run() {
            for (int i = 0; i < 20; i++) player.sendMessage("");
            player.sendMessage(ChatColorConverter.convert("&2-------------------------------------------------"));
            player.sendMessage(ChatColorConverter.convert("&7[EliteMobs] &2Ready to install " + dungeonPackagerConfigFields.getDungeonSizeCategory().toString().toLowerCase() + "!"));
            TextComponent pasteString = new TextComponent(ChatColorConverter.convert("&aClick here to place the &lbuilding and bosses &awhere you're standing!"));
            pasteString.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/em setup minidungeon " + dungeonPackagerConfigFields.getFilename()));
            pasteString.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColorConverter.convert("&2Click me!"))));
            TextComponent noPasteString = new TextComponent(ChatColorConverter.convert("&4&lOr &4click here to &lonly set the bosses with no building&4!"));
            noPasteString.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/em setup minidungeonNoPaste " + dungeonPackagerConfigFields.getFilename()));
            noPasteString.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColorConverter.convert("&cOnly click if you're already standing at the bulding's anchor point!"))));
            player.spigot().sendMessage(pasteString);
            player.spigot().sendMessage(noPasteString);
            player.sendMessage(ChatColorConverter.convert("&2-------------------------------------------------"));
        }
    }.runTaskLater(MetadataHandler.PLUGIN, 20);
    initializeWormholeWorld();
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Text(net.md_5.bungee.api.chat.hover.content.Text)

Example 57 with TextComponent

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

the class Minidungeon method finalizeMinidungeonInstallation.

public void finalizeMinidungeonInstallation(Player player, boolean pastedSchematic) {
    dungeonPackagerConfigFields.setEnabled(true, player.getLocation());
    this.relativeBossLocations = new RelativeDungeonLocations(dungeonPackagerConfigFields.getRelativeBossLocations(), true);
    this.relativeTreasureChestLocations = new RelativeDungeonLocations(dungeonPackagerConfigFields.getRelativeTreasureChestLocations(), false);
    this.realDungeonLocations = new RealDungeonLocations();
    commitLocations();
    this.isInstalled = true;
    if (dungeonPackagerConfigFields.isProtect()) {
        Location realCorner1 = getRotatedFinalLocation(dungeonPackagerConfigFields.getAnchorPoint(), dungeonPackagerConfigFields.getCorner1());
        Location realCorner2 = getRotatedFinalLocation(dungeonPackagerConfigFields.getAnchorPoint(), dungeonPackagerConfigFields.getCorner2());
        WorldGuardCompatibility.defineMinidungeon(realCorner1, realCorner2, dungeonPackagerConfigFields.getAnchorPoint(), dungeonPackagerConfigFields.getSchematicName(), this);
    }
    teleportLocation = getRotatedFinalLocation(dungeonPackagerConfigFields.getAnchorPoint(), dungeonPackagerConfigFields.getTeleportPoint());
    for (int i = 0; i < 20; i++) player.sendMessage("");
    player.sendMessage(ChatColorConverter.convert("&2" + dungeonPackagerConfigFields.getName() + " installed!"));
    TextComponent setupOptions = new TextComponent(ChatColorConverter.convert("&4Click here to uninstall!"));
    if (pastedSchematic)
        setupOptions.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/em setup unminidungeon " + dungeonPackagerConfigFields.getFilename()));
    else
        setupOptions.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/em setup unminidungeonNoPaste " + dungeonPackagerConfigFields.getFilename()));
    player.spigot().sendMessage(setupOptions);
    quantifySchematicBosses(true);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) Location(org.bukkit.Location)

Example 58 with TextComponent

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

the class ShareItem method setItemHoverEvent.

public static void setItemHoverEvent(TextComponent textComponent, ItemStack itemStack) {
    if (!EliteMobsItemDetector.isEliteMobsItem(itemStack))
        return;
    String stringList = itemStack.getItemMeta().getDisplayName();
    if (itemStack.getItemMeta().hasLore())
        for (String loreString : itemStack.getItemMeta().getLore()) stringList += "\n" + ChatColor.DARK_PURPLE + ChatColor.ITALIC + loreString;
    textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(stringList).create()));
}
Also used : HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 59 with TextComponent

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

the class BossTrackingPage method bossTrackingPage.

protected static TextComponent[] bossTrackingPage(Player player) {
    TextComponent configTextComponent = new TextComponent();
    for (int i = 0; i < 3; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getBossTrackerTextLines()[i] + "\n");
        if (!PlayerStatusMenuConfig.getBossTrackerHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getBossTrackerHoverLines()[i]);
        if (!PlayerStatusMenuConfig.getBossTrackerCommandLines()[i].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getBossTrackerCommandLines()[i]));
        configTextComponent.addExtra(line);
    }
    ArrayList<TextComponent> textComponents = new ArrayList<>();
    int counter = 0;
    for (CustomBossEntity customBossEntity : CustomBossEntity.getTrackableCustomBosses()) {
        try {
            textComponents.add(SpigotMessage.commandHoverMessage(customBossEntity.getCustomBossBossBar().bossBarMessage(player, customBossEntity.getCustomBossesConfigFields().getLocationMessage()) + "\n", PlayerStatusMenuConfig.getOnBossTrackHover(), "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
            counter++;
        } catch (Exception ex) {
            new WarningMessage("Failed to correctly get elements for boss tracking page!");
            ex.printStackTrace();
        }
    }
    TextComponent[] textComponent;
    if (counter == 0) {
        textComponent = new TextComponent[1];
        textComponent[0] = configTextComponent;
    } else {
        textComponent = new TextComponent[(int) Math.floor(counter / 6D) + 1];
        int internalCounter = 0;
        textComponent[0] = configTextComponent;
        for (TextComponent text : textComponents) {
            int currentPage = (int) Math.floor(internalCounter / 6D);
            if (textComponent[currentPage] == null)
                textComponent[currentPage] = new TextComponent();
            textComponent[currentPage].addExtra(text);
            internalCounter++;
        }
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 60 with TextComponent

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

the class PlayerStatusScreen method generateBook.

private ItemStack generateBook(Player requestingPlayer, Player targetPlayer) {
    TextComponent[] pages = new TextComponent[50];
    int pageCounter = 1;
    pageCounter++;
    int statsPage = -1;
    int gearPage = -1;
    int teleportsPage = -1;
    int commandsPage = -1;
    int questsPage = -1;
    int bossTrackingPage = -1;
    if (PlayerStatusMenuConfig.isDoStatsPage()) {
        statsPage = pageCounter;
        pages[pageCounter] = StatsPage.statsPage(targetPlayer);
        pageCounter++;
    }
    if (PlayerStatusMenuConfig.isDoGearPage()) {
        gearPage = pageCounter;
        pages[pageCounter] = GearPage.gearPage(targetPlayer);
        pageCounter++;
    }
    if (PlayerStatusMenuConfig.isDoTeleportsPage()) {
        teleportsPage = pageCounter;
        for (TextComponent textComponent : TeleportsPage.teleportsPage()) {
            pages[pageCounter] = textComponent;
            pageCounter++;
        }
    }
    if (PlayerStatusMenuConfig.isDoCommandsPage()) {
        commandsPage = pageCounter;
        pages[pageCounter] = CommandsPage.commandsPage();
        pageCounter++;
    }
    if (PlayerStatusMenuConfig.isDoQuestTrackingPage()) {
        questsPage = pageCounter;
        for (TextComponent textComponent : QuestsPage.questsPage(targetPlayer)) {
            pages[pageCounter] = textComponent;
            pageCounter++;
        }
    }
    if (PlayerStatusMenuConfig.isDoBossTrackingPage()) {
        bossTrackingPage = pageCounter;
        for (TextComponent textComponent : BossTrackingPage.bossTrackingPage(targetPlayer)) {
            pages[pageCounter] = textComponent;
            pageCounter++;
        }
    }
    pages[0] = CoverPage.coverPage(statsPage, gearPage, teleportsPage, commandsPage, questsPage, bossTrackingPage);
    int counter = 0;
    for (TextComponent textComponent : pages) {
        if (textComponent != null)
            counter++;
    }
    TextComponent[] finalPages = new TextComponent[counter];
    int secondCounter = 0;
    for (TextComponent textComponent : pages) {
        if (textComponent != null) {
            finalPages[secondCounter] = textComponent;
            secondCounter++;
        }
    }
    return BookMaker.generateBook(requestingPlayer, finalPages);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent)

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