コード例 #1
0
  @EventHandler(priority = EventPriority.LOWEST)
  public void chatHandler(AsyncPlayerChatEvent event) {
    // if the chat is cancelled, back out
    if (event.isCancelled()) return;

    // and cancel the event!
    event.setCancelled(true);

    // filter the annoying rei's minimap
    if (event.getMessage().startsWith("u00")) {
      return;
    }

    // now intercept the chat
    boolean chatSent =
        plugin.chatManager.handleChat(event.getPlayer(), event.getMessage(), false, "", true);

    if (!chatSent) {
      plugin.debug("no network message (chat not sent)");
      return;
    }

    // only if they're not spamming / on timeout and the network layer is enabled!
    if (plugin.netManager != null) {
      // send to our network layer
      plugin.debug("sending network chat");
      plugin.chatManager.sendNetworkChat(event.getPlayer(), event.getMessage(), false, "", true);
    } else {
      plugin.debug("message not broadcasted due to netManager being null");
    }
  }