예제 #1
0
 public void setTarget(Target t) {
   target = t;
   Player p = getPlayer();
   if (p != null) {
     p.sendMessage("[ChatSuite] Your target is now: " + target.getName());
   }
 }
예제 #2
0
 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);
   }
 }
예제 #3
0
 @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());
 }
예제 #4
0
 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;
 }
예제 #5
0
 protected String whisperParse(String format) {
   format = TARGET.matcher(format).replaceAll(reply.getName());
   format = TARGET_DISPLAY.matcher(format).replaceAll(reply.getName());
   return format;
 }
예제 #6
0
 @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);
 }