Search in sources :

Example 1 with Chat

use of net.md_5.bungee.protocol.packet.Chat in project FireAPI by FireBlade-Serv.

the class StaffChatCommand method execute.

// ! = all en jeu
// : = staff chat
// @ = party chat
@Override
public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
        ProxiedPlayer pp = (ProxiedPlayer) sender;
        if (this.api.getRankSystem().hasRankAndSup(pp.getName(), Rank.GUIDE)) {
            if (this.players.containsKey(pp)) {
                pp.sendMessage(new TextComponent(this.pre + "§aBien, vous n'entendez plus les discutions du staff !"));
                this.players.remove(pp);
            } else {
                pp.sendMessage(new TextComponent(this.pre + "§aBien, vous entendez maintenant les discussions du staff !"));
                pp.sendMessage(new TextComponent(this.pre + "§oRappel : Utilisez ':' devant vos messages pour parler au reste du staff !"));
                this.players.put(pp, true);
            }
        } else {
            pp.sendMessage(new TextComponent(this.pre + "§cErreur vous n'avez pas la permission d'utiliser cette commande !"));
        }
    } else {
        if (this.consoleListen) {
            sender.sendMessage(new TextComponent(this.pre + "§aBien, vous n'entendez plus les discutions du staff !"));
            this.consoleListen = false;
        } else {
            sender.sendMessage(new TextComponent(this.pre + "§aBien, vous entendez maintenant les discussions du staff !"));
            this.consoleListen = true;
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer)

Example 2 with Chat

use of net.md_5.bungee.protocol.packet.Chat 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);
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Trigger(xyz.derkades.ublisk.chat.Trigger) ChatColor(net.md_5.bungee.api.ChatColor) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ChatColor (net.md_5.bungee.api.ChatColor)1 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1 EventHandler (org.bukkit.event.EventHandler)1 Trigger (xyz.derkades.ublisk.chat.Trigger)1 UPlayer (xyz.derkades.ublisk.utils.UPlayer)1