use of xyz.derkades.ublisk.chat.Trigger 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);
}
Aggregations