private HISTORY history() {
   HISTORY history = HISTORY.Factory.newInstance();
   history.setName(dvText("data"));
   history.setOrigin(dvDateTime("2008-05-22T20:04:26"));
   history.insertNewEvents(0);
   history.setEventsArray(0, pointEvent());
   return history;
 }
  public boolean isRightOf(FragmentsAvailable fragment) {
    switch (this) {
      case HISTORY:
        return fragment == UNKNOW;

      case HISTORY_DETAIL:
        return HISTORY.isRightOf(fragment) || fragment == HISTORY;

      case CONTACTS:
        return HISTORY_DETAIL.isRightOf(fragment) || fragment == HISTORY_DETAIL;

      case CONTACT:
        return CONTACTS.isRightOf(fragment) || fragment == CONTACTS;

      case EDIT_CONTACT:
        return CONTACT.isRightOf(fragment) || fragment == CONTACT;

      case DIALER:
        return EDIT_CONTACT.isRightOf(fragment) || fragment == EDIT_CONTACT;

      case ABOUT_INSTEAD_OF_CHAT:
      case CHATLIST:
        return DIALER.isRightOf(fragment) || fragment == DIALER;

      case CHAT:
        return CHATLIST.isRightOf(fragment) || fragment == CHATLIST;

      case ABOUT_INSTEAD_OF_SETTINGS:
      case SETTINGS:
        return CHATLIST.isRightOf(fragment)
            || fragment == CHATLIST
            || fragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;

      case ABOUT:
      case ACCOUNT_SETTINGS:
        return SETTINGS.isRightOf(fragment) || fragment == SETTINGS;

      default:
        return false;
    }
  }
示例#3
0
  /**
   * Builds an XML report of the timings to be uploaded for parsing.
   *
   * @param sender Who to report to
   */
  static void reportTimings(CommandSource sender) {
    Platform platform = SpongeImpl.getGame().getPlatform();
    JsonObjectBuilder builder =
        JSONUtil.objectBuilder()
            // Get some basic system details about the server
            .add(
                "version",
                platform
                    .getImplementation()
                    .getVersion()
                    .orElse(platform.getMinecraftVersion().getName() + "-DEV"))
            .add("maxplayers", SpongeImpl.getGame().getServer().getMaxPlayers())
            .add("start", TimingsManager.timingStart / 1000)
            .add("end", System.currentTimeMillis() / 1000)
            .add("sampletime", (System.currentTimeMillis() - TimingsManager.timingStart) / 1000);
    if (!TimingsManager.privacy) {
      builder
          .add("server", getServerName())
          .add("motd", SpongeImpl.getGame().getServer().getMotd().toPlain())
          .add("online-mode", SpongeImpl.getGame().getServer().getOnlineMode())
          .add("icon", MinecraftServer.getServer().getServerStatusResponse().getFavicon());
    }

    final Runtime runtime = Runtime.getRuntime();
    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
    builder.add(
        "system",
        JSONUtil.objectBuilder()
            .add("timingcost", getCost())
            .add("name", System.getProperty("os.name"))
            .add("version", System.getProperty("os.version"))
            .add("jvmversion", System.getProperty("java.version"))
            .add("arch", System.getProperty("os.arch"))
            .add("maxmem", runtime.maxMemory())
            .add("cpu", runtime.availableProcessors())
            .add("runtime", ManagementFactory.getRuntimeMXBean().getUptime())
            .add("flags", RUNTIME_FLAG_JOINER.join(runtimeBean.getInputArguments()))
            .add(
                "gc",
                JSONUtil.mapArrayToObject(
                    ManagementFactory.getGarbageCollectorMXBeans(),
                    (input) -> {
                      return JSONUtil.singleObjectPair(
                          input.getName(),
                          JSONUtil.arrayOf(input.getCollectionCount(), input.getCollectionTime()));
                    })));

    Set<BlockType> blockTypeSet = Sets.newHashSet();
    Set<EntityType> entityTypeSet = Sets.newHashSet();

    int size = HISTORY.size();
    TimingHistory[] history = new TimingHistory[size + 1];
    int i = 0;
    for (TimingHistory timingHistory : HISTORY) {
      blockTypeSet.addAll(timingHistory.blockTypeSet);
      entityTypeSet.addAll(timingHistory.entityTypeSet);
      history[i++] = timingHistory;
    }

    history[i] = new TimingHistory(); // Current snapshot
    blockTypeSet.addAll(history[i].blockTypeSet);
    entityTypeSet.addAll(history[i].entityTypeSet);

    JsonObjectBuilder handlersBuilder = JSONUtil.objectBuilder();
    for (TimingIdentifier.TimingGroup group : TimingIdentifier.GROUP_MAP.values()) {
      for (TimingHandler id : group.handlers) {
        if (!id.timed && !id.isSpecial()) {
          continue;
        }
        handlersBuilder.add(id.id, JSONUtil.arrayOf(group.id, id.name));
      }
    }

    builder.add(
        "idmap",
        JSONUtil.objectBuilder()
            .add(
                "groups",
                JSONUtil.mapArrayToObject(
                    TimingIdentifier.GROUP_MAP.values(),
                    (group) -> {
                      return JSONUtil.singleObjectPair(group.id, group.name);
                    }))
            .add("handlers", handlersBuilder)
            .add(
                "worlds",
                JSONUtil.mapArrayToObject(
                    TimingHistory.worldMap.entrySet(),
                    (entry) -> {
                      return JSONUtil.singleObjectPair(entry.getValue(), entry.getKey());
                    }))
            .add(
                "tileentity",
                JSONUtil.mapArrayToObject(
                    blockTypeSet,
                    (blockType) -> {
                      return JSONUtil.singleObjectPair(
                          Block.getIdFromBlock((Block) blockType), blockType.getId());
                    }))
            .add(
                "entity",
                JSONUtil.mapArrayToObject(
                    entityTypeSet,
                    (entityType) -> {
                      return JSONUtil.singleObjectPair(
                          ((SpongeEntityType) entityType).entityTypeId, entityType.getId());
                    })));

    // Information about loaded plugins

    builder.add(
        "plugins",
        JSONUtil.mapArrayToObject(
            SpongeImpl.getGame().getPluginManager().getPlugins(),
            (plugin) -> {
              return JSONUtil.objectBuilder()
                  .add(
                      plugin.getId(),
                      JSONUtil.objectBuilder()
                          .add("version", plugin.getVersion().orElse(""))
                          .add("description", plugin.getDescription().orElse(""))
                          .add("website", plugin.getUrl().orElse(""))
                          .add("authors", AUTHOR_LIST_JOINER.join(plugin.getAuthors())))
                  .build();
            }));

    // Information on the users Config

    builder.add(
        "config",
        JSONUtil.objectBuilder()
            .add("sponge", serializeConfigNode(SpongeImpl.getGlobalConfig().getRootNode())));

    new TimingsExport(sender, builder.build(), history).start();
  }