use of net.md_5.bungee.protocol.packet.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;
}
use of net.md_5.bungee.protocol.packet.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);
}
use of net.md_5.bungee.protocol.packet.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);
}
}
use of net.md_5.bungee.protocol.packet.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;
}
use of net.md_5.bungee.protocol.packet.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);
}
}
Aggregations