Search in sources :

Example 1 with BaseComponent

use of net.md_5.bungee.api.chat.BaseComponent in project HolographicMenus by DRE2N.

the class HPlayer method sendPendingCommandMessage.

public void sendPendingCommandMessage() {
    String msg = clickedButton != null ? clickedButton.getVariableMessage(currentlyReplacedVariable) : HMessage.PENDING_ENTER_COMMAND_VARIABLE.getMessage(String.valueOf(currentlyReplacedVariable));
    MessageUtil.sendMessage(player, msg);
    if (CompatibilityHandler.getInstance().isSpigot()) {
        BaseComponent[] comps = TextComponent.fromLegacyText(HMessage.PENDING_CANCEL.getMessage());
        for (BaseComponent comp : comps) {
            comp.setClickEvent(new ClickEvent(Action.RUN_COMMAND, "/holographicmenus cancelInput"));
        }
        MessageUtil.sendMessage(player, comps);
    } else {
        MessageUtil.sendMessage(player, HMessage.PENDING_CANCEL_NO_SPIGOT.getMessage());
    }
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent)

Example 2 with BaseComponent

use of net.md_5.bungee.api.chat.BaseComponent in project Arcade2 by ShootGame.

the class MatchGame method onGameOverScreenRender.

/*
     * Don't use MatchEndEvent, because it is called before the players
     * are reset. The reset method would reset their titles.
     */
@Handler(priority = Priority.LAST)
public void onGameOverScreenRender(MatchEndedEvent event) {
    BaseComponent[] defaultComponent = TextComponent.fromLegacyText(ChatColor.AQUA + ChatColor.UNDERLINE.toString() + "Game over!");
    BaseComponent[] winnerComponent = TextComponent.fromLegacyText(ChatColor.GOLD + ChatColor.UNDERLINE.toString() + "Victory!");
    BaseComponent[] loserComponent = TextComponent.fromLegacyText(ChatColor.RED + ChatColor.UNDERLINE.toString() + "Defeat!");
    MatchWinner winner = event.getWinner();
    BaseComponent[] resultComponent;
    if (winner != null) {
        resultComponent = TextComponent.fromLegacyText(winner.getMessage());
    } else {
        // empty
        resultComponent = TextComponent.fromLegacyText("");
    }
    int fadeIn = (int) Time.ofTicks(10).toTicks();
    int stay = (int) Time.ofSeconds(3).toTicks();
    int fadeOut = (int) Time.ofTicks(30).toTicks();
    boolean isDrawWinner = winner instanceof DrawMatchWinner;
    for (ArcadePlayer online : event.getPlugin().getPlayers()) {
        if (online.getGamePlayer() == null) {
            continue;
        }
        BaseComponent[] title;
        ArcadeSound sound;
        if (winner == null || this.getObservers().contains(online)) {
            title = defaultComponent;
            sound = ArcadeSound.ENEMY_LOST;
        } else if (isDrawWinner || winner.contains(online)) {
            title = winnerComponent;
            sound = ArcadeSound.ENEMY_LOST;
        } else {
            title = loserComponent;
            sound = ArcadeSound.ENEMY_WON;
        }
        online.getBukkit().showTitle(title, resultComponent, fadeIn, stay, fadeOut);
        online.play(sound);
    }
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ArcadeSound(pl.themolka.arcade.session.ArcadeSound) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) Handler(net.engio.mbassy.listener.Handler)

Example 3 with BaseComponent

use of net.md_5.bungee.api.chat.BaseComponent in project Arcade2 by ShootGame.

the class PlayerTitleParser method parseTree.

@Override
protected ParserResult<PlayerTitle> parseTree(Node node, String name) throws ParserException {
    BaseComponent primary = this.primaryParser.parse(node.firstChild("title", "primary")).orDefaultNull();
    BaseComponent secondary = this.seconaryParser.parse(node.firstChild("subtitle", "sub-title", "secondary")).orDefaultNull();
    if (primary == null && secondary == null) {
        return ParserResult.empty(node, "Missing <title> or <subtitle>");
    }
    PlayerTitle title = new PlayerTitle(primary != null ? primary : empty, secondary != null ? secondary : empty);
    Time fadeIn = this.fadeInParser.parse(node.property("fade-in", "fadein")).orDefaultNull();
    if (fadeIn != null) {
        title.setFadeIn(fadeIn);
    }
    Time viewTime = this.viewTimeParser.parse(node.property("view-time", "viewtime", "time", "timeout")).orDefaultNull();
    if (viewTime != null) {
        title.setViewTime(viewTime);
    }
    Time fadeOut = this.fadeOutParser.parse(node.property("fade-out", "fadeout")).orDefaultNull();
    if (fadeOut != null) {
        title.setFadeOut(fadeOut);
    }
    return ParserResult.fine(node, name, title);
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) Time(pl.themolka.arcade.time.Time)

Example 4 with BaseComponent

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

the class PlayerInteractEntity method onPlayerInteractEntityEvent.

@EventHandler
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    if (event.isCancelled()) {
        return;
    }
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    Entity entity = event.getRightClicked();
    final UPlayer player = new UPlayer(event);
    if (entity instanceof ArmorStand && player.getGameMode() != GameMode.CREATIVE) {
        event.setCancelled(true);
    }
    if (entity instanceof Player && player.isSneaking()) {
        UPlayer target = new UPlayer(entity);
        BaseComponent[] stats = new ComponentBuilder("View statistics").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to open website").color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://ublisk.robinmc.com/stats/player.php?player=" + target.getName())).create();
        BaseComponent[] addAsFriend = new ComponentBuilder("Add as friend").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to run /friend add " + target.getName()).color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend add " + target.getName())).create();
        BaseComponent[] inviteToGuild = new ComponentBuilder("Invite to guild").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to run /guild invite " + target.getName()).color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/guild invite " + target.getName())).create();
        player.sendSpacers(2);
        player.sendMessage(stats);
        player.sendMessage(addAsFriend);
        player.sendMessage(inviteToGuild);
    }
}
Also used : Entity(org.bukkit.entity.Entity) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Player(org.bukkit.entity.Player) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) UPlayer(xyz.derkades.ublisk.utils.UPlayer) ArmorStand(org.bukkit.entity.ArmorStand) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) EventHandler(org.bukkit.event.EventHandler)

Example 5 with BaseComponent

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

the class Guild method invitePlayer.

public synchronized void invitePlayer(final UPlayer source, final UPlayer target) {
    if (!this.exists())
        throw new UnsupportedOperationException("Cannot invite player to non-existent guild.");
    final GuildInvite invite = new GuildInvite(this, source);
    // Add invite to list of invites, and remove it after 60 seconds (if it hasn't been accepted)
    GUILD_INVITES.put(target.getName(), invite);
    new BukkitRunnable() {

        public void run() {
            if (GUILD_INVITES.containsKey(target.getName())) {
                GUILD_INVITES.remove(target.getName());
            }
        }
    }.runTaskLater(Main.getInstance(), 60 * 20);
    TextComponent inviteMessage = new TextComponent(source.getName() + " has invited you to join " + this.getName() + ". ");
    inviteMessage.setColor(ChatColor.DARK_AQUA);
    inviteMessage.setBold(true);
    BaseComponent[] hoverText = new ComponentBuilder("Click me!").color(ChatColor.YELLOW).create();
    TextComponent clickToAccept = new TextComponent("Click here to accept.");
    clickToAccept.setColor(ChatColor.AQUA);
    clickToAccept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText));
    clickToAccept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/guild accept"));
    BaseComponent[] components = new BaseComponent[] { inviteMessage, clickToAccept };
    target.sendMessage(components);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Aggregations

BaseComponent (net.md_5.bungee.api.chat.BaseComponent)23 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)7 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)6 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)5 Player (org.bukkit.entity.Player)4 BookMeta (org.bukkit.inventory.meta.BookMeta)4 UPlayer (xyz.derkades.ublisk.utils.UPlayer)4 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)3 ListTag (com.denizenscript.denizencore.objects.core.ListTag)3 ChatColor (net.md_5.bungee.api.ChatColor)3 MapTag (com.denizenscript.denizencore.objects.core.MapTag)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ListTag (net.minecraft.nbt.ListTag)2 EventHandler (org.bukkit.event.EventHandler)2 PlayerNotFoundException (xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)2 MinigamesBroadcastEvent (au.com.mineauz.minigames.events.MinigamesBroadcastEvent)1 EntityTag (com.denizenscript.denizen.objects.EntityTag)1 ItemTag (com.denizenscript.denizen.objects.ItemTag)1