Exemplo n.º 1
0
  /**
   * Process a record from the table containing the names and add the name to the name storage of
   * this class.
   *
   * @param line current line that is handled
   * @param loader table loader that loads the name table
   * @return true at all times
   */
  @Override
  public boolean processRecord(final int line, final TableLoader loader) {
    throwNullException(loader);

    names.addName(new CharacterId(loader.getLong(0)), loader.getString(1));

    return true;
  }
Exemplo n.º 2
0
  /**
   * Introduce a character and store the name in the table or overwrite a existing entry for this
   * character.
   *
   * @param id the ID of the character that shall get a name
   * @param name the name that the character shall get
   */
  public void introduce(final CharacterId id, final String name) {
    throwNullException(name);

    // update character with his name
    final Char chara = getCharacter(id);
    if (chara != null) {
      chara.setName(name);
    }

    // add name to list of known names
    names.addName(id, name);
  }
Exemplo n.º 3
0
  /**
   * Return the short version of the name of a character.
   *
   * @param id ID of the characters whos short name is wanted
   * @return the short version of the name of the character
   */
  @SuppressWarnings("nls")
  private String getShortName(final CharacterId id) {
    String name = null;

    if (names != null) {
      name = names.getName(id);
    }

    // return the id
    if (name == null) {
      if (showIDs) {
        name = Long.toString(id.getValue());
      }
    } else { // return text up to first blank
      final int pos = name.indexOf(' ');
      if (pos > 0) {
        name = name.substring(0, pos);
      }
    }
    return name;
  }
Exemplo n.º 4
0
  /**
   * Get the name of the character. Returns the last known name or someone along with the ID of the
   * character, in case its set that the IDs shall be shown.
   *
   * @param id ID of the character who's name is wanted
   * @return the name of the character or null
   */
  @SuppressWarnings("nls")
  private String getName(final CharacterId id) {
    String name = null;

    if (names != null) {
      name = names.getName(id);
    }

    if (name == null) {
      if (showIDs) {
        final TextBuilder buildName = TextBuilder.newInstance();
        buildName.setLength(0);
        buildName.append(Lang.getMsg("someone"));
        buildName.append(' ');
        buildName.append('(');
        buildName.append(id);
        buildName.append(')');
        name = buildName.toString();
        TextBuilder.recycle(buildName);
      }
    }
    return name;
  }
Exemplo n.º 5
0
 /**
  * Save the table that stores the names of the characters known to the current player character.
  */
 public void saveNames() {
   names.saveTable();
 }