Search in sources :

Example 16 with ClickEvent

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

the class TeleportsPage method teleportsPage.

protected static TextComponent[] teleportsPage() {
    TextComponent configTextComponent = new TextComponent();
    // Fills the non-dungeon lines
    int textLineCounter = 0;
    for (String string : PlayerStatusMenuConfig.getTeleportTextLines()) {
        if (string == null || string.equals("null"))
            continue;
        TextComponent line = new TextComponent(string + "\n");
        if (PlayerStatusMenuConfig.getTeleportHoverLines()[textLineCounter] != null && !PlayerStatusMenuConfig.getTeleportHoverLines()[textLineCounter].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getTeleportHoverLines()[textLineCounter]);
        if (PlayerStatusMenuConfig.getTeleportCommandLines()[textLineCounter] != null && !PlayerStatusMenuConfig.getTeleportCommandLines()[textLineCounter].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getTeleportCommandLines()[textLineCounter]));
        configTextComponent.addExtra(line);
        textLineCounter++;
    }
    // Fills the minidungeon components
    int counter = 0;
    ArrayList<TextComponent> textComponents = new ArrayList<>();
    for (Minidungeon minidungeon : Minidungeon.getMinidungeons().values()) {
        if (!minidungeon.isInstalled())
            continue;
        TextComponent message = new TextComponent(PlayerStatusScreen.convertLightColorsToBlack(minidungeon.getDungeonPackagerConfigFields().getName() + "\n"));
        String hoverMessage = ChatColorConverter.convert(PlayerStatusMenuConfig.getOnTeleportHover() + "\n" + minidungeon.getDungeonPackagerConfigFields().getPlayerInfo().replace("$bossCount", minidungeon.getRegionalBossCount() + "").replace("$lowestTier", minidungeon.getLowestTier() + "").replace("$highestTier", minidungeon.getHighestTier() + ""));
        message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverMessage).create()));
        message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/elitemobs dungeontp " + minidungeon.getDungeonPackagerConfigFields().getFilename()));
        textComponents.add(message);
        counter++;
    }
    if (counter == 0) {
        TextComponent[] textComponent = new TextComponent[1];
        textComponent[0] = configTextComponent;
        return textComponent;
    } else {
        TextComponent[] textComponent = new TextComponent[(int) Math.floor(counter / 9D) + 1];
        int internalCounter = 0;
        textComponent[0] = configTextComponent;
        for (TextComponent text : textComponents) {
            int currentPage = (int) Math.floor(internalCounter / 9D);
            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) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) Minidungeon(com.magmaguy.elitemobs.dungeons.Minidungeon) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 17 with ClickEvent

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

the class CoverPage method coverPage.

protected static TextComponent coverPage(int statsPage, int gearPage, int teleportsPage, int commandsPage, int questsPage, int bossTrackingPage) {
    TextComponent textComponent = new TextComponent();
    for (int i = 0; i < 13; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getIndexTextLines()[i].replace("$statsPage", statsPage + "").replace("$gearPage", gearPage + "").replace("$teleportsPage", teleportsPage + "").replace("$commandsPage", commandsPage + "").replace("$questsPage", questsPage + "").replace("$bossTrackingPage", bossTrackingPage + "") + "\n");
        if (!PlayerStatusMenuConfig.getIndexHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getIndexHoverLines()[i]);
        if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$statsPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$statsPage", statsPage + "")));
        else if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$gearPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$gearPage", gearPage + "")));
        else if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$teleportsPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$teleportsPage", teleportsPage + "")));
        else if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$commandsPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$commandsPage", commandsPage + "")));
        else if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$questsPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$questsPage", questsPage + "")));
        else if (PlayerStatusMenuConfig.getIndexCommandLines()[i].contains("$bossTrackingPage"))
            line.setClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, PlayerStatusMenuConfig.getIndexCommandLines()[i].replace("$bossTrackingPage", bossTrackingPage + "")));
        else
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getIndexCommandLines()[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 18 with ClickEvent

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

the class SpigotMessage method hoverLinkMessage.

public static TextComponent hoverLinkMessage(String message, String hoverMessage, String link) {
    TextComponent textComponent = hoverMessage(message, hoverMessage);
    textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent)

Example 19 with ClickEvent

use of net.md_5.bungee.api.chat.ClickEvent in project FireAPI by FireBlade-Serv.

the class FireFriends method sendFriendsMessageResquest.

public void sendFriendsMessageResquest(ProxiedPlayer pp, String name) {
    TextComponent accept = new TextComponent("§a§l✔ Accepter§r ");
    accept.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/amis accept " + name));
    accept.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aCliquez ici pour accepter sa demande").create()));
    TextComponent base = new TextComponent(this.pre + "§e" + name + "§r vous demande en ami ! ");
    base.addExtra(accept);
    pp.sendMessage(base);
}
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) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 20 with ClickEvent

use of net.md_5.bungee.api.chat.ClickEvent in project solinia3-core by mixxit.

the class SoliniaPlayer method setInteraction.

@Override
public void setInteraction(UUID interaction, ISoliniaNPC npc) {
    if (interaction == null) {
        this.interaction = interaction;
        this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are no longer interacting");
        return;
    }
    Entity e = Bukkit.getEntity(interaction);
    if (e == null)
        return;
    if (!(e instanceof LivingEntity))
        return;
    if (((Creature) e).getTarget() != null) {
        if (interaction != null) {
            this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are no longer interacting");
            interaction = null;
        }
        return;
    }
    if (Bukkit.getEntity(interaction) instanceof Wolf) {
        Wolf w = (Wolf) Bukkit.getEntity(interaction);
        if (w.getOwner() != null)
            return;
    }
    this.interaction = interaction;
    if (npc != null) {
        this.getBukkitPlayer().sendMessage(ChatColor.GRAY + "* You are now interacting with " + Bukkit.getEntity(interaction).getName() + " [" + npc.getId() + "] - Anything you type will be heared by the NPC and possibly responded to. Words in pink are trigger words you can type");
        if (npc.getMerchantid() > 0) {
            try {
                StateManager.getInstance().getEntityManager().getLivingEntity((LivingEntity) e).say("i have a [" + ChatColor.LIGHT_PURPLE + "SHOP" + ChatColor.AQUA + "] available if you are interested in buying or selling something", getBukkitPlayer());
            } catch (CoreStateInitException cse) {
            // 
            }
        }
        for (ISoliniaNPCEventHandler eventHandler : npc.getEventHandlers()) {
            if (!eventHandler.getInteractiontype().equals(InteractionType.ITEM))
                continue;
            // See if player has any items that are wanted
            int itemId = Integer.parseInt(eventHandler.getTriggerdata());
            if (itemId == 0)
                continue;
            if (Utils.getPlayerTotalCountOfItemId(getBukkitPlayer(), itemId) < 1)
                continue;
            try {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
                TextComponent tc = new TextComponent();
                tc.setText(ChatColor.YELLOW + "[QUEST] ");
                TextComponent tc2 = new TextComponent();
                tc2.setText(ChatColor.GRAY + "- Click here to give " + item.getDisplayname() + ChatColor.RESET);
                tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/npcgive " + itemId));
                tc.addExtra(tc2);
                getBukkitPlayer().spigot().sendMessage(tc);
            } catch (CoreStateInitException eNotInitialised) {
                continue;
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) TextComponent(net.md_5.bungee.api.chat.TextComponent) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) ISoliniaNPCEventHandler(com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) Wolf(org.bukkit.entity.Wolf)

Aggregations

ClickEvent (net.md_5.bungee.api.chat.ClickEvent)30 TextComponent (net.md_5.bungee.api.chat.TextComponent)21 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)15 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)10 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)7 Player (org.bukkit.entity.Player)7 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)4 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3 UPlayer (xyz.derkades.ublisk.utils.UPlayer)3 OwnedLand (biz.princeps.landlord.util.OwnedLand)2 ConfirmationGUI (biz.princeps.lib.gui.ConfirmationGUI)2 ArrayList (java.util.ArrayList)2 ChatColor (net.md_5.bungee.api.ChatColor)2 Material (org.bukkit.Material)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 World (org.bukkit.World)2 Landlord (biz.princeps.landlord.Landlord)1 Options (biz.princeps.landlord.api.Options)1 LandPostClaimEvent (biz.princeps.landlord.api.events.LandPostClaimEvent)1