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());
}
}
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);
}
}
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);
}
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);
}
}
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);
}
Aggregations