예제 #1
0
  @Override
  public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    if (!ichat.handleMe) return;
    if (event.isCancelled()) return;
    Player player = event.getPlayer();
    String command = event.getMessage();
    if (command == null) return;

    if (command.toLowerCase().startsWith("/me ")) {
      String message = command.substring(command.indexOf(" ")).trim();
      String formatted = ichat.API.parseChat(player, message, ichat.meFormat);

      // Call iChatMeEvent
      // TODO: Fix iChatMeEvent
      iChatMeEvent meEvent = new iChatMeEvent(player, message);
      ichat.getServer().getPluginManager().callEvent(meEvent);

      // Display in console, send to players, and cancel event
      ichat.console.sendMessage(formatted);
      for (Player target : ichat.getServer().getOnlinePlayers()) {
        target.sendMessage(formatted);
      }
      event.setCancelled(true);
    }
  }
예제 #2
0
 @Override
 public void onPlayerChat(PlayerChatEvent event) {
   if (event.isCancelled()) return;
   Player player = event.getPlayer();
   String message = event.getMessage();
   if (message == null) return;
   event.setFormat(ichat.API.parseChat(player, message, ichat.chatFormat));
 }