Пример #1
0
  @SubscribeEvent
  public void onCrashReportEvent(CrashReportEvent event) {
    if (!diagnostics) return;
    if (event.getHeader().length() > 0) {
      return;
    }
    Throwable t = event.getThrowable();
    if (t instanceof LoaderException
        || t instanceof InvocationTargetException
        || t instanceof ReportedException) {
      t = t.getCause();
    }
    if (t == null) {
      return;
    }
    try {
      event.setHeader(handleThrowable(t));
    } catch (Throwable t2) {
      // Ignore any errors. We don't want to f**k up the crash reports.
    }
    List<ModContainer> mods = Utils.getModsFromStackTrace(event.getThrowable().getStackTrace());
    Set<ModContainer> s = Sets.newHashSet();
    ModContainer active = Loader.instance().activeModContainer();
    if (!mods.isEmpty() || (active != null && !active.getModId().equals("SquidAPI"))) {
      CrashReportCategory c = event.createCategory("Possibly involved mods");
      if (active != null && !active.getModId().equals("SquidAPI"))
        c.addCrashSection(
            active.getName(),
            String.format(
                "Version: %s. Main class: %s. Source: %s. Url: %s. Checksum: %s.",
                active.getVersion(),
                active.getMod().getClass().getName(),
                active.getSource().getName(),
                active.getMetadata().url,
                getChecksum(active.getSource())));
      for (ModContainer mod : mods) {
        if (!s.contains(mod)) {
          c.addCrashSection(
              mod.getName(),
              String.format(
                  "Version: %s. Main class: %s. Source: %s. Url: %s. Checksum: %s.",
                  mod.getVersion(),
                  mod.getMod().getClass().getName(),
                  mod.getSource().getName(),
                  mod.getMetadata().url,
                  getChecksum(mod.getSource())));
          s.add(mod);
        }
      }
    }
    try {
      if (Utils.isCoolSquid()) {
        event.setHeader("DRM!!! IT'S DRMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM!!!!!!!!!");
      }
    } catch (Throwable t2) {

    }
  }