コード例 #1
0
  /**
   * Create a new NotificationChannel.
   *
   * @param channelName name of the channel
   * @param channel text area for showing the event log
   * @param blackList if <code>true</code>, the channel will default to showing everything that has
   *     not been explicitly blacklisted. Otherwise it'll show only whitelisted content. The main
   *     channel should default to blacklisting, as it should show types that have been added in new
   *     game versions
   * @param defaultTypes default value of the saved notification type list (white- or blacklist
   *     depending on the value of <code>showUnknown</code>)
   */
  NotificationChannel(
      String channelName, KTextEdit channel, boolean blackList, String defaultTypes) {
    name = channelName;
    this.channel = channel;
    if (blackList) {
      eventTypes = EnumSet.allOf(NotificationType.class);
    } else {
      eventTypes = EnumSet.noneOf(NotificationType.class);
    }

    // Load
    WtWindowManager wm = WtWindowManager.getInstance();
    String value = wm.getProperty("ui.channel." + name, defaultTypes);
    for (String typeString : value.split(",")) {
      /*
       * String.split is unfortunately unable to return empty arrays when
       * applied on empty string. Work around it.
       */
      if ("".equals(typeString)) {
        continue;
      }
      try {
        NotificationType type = NotificationType.valueOf(typeString);
        setTypeFiltering(type, !blackList);
      } catch (RuntimeException e) {
        logger.error("Unrecognized notification type '" + typeString + "'", e);
      }
    }
  }
コード例 #2
0
 /**
  * Creates a new text event.
  *
  * @param type NotificationType
  * @param text Text
  */
 public PrivateTextEvent(final NotificationType type, final String text) {
   super(Events.PRIVATE_TEXT);
   put(TEXT_TYPE, type.name());
   put(TEXT, text);
 }