@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) void playerChatMonitor(AsyncPlayerChatEvent event) { if (plugin.getIRCBot() == null) { return; } final String message = ChatColor.stripColor( replaceAllLiteral( event.getFormat(), "%2$s", replaceAll(event.getMessage(), '$', "\\\\$"))); ChatPlayer player = plugin.getPlayerManager().getPlayer(event.getPlayer().getName()); if (player.getTarget() instanceof Channel) { ((Channel) player.getTarget()).sendToIRC(message); } }
public void reply(String message) { if (reply == null) { return; } whisperTo(reply, message); ((ChatPlayer) reply).whisperFrom(this, message); }
@Override public void runCommand(CommandSender sender, List<String> args) { String name = args.remove(0); ChatPlayer player = plugin.getPlayerManager().getPlayer(name); if (player == null) { sender.sendMessage("The player '" + name + "' does not exist."); return; } if (args.size() == 0) { player.setSuffix(null); sender.sendMessage(player.getName() + "'s suffix has been reset."); return; } StringBuilder suffix = new StringBuilder(args.remove(0)); for (String arg : args) { suffix.append(" ").append(arg); } player.setSuffix(suffix.toString()); sender.sendMessage(player.getName() + "'s suffix has been set to '" + suffix + "'"); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) void playerChatLowest(AsyncPlayerChatEvent event) { ChatPlayer player = plugin.getPlayerManager().getPlayer(event.getPlayer().getName()); if (player == null) { return; } // player object was null if (player.isMuted()) { player.sendMessage(ChatColor.RED + "You are muted."); event.setCancelled(true); return; } Target target = player.getTarget(); if (target == null) { return; } // target object was null if (target.isMuted()) { player.sendMessage(ChatColor.RED + "Target is muted."); event.setCancelled(true); return; } if (player.colorfulChat()) { event.setMessage(ChatColor.translateAlternateColorCodes('&', event.getMessage())); } String format = player.getFormattedMessage(); Set<Player> players = new HashSet<Player>(); if (target instanceof Channel) { if (!((Channel) target).getOccupants().contains(event.getPlayer())) { event.getPlayer().sendMessage(ChatColor.RED + "You aren't on that channel."); event.setCancelled(true); return; } players.addAll(((Channel) target).getOccupants()); } else { player.whisperTo(target, event.getMessage()); ((ChatPlayer) target).whisperFrom(player, event.getMessage()); event.setCancelled(true); return; } event.getRecipients().clear(); event.getRecipients().addAll(players); event.setFormat(format); event.setMessage(event.getMessage()); }