Paper/patch-remap/mache-spigotflower/net/minecraft/CrashReport.java.patch
2024-01-14 11:04:49 +01:00

168 lines
7.0 KiB
Diff

--- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java
@@ -33,9 +33,10 @@
private StackTraceElement[] uncategorizedStackTrace = new StackTraceElement[0];
private final SystemReport systemReport = new SystemReport();
- public CrashReport(String s, Throwable throwable) {
- this.title = s;
- this.exception = throwable;
+ public CrashReport(String title, Throwable exception) {
+ this.title = title;
+ this.exception = exception;
+ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
}
public String getTitle() {
@@ -53,38 +54,38 @@
return stringbuilder.toString();
}
- public void getDetails(StringBuilder stringbuilder) {
+ public void getDetails(StringBuilder builder) {
if ((this.uncategorizedStackTrace == null || this.uncategorizedStackTrace.length <= 0) && !this.details.isEmpty()) {
this.uncategorizedStackTrace = (StackTraceElement[]) ArrayUtils.subarray(((CrashReportCategory) this.details.get(0)).getStacktrace(), 0, 1);
}
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
- stringbuilder.append("-- Head --\n");
- stringbuilder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
- stringbuilder.append("Stacktrace:\n");
+ builder.append("-- Head --\n");
+ builder.append("Thread: ").append(Thread.currentThread().getName()).append("\n");
+ builder.append("Stacktrace:\n");
StackTraceElement[] astacktraceelement = this.uncategorizedStackTrace;
int i = astacktraceelement.length;
for (int j = 0; j < i; ++j) {
StackTraceElement stacktraceelement = astacktraceelement[j];
- stringbuilder.append("\t").append("at ").append(stacktraceelement);
- stringbuilder.append("\n");
+ builder.append("\t").append("at ").append(stacktraceelement);
+ builder.append("\n");
}
- stringbuilder.append("\n");
+ builder.append("\n");
}
Iterator iterator = this.details.iterator();
while (iterator.hasNext()) {
- CrashReportCategory crashreportcategory = (CrashReportCategory) iterator.next();
+ CrashReportCategory crashreportsystemdetails = (CrashReportCategory) iterator.next();
- crashreportcategory.getDetails(stringbuilder);
- stringbuilder.append("\n\n");
+ crashreportsystemdetails.getDetails(builder);
+ builder.append("\n\n");
}
- this.systemReport.appendToCrashReportString(stringbuilder);
+ this.systemReport.appendToCrashReportString(builder);
}
public String getExceptionMessage() {
@@ -149,12 +150,12 @@
return this.saveFile;
}
- public boolean saveToFile(File file) {
+ public boolean saveToFile(File toFile) {
if (this.saveFile != null) {
return false;
} else {
- if (file.getParentFile() != null) {
- file.getParentFile().mkdirs();
+ if (toFile.getParentFile() != null) {
+ toFile.getParentFile().mkdirs();
}
OutputStreamWriter outputstreamwriter = null;
@@ -162,14 +163,14 @@
boolean flag;
try {
- outputstreamwriter = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
+ outputstreamwriter = new OutputStreamWriter(new FileOutputStream(toFile), StandardCharsets.UTF_8);
outputstreamwriter.write(this.getFriendlyReport());
- this.saveFile = file;
+ this.saveFile = toFile;
boolean flag1 = true;
return flag1;
} catch (Throwable throwable) {
- CrashReport.LOGGER.error("Could not save crash report to {}", file, throwable);
+ CrashReport.LOGGER.error("Could not save crash report to {}", toFile, throwable);
flag = false;
} finally {
IOUtils.closeQuietly(outputstreamwriter);
@@ -183,15 +184,15 @@
return this.systemReport;
}
- public CrashReportCategory addCategory(String s) {
- return this.addCategory(s, 1);
+ public CrashReportCategory addCategory(String name) {
+ return this.addCategory(name, 1);
}
- public CrashReportCategory addCategory(String s, int i) {
- CrashReportCategory crashreportcategory = new CrashReportCategory(s);
+ public CrashReportCategory addCategory(String categoryName, int stacktraceLength) {
+ CrashReportCategory crashreportsystemdetails = new CrashReportCategory(categoryName);
if (this.trackingStackTrace) {
- int j = crashreportcategory.fillInStackTrace(i);
+ int j = crashreportsystemdetails.fillInStackTrace(stacktraceLength);
StackTraceElement[] astacktraceelement = this.exception.getStackTrace();
StackTraceElement stacktraceelement = null;
StackTraceElement stacktraceelement1 = null;
@@ -208,7 +209,7 @@
}
}
- this.trackingStackTrace = crashreportcategory.validateStackTrace(stacktraceelement, stacktraceelement1);
+ this.trackingStackTrace = crashreportsystemdetails.validateStackTrace(stacktraceelement, stacktraceelement1);
if (astacktraceelement != null && astacktraceelement.length >= j && 0 <= k && k < astacktraceelement.length) {
this.uncategorizedStackTrace = new StackTraceElement[k];
System.arraycopy(astacktraceelement, 0, this.uncategorizedStackTrace, 0, this.uncategorizedStackTrace.length);
@@ -217,8 +218,8 @@
}
}
- this.details.add(crashreportcategory);
- return crashreportcategory;
+ this.details.add(crashreportsystemdetails);
+ return crashreportsystemdetails;
}
private static String getErrorComment() {
@@ -231,19 +232,19 @@
}
}
- public static CrashReport forThrowable(Throwable throwable, String s) {
- while (throwable instanceof CompletionException && throwable.getCause() != null) {
- throwable = throwable.getCause();
+ public static CrashReport forThrowable(Throwable cause, String description) {
+ while (cause instanceof CompletionException && cause.getCause() != null) {
+ cause = cause.getCause();
}
CrashReport crashreport;
- if (throwable instanceof ReportedException) {
- ReportedException reportedexception = (ReportedException) throwable;
+ if (cause instanceof ReportedException) {
+ ReportedException reportedexception = (ReportedException) cause;
crashreport = reportedexception.getReport();
} else {
- crashreport = new CrashReport(s, throwable);
+ crashreport = new CrashReport(description, cause);
}
return crashreport;