use of net.md_5.bungee.api.chat.ClickEvent in project Ublisk by Derkades.
the class StatsCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
UPlayer player = new UPlayer(sender);
if (args.length == 1) {
UPlayer target = null;
try {
target = new UPlayer(args[1]);
} catch (PlayerNotFoundException e) {
player.sendMessage(Message.PLAYER_NOT_FOUND);
return true;
}
BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
BaseComponent[] text = new ComponentBuilder("Click here to open " + target.getName() + "'s statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, target.getStatsURL())).create();
player.sendMessage(text);
return true;
} else if (args.length == 0) {
BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
BaseComponent[] text = new ComponentBuilder("Click here to open your statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, player.getStatsURL())).create();
player.sendMessage(text);
return true;
} else {
return false;
}
}
use of net.md_5.bungee.api.chat.ClickEvent 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);
}
use of net.md_5.bungee.api.chat.ClickEvent in project LandLord by SpatiumPrinceps.
the class Claims method onClaims.
public void onClaims(Player player) {
if (plugin.getConfig().getBoolean("Shop.enable")) {
int claimcount = plugin.getPlayerManager().get(player.getUniqueId()).getClaims();
int regionCount = plugin.getWgHandler().getWG().getRegionManager(player.getWorld()).getRegionCountOfPlayer(plugin.getWgHandler().getWG().wrapPlayer(player));
String message = lm.getString("Commands.Claims.message");
String noClaims = lm.getString("Commands.Claims.noClaims");
if (claimcount > 0) {
player.sendMessage(message.replace("%regions%", regionCount + "").replace("%claims%", claimcount + ""));
} else {
BaseComponent text = new TextComponent(noClaims);
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ll shop"));
player.spigot().sendMessage(text);
}
} else {
player.sendMessage(lm.getString("Commands.Claims.disabled"));
}
}
use of net.md_5.bungee.api.chat.ClickEvent in project Minigames by AddstarMC.
the class MessageManager method sendClickedCommandMessage.
public static void sendClickedCommandMessage(CommandSender target, String command, String identifier, String key, Object... args) {
BaseComponent init = getMessageStart(MinigameMessageType.INFO);
TextComponent message = new TextComponent(getMessage(identifier, key, args));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
sendMessage(target, init, message);
}
use of net.md_5.bungee.api.chat.ClickEvent in project Denizen-For-Bukkit by DenizenScript.
the class FormattedTextHelper method stringify.
public static String stringify(BaseComponent component) {
if (component == null) {
return null;
}
StringBuilder builder = new StringBuilder(128);
ChatColor color = component.getColorRaw();
if (color != null) {
builder.append(color);
}
if (boolNotNull(component.isBoldRaw())) {
builder.append(ChatColor.BOLD);
}
if (boolNotNull(component.isItalicRaw())) {
builder.append(ChatColor.ITALIC);
}
if (boolNotNull(component.isStrikethroughRaw())) {
builder.append(ChatColor.STRIKETHROUGH);
}
if (boolNotNull(component.isUnderlinedRaw())) {
builder.append(ChatColor.UNDERLINE);
}
if (boolNotNull(component.isObfuscatedRaw())) {
builder.append(ChatColor.MAGIC);
}
if (component.getFontRaw() != null) {
builder.append(ChatColor.COLOR_CHAR).append("[font=").append(component.getFontRaw()).append("]");
}
boolean hasInsertion = component.getInsertion() != null;
if (hasInsertion) {
builder.append(ChatColor.COLOR_CHAR).append("[insertion=").append(escape(component.getInsertion())).append("]");
}
boolean hasHover = component.getHoverEvent() != null;
if (hasHover) {
HoverEvent hover = component.getHoverEvent();
builder.append(ChatColor.COLOR_CHAR).append("[hover=").append(hover.getAction().name()).append(";").append(escape(NMSHandler.getInstance().stringForHover(hover))).append("]");
}
boolean hasClick = component.getClickEvent() != null;
if (hasClick) {
ClickEvent click = component.getClickEvent();
builder.append(ChatColor.COLOR_CHAR).append("[click=").append(click.getAction().name()).append(";").append(escape(click.getValue())).append("]");
}
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).getText());
} else if (component instanceof TranslatableComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[translate=").append(escape(((TranslatableComponent) component).getTranslate()));
List<BaseComponent> with = ((TranslatableComponent) component).getWith();
if (with != null) {
for (BaseComponent withComponent : with) {
builder.append(";").append(escape(stringify(withComponent)));
}
}
builder.append("]");
} else if (component instanceof SelectorComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[selector=").append(escape(((SelectorComponent) component).getSelector())).append("]");
} else if (component instanceof KeybindComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[keybind=").append(escape(((KeybindComponent) component).getKeybind())).append("]");
} else if (component instanceof ScoreComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[score=").append(escape(((ScoreComponent) component).getName())).append(";").append(escape(((ScoreComponent) component).getObjective())).append(";").append(escape(((ScoreComponent) component).getValue())).append("]");
}
List<BaseComponent> after = component.getExtra();
if (after != null) {
for (BaseComponent afterComponent : after) {
builder.append(stringify(afterComponent));
}
}
if (hasClick) {
builder.append(ChatColor.COLOR_CHAR + "[/click]");
}
if (hasHover) {
builder.append(ChatColor.COLOR_CHAR + "[/hover]");
}
if (hasInsertion) {
builder.append(ChatColor.COLOR_CHAR + "[/insertion]");
}
builder.append(RESET);
String output = builder.toString();
return cleanRedundantCodes(output);
}
Aggregations