public void setTarget(Target t) { target = t; Player p = getPlayer(); if (p != null) { p.sendMessage("[ChatSuite] Your target is now: " + target.getName()); } }
public void whisperTo(Target to, String message) { reply = to; String format = getFormattedWhisperTo(to); format = format.replaceAll("(%message|%m)", message); sendMessage(format); if (to instanceof ChatPlayer && ((ChatPlayer) to).afk) { sendMessage(to.getName() + " is afk: " + ((ChatPlayer) to).afk_message); } }
@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()); }
private String parseTarget(String format) { if (target != null) { if (target instanceof Channel) { format = TARGET.matcher(format).replaceAll(((Channel) target).getColoredName()); } else { format = TARGET.matcher(format).replaceAll(target.getName()); } Player p = getPlayer(); if (p != null) { format = TARGET_DISPLAY.matcher(format).replaceAll(p.getDisplayName()); } } return format; }
protected String whisperParse(String format) { format = TARGET.matcher(format).replaceAll(reply.getName()); format = TARGET_DISPLAY.matcher(format).replaceAll(reply.getName()); return format; }
@Override public void persist() { String t = (target instanceof Channel ? "c:" + target.getName() : "p:" + target.getName()); manager.getConfig().set(getName() + ".target", t); manager.getConfig().set(getName() + ".auto_join", auto_join); }