Search in sources :

Example 66 with TextComponent

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

the class CustomBossBossBar method sendLocation.

private void sendLocation() {
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (!player.getWorld().equals(customBossEntity.getLocation().getWorld()))
            continue;
        TextComponent interactiveMessage = new TextComponent(MobCombatSettingsConfig.getBossLocationMessage());
        interactiveMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
        interactiveMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(TranslationConfig.getTrackMessage().replace("$name", customBossEntity.getName())).create()));
        player.spigot().sendMessage(interactiveMessage);
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) Player(org.bukkit.entity.Player) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 67 with TextComponent

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

the class QuestInventoryMenu method generateInventoryQuestEntry.

public static void generateInventoryQuestEntry(Quest quest, Player player, NPCEntity npcEntity) {
    QuestMenu.QuestText questText = new QuestMenu.QuestText(quest, npcEntity, player);
    String title = "";
    if (questText.getHeader().getText() != null)
        title = questText.getHeader().getText();
    Inventory questInventory = Bukkit.createInventory(player, 27, title);
    int titleEntry = 4;
    List<Integer> loreEntries = new ArrayList<>(Arrays.asList(13, 14, 12, 15, 11, 16, 10, 17, 9));
    List<Integer> objectivesEntries = new ArrayList<>(Arrays.asList(21, 20, 19, 18));
    List<Integer> rewardEntries = new ArrayList<>(Arrays.asList(23, 24, 25));
    Material titleMaterial = Material.PAINTING;
    Material trackingMaterial = Material.TARGET;
    Material loreMaterial = Material.BOOK;
    Material objectivesMaterial = Material.ITEM_FRAME;
    Material rewardsMaterial = Material.GOLD_INGOT;
    Material acceptMaterial = Material.EMERALD;
    questInventory.setItem(titleEntry, generateItemStackEntry(questText.getHeader(), new TextComponent(), titleMaterial).get(0));
    if (quest instanceof CustomQuest && quest.isAccepted())
        questInventory.setItem(trackEntry, generateItemStackEntry(questText.getTrack(), new TextComponent(), trackingMaterial).get(0));
    questInventory.setItem(acceptEntry, generateItemStackEntry(questText.getAccept(), new TextComponent(), acceptMaterial).get(0));
    if (quest instanceof CustomQuest)
        fillItemSlotLists(questInventory, loreEntries, new TextComponent(" "), questText.getBody(), loreMaterial);
    fillItemSlotLists(questInventory, objectivesEntries, questText.getFixedSummary(), questText.getSummary(), objectivesMaterial);
    fillItemSlotLists(questInventory, rewardEntries, questText.getFixedRewards(), questText.getRewards(), rewardsMaterial);
    new QuestInventory(player, quest, questInventory, npcEntity);
    player.openInventory(questInventory);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) CustomQuest(com.magmaguy.elitemobs.quests.CustomQuest) Material(org.bukkit.Material) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Inventory(org.bukkit.inventory.Inventory)

Example 68 with TextComponent

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

the class QuestMenu method generateBookQuestEntries.

public static void generateBookQuestEntries(List<? extends Quest> quests, Player player, NPCEntity npcEntity) {
    List<TextComponent[]> textComponents = new ArrayList<>();
    int counter = 0;
    for (Quest quest : quests) {
        TextComponent[] iteratedTextComponent = QuestBookMenu.generateQuestEntry(quest, player, npcEntity);
        counter += iteratedTextComponent.length;
        textComponents.add(iteratedTextComponent);
    }
    TextComponent[] allQuests = new TextComponent[counter];
    int counter2 = 0;
    for (TextComponent[] textComponentsArray : textComponents) for (TextComponent textComponent : textComponentsArray) {
        allQuests[counter2] = textComponent;
        counter2++;
    }
    BookMaker.generateBook(player, allQuests);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ArrayList(java.util.ArrayList) CustomQuest(com.magmaguy.elitemobs.quests.CustomQuest) Quest(com.magmaguy.elitemobs.quests.Quest) DynamicQuest(com.magmaguy.elitemobs.quests.DynamicQuest)

Example 69 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project Ublisk by Derkades.

the class TownCommand method onCommand.

@Override
protected void onCommand(UPlayer player, String[] args) {
    List<BaseComponent> list = new ArrayList<BaseComponent>();
    for (Town town : Town.values()) {
        TextComponent component = new TextComponent(town.getName() + "   ");
        double x = town.getSpawnLocation().getX();
        double y = town.getSpawnLocation().getY();
        double z = town.getSpawnLocation().getZ();
        component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp @p " + x + " " + y + " " + z));
        list.add(component);
    }
    BaseComponent[] components = list.toArray(new BaseComponent[] {});
    player.sendMessage(components);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) Town(xyz.derkades.ublisk.Town) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList)

Example 70 with TextComponent

use of net.md_5.bungee.api.chat.TextComponent in project Ublisk by Derkades.

the class V1_12_R1 method sendActionBarMessage.

@Override
public void sendActionBarMessage(Player player, String message) {
    IChatBaseComponent dummyComponent = ChatSerializer.a("{\"text\":\"herobrine1337\"}");
    PacketPlayOutChat packet = new PacketPlayOutChat(dummyComponent, ChatMessageType.GAME_INFO);
    packet.components = new BaseComponent[] { new TextComponent(message) };
    CraftPlayer craftPlayer = (CraftPlayer) player;
    craftPlayer.getHandle().playerConnection.sendPacket(packet);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) PacketPlayOutChat(net.minecraft.server.v1_12_R1.PacketPlayOutChat) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)

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