use of net.md_5.bungee.api.chat.BaseComponent 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.BaseComponent in project Ublisk by Derkades.
the class Chat method onChat.
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) {
// Don't send chat message, we'll send a custom message
event.setCancelled(true);
UPlayer player = new UPlayer(event);
if (Chat.IS_MUTED.get(player.getUniqueId())) {
player.sendMessage(Message.CANT_CHAT_MUTED);
event.setCancelled(true);
return;
}
for (Trigger trigger : Trigger.values()) {
if (event.getMessage().equals(trigger.getTrigger())) {
event.setMessage(trigger.getMessage());
}
}
ChatColor chatColor = ChatColor.WHITE;
if (IS_SOFT_MUTED.get(player.getUniqueId()))
chatColor = ChatColor.GRAY;
int level = player.getLevel();
BaseComponent[] message = new ComponentBuilder("").append("[").reset().color(ChatColor.DARK_GRAY).append(level + "").reset().color(ChatColor.GRAY).append("] ").reset().color(ChatColor.DARK_GRAY).append(player.getGroup().getName()).color(player.getGroup().getPrefixColor()).bold(player.getGroup().nameBold()).append(":").reset().color(ChatColor.DARK_GRAY).append(" ").create();
message = ArrayUtils.addAll(message, player.getDisplayName(player.getGroup().getNameColor(), player.getGroup().nameBold()));
message = ArrayUtils.addAll(message, new ComponentBuilder("").append(": ").reset().color(ChatColor.DARK_GRAY).bold(true).append(event.getMessage()).reset().color(chatColor).create());
Ublisk.getServer().spigot().broadcast(message);
}
use of net.md_5.bungee.api.chat.BaseComponent 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.BaseComponent in project Ublisk by Derkades.
the class V1_12_R1 method sendActionBarMessage.
@Override
public void sendActionBarMessage(Player player, String message) {
IChatBaseComponent dummyComponent = ChatSerializer.a("{\"text\":\"herobrine1337\"}");
PacketPlayOutChat packet = new PacketPlayOutChat(dummyComponent, ChatMessageType.GAME_INFO);
packet.components = new BaseComponent[] { new TextComponent(message) };
CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().playerConnection.sendPacket(packet);
}
use of net.md_5.bungee.api.chat.BaseComponent 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"));
}
}
Aggregations