Search in sources :

Example 1 with Title

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

the class CommandSetTitle method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (args.length == 0) {
                player.sendMessage("Available titles:");
                for (String title : solplayer.getAvailableTitles()) {
                    TextComponent tc = new TextComponent();
                    tc.setText("- " + title);
                    TextComponent tc2 = new TextComponent();
                    tc2.setText(ChatColor.GRAY + "Click here to set this title" + ChatColor.RESET);
                    tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/settitle " + title));
                    tc.addExtra(tc2);
                    sender.spigot().sendMessage(tc);
                }
                player.sendMessage("/settitle none to remove your current title");
                return true;
            }
            String targetTitle = args[0];
            if (args.length > 0) {
                targetTitle = "";
                int current = 0;
                for (String entry : args) {
                    current++;
                    targetTitle = targetTitle + entry + " ";
                }
                targetTitle = targetTitle.trim();
            }
            if (!targetTitle.equals("none")) {
                boolean found = false;
                for (String title : solplayer.getAvailableTitles()) {
                    if (targetTitle.toUpperCase().equals(title.toUpperCase())) {
                        targetTitle = title;
                        found = true;
                        break;
                    }
                }
                if (found == false) {
                    player.sendMessage("You do not have this title");
                    return true;
                }
                solplayer.setTitle(targetTitle);
            } else {
                solplayer.setTitle("");
            }
            System.out.println("* [" + player.getName() + "] Title set to: " + "'" + solplayer.getTitle() + "'");
            player.sendMessage("* Title set to: '" + solplayer.getTitle() + "'");
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 2 with Title

use of net.md_5.bungee.api.Title in project Bukkit_Bungee_PluginLib by GeorgH93.

the class TitleSender method send.

/**
 * Sends a JSON message to a player shown as title.
 *
 * @param player   The player that should receive the message
 * @param json     The message in JSON format to be sent
 * @param metadata The metadata object giving more details on how the message should be displayed
 */
public static void send(@NotNull ProxiedPlayer player, @NotNull String json, @NotNull TitleMetadata metadata) {
    Title titleTimes = new Title(), titleSend = new Title();
    titleTimes.setAction(Title.Action.TIMES);
    titleTimes.setFadeIn(metadata.getFadeIn());
    titleTimes.setStay(metadata.getStay());
    titleTimes.setFadeOut(metadata.getFadeOut());
    titleSend.setAction(metadata.getTitleType());
    titleSend.setText(json);
    player.unsafe().sendPacket(titleTimes);
    player.unsafe().sendPacket(titleSend);
}
Also used : Title(net.md_5.bungee.protocol.packet.Title)

Example 3 with Title

use of net.md_5.bungee.api.Title in project Bukkit_Bungee_PluginLib by GeorgH93.

the class TitleSender method send.

/**
 * Sends a JSON message to players shown as title.
 *
 * @param players  The player that should receive the message
 * @param json     The message in JSON format to be sent
 * @param metadata The metadata object giving more details on how the message should be displayed
 */
public static void send(@NotNull Collection<? extends ProxiedPlayer> players, @NotNull String json, @NotNull TitleMetadata metadata) {
    Title titleTimes = new Title(), titleSend = new Title();
    titleTimes.setAction(Title.Action.TIMES);
    titleTimes.setFadeIn(metadata.getFadeIn());
    titleTimes.setStay(metadata.getStay());
    titleTimes.setFadeOut(metadata.getFadeOut());
    titleSend.setAction(metadata.getTitleType());
    titleSend.setText(json);
    for (ProxiedPlayer player : players) {
        player.unsafe().sendPacket(titleTimes);
        player.unsafe().sendPacket(titleSend);
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Title(net.md_5.bungee.protocol.packet.Title)

Example 4 with Title

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

the class FireAuth method getRegisterTitle.

public Title getRegisterTitle() {
    Title title = this.main.getProxy().createTitle();
    title.title(new TextComponent("§cVous devez vous inscrire !"));
    title.subTitle(new TextComponent("§c/register <motdepasse> <motdepasse>"));
    return title;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Title(net.md_5.bungee.api.Title)

Example 5 with Title

use of net.md_5.bungee.api.Title 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)

Aggregations

TextComponent (net.md_5.bungee.api.chat.TextComponent)3 Title (net.md_5.bungee.api.Title)2 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)2 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)2 Title (net.md_5.bungee.protocol.packet.Title)2 Player (org.bukkit.entity.Player)2 Landlord (biz.princeps.landlord.Landlord)1 Options (biz.princeps.landlord.api.Options)1 LLFlag (biz.princeps.landlord.flags.LLFlag)1 LangManager (biz.princeps.landlord.manager.LangManager)1 LPlayer (biz.princeps.landlord.persistent.LPlayer)1 OwnedLand (biz.princeps.landlord.util.OwnedLand)1 ConfirmationGUI (biz.princeps.lib.gui.ConfirmationGUI)1 MultiPagedGUI (biz.princeps.lib.gui.MultiPagedGUI)1 AbstractGUI (biz.princeps.lib.gui.simple.AbstractGUI)1 Icon (biz.princeps.lib.gui.simple.Icon)1 Conditions (biz.princeps.lib.storage.requests.Conditions)1 DefaultFlag (com.sk89q.worldguard.protection.flags.DefaultFlag)1 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)1