Example #1
0
  public static final PlayerAppearance getInstance(int objectId) {
    PlayerAppearance appearance = pool.take();

    if (appearance == null) appearance = new PlayerAppearance();

    appearance.setObjectId(objectId);

    return appearance;
  }
Example #2
0
  public static String toXML(PlayerAppearance appearance, String id) {
    StringBuilder builder = new StringBuilder();

    builder.append("<appearance id=\"").append(id).append("\" >\n");

    Array<Field> fields =
        ReflectionUtils.getAllFields(appearance.getClass(), Object.class, true, "pool", "objectId");

    try {
      for (Field field : fields) {
        String name = field.getName();

        boolean old = field.isAccessible();

        field.setAccessible(true);

        String value = String.valueOf(field.get(appearance));

        builder
            .append("	<set name=\"")
            .append(name)
            .append("\" value=\"")
            .append(value)
            .append("\" />")
            .append("\n");

        field.setAccessible(old);
      }
    } catch (IllegalArgumentException | IllegalAccessException e) {
      Loggers.warning(appearance.getClass(), e);
    }

    builder.append("</appearance>");

    return builder.toString();
  }