1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
--- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java
@@ -7,10 +7,10 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletionException;
@@ -21,6 +21,7 @@
import org.slf4j.Logger;
public class CrashReport {
+
private static final Logger LOGGER = LogUtils.getLogger();
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss", Locale.ROOT);
private final String title;
@@ -35,6 +36,7 @@
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() {
@@ -46,31 +48,40 @@
}
public String getDetails() {
- StringBuilder stringBuilder = new StringBuilder();
- this.getDetails(stringBuilder);
- return stringBuilder.toString();
+ StringBuilder stringbuilder = new StringBuilder();
+
+ this.getDetails(stringbuilder);
+ return stringbuilder.toString();
}
public void getDetails(StringBuilder builder) {
if ((this.uncategorizedStackTrace == null || this.uncategorizedStackTrace.length <= 0) && !this.details.isEmpty()) {
- this.uncategorizedStackTrace = ArrayUtils.subarray(this.details.get(0).getStacktrace(), 0, 1);
+ this.uncategorizedStackTrace = (StackTraceElement[]) ArrayUtils.subarray(((CrashReportCategory) this.details.get(0)).getStacktrace(), 0, 1);
}
if (this.uncategorizedStackTrace != null && this.uncategorizedStackTrace.length > 0) {
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 (StackTraceElement stackTraceElement : this.uncategorizedStackTrace) {
- builder.append("\t").append("at ").append(stackTraceElement);
+ for (int j = 0; j < i; ++j) {
+ StackTraceElement stacktraceelement = astacktraceelement[j];
+
+ builder.append("\t").append("at ").append(stacktraceelement);
builder.append("\n");
}
builder.append("\n");
}
- for (CrashReportCategory crashReportCategory : this.details) {
- crashReportCategory.getDetails(builder);
+ Iterator iterator = this.details.iterator();
+
+ while (iterator.hasNext()) {
+ CrashReportCategory crashreportsystemdetails = (CrashReportCategory) iterator.next();
+
+ crashreportsystemdetails.getDetails(builder);
builder.append("\n\n");
}
@@ -78,57 +89,60 @@
}
public String getExceptionMessage() {
- StringWriter stringWriter = null;
- PrintWriter printWriter = null;
- Throwable throwable = this.exception;
- if (throwable.getMessage() == null) {
- if (throwable instanceof NullPointerException) {
- throwable = new NullPointerException(this.title);
- } else if (throwable instanceof StackOverflowError) {
- throwable = new StackOverflowError(this.title);
- } else if (throwable instanceof OutOfMemoryError) {
- throwable = new OutOfMemoryError(this.title);
+ StringWriter stringwriter = null;
+ PrintWriter printwriter = null;
+ Object object = this.exception;
+
+ if (((Throwable) object).getMessage() == null) {
+ if (object instanceof NullPointerException) {
+ object = new NullPointerException(this.title);
+ } else if (object instanceof StackOverflowError) {
+ object = new StackOverflowError(this.title);
+ } else if (object instanceof OutOfMemoryError) {
+ object = new OutOfMemoryError(this.title);
}
- throwable.setStackTrace(this.exception.getStackTrace());
+ ((Throwable) object).setStackTrace(this.exception.getStackTrace());
}
- String var4;
+ String s;
+
try {
- stringWriter = new StringWriter();
- printWriter = new PrintWriter(stringWriter);
- throwable.printStackTrace(printWriter);
- var4 = stringWriter.toString();
+ stringwriter = new StringWriter();
+ printwriter = new PrintWriter(stringwriter);
+ ((Throwable) object).printStackTrace(printwriter);
+ s = stringwriter.toString();
} finally {
- IOUtils.closeQuietly((Writer)stringWriter);
- IOUtils.closeQuietly((Writer)printWriter);
+ IOUtils.closeQuietly(stringwriter);
+ IOUtils.closeQuietly(printwriter);
}
- return var4;
+ return s;
}
public String getFriendlyReport() {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("---- Minecraft Crash Report ----\n");
- stringBuilder.append("// ");
- stringBuilder.append(getErrorComment());
- stringBuilder.append("\n\n");
- stringBuilder.append("Time: ");
- stringBuilder.append(DATE_TIME_FORMATTER.format(ZonedDateTime.now()));
- stringBuilder.append("\n");
- stringBuilder.append("Description: ");
- stringBuilder.append(this.title);
- stringBuilder.append("\n\n");
- stringBuilder.append(this.getExceptionMessage());
- stringBuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n");
+ StringBuilder stringbuilder = new StringBuilder();
- for (int i = 0; i < 87; i++) {
- stringBuilder.append("-");
+ stringbuilder.append("---- Minecraft Crash Report ----\n");
+ stringbuilder.append("// ");
+ stringbuilder.append(getErrorComment());
+ stringbuilder.append("\n\n");
+ stringbuilder.append("Time: ");
+ stringbuilder.append(CrashReport.DATE_TIME_FORMATTER.format(ZonedDateTime.now()));
+ stringbuilder.append("\n");
+ stringbuilder.append("Description: ");
+ stringbuilder.append(this.title);
+ stringbuilder.append("\n\n");
+ stringbuilder.append(this.getExceptionMessage());
+ stringbuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n");
+
+ for (int i = 0; i < 87; ++i) {
+ stringbuilder.append("-");
}
- stringBuilder.append("\n\n");
- this.getDetails(stringBuilder);
- return stringBuilder.toString();
+ stringbuilder.append("\n\n");
+ this.getDetails(stringbuilder);
+ return stringbuilder.toString();
}
@Nullable
@@ -144,22 +158,25 @@
toFile.getParentFile().mkdirs();
}
- Writer writer = null;
+ OutputStreamWriter outputstreamwriter = null;
- boolean var4;
+ boolean flag;
+
try {
- writer = new OutputStreamWriter(new FileOutputStream(toFile), StandardCharsets.UTF_8);
- writer.write(this.getFriendlyReport());
+ outputstreamwriter = new OutputStreamWriter(new FileOutputStream(toFile), StandardCharsets.UTF_8);
+ outputstreamwriter.write(this.getFriendlyReport());
this.saveFile = toFile;
- return true;
- } catch (Throwable var8) {
- LOGGER.error("Could not save crash report to {}", toFile, var8);
- var4 = false;
+ boolean flag1 = true;
+
+ return flag1;
+ } catch (Throwable throwable) {
+ CrashReport.LOGGER.error("Could not save crash report to {}", toFile, throwable);
+ flag = false;
} finally {
- IOUtils.closeQuietly(writer);
+ IOUtils.closeQuietly(outputstreamwriter);
}
- return var4;
+ return flag;
}
}
@@ -172,78 +189,45 @@
}
public CrashReportCategory addCategory(String categoryName, int stacktraceLength) {
- CrashReportCategory crashReportCategory = new CrashReportCategory(categoryName);
+ CrashReportCategory crashreportsystemdetails = new CrashReportCategory(categoryName);
+
if (this.trackingStackTrace) {
- int i = crashReportCategory.fillInStackTrace(stacktraceLength);
- StackTraceElement[] stackTrace = this.exception.getStackTrace();
- StackTraceElement stackTraceElement = null;
- StackTraceElement stackTraceElement1 = null;
- int i1 = stackTrace.length - i;
- if (i1 < 0) {
- LOGGER.error("Negative index in crash report handler ({}/{})", stackTrace.length, i);
+ int j = crashreportsystemdetails.fillInStackTrace(stacktraceLength);
+ StackTraceElement[] astacktraceelement = this.exception.getStackTrace();
+ StackTraceElement stacktraceelement = null;
+ StackTraceElement stacktraceelement1 = null;
+ int k = astacktraceelement.length - j;
+
+ if (k < 0) {
+ CrashReport.LOGGER.error("Negative index in crash report handler ({}/{})", astacktraceelement.length, j);
}
- if (stackTrace != null && 0 <= i1 && i1 < stackTrace.length) {
- stackTraceElement = stackTrace[i1];
- if (stackTrace.length + 1 - i < stackTrace.length) {
- stackTraceElement1 = stackTrace[stackTrace.length + 1 - i];
+ if (astacktraceelement != null && 0 <= k && k < astacktraceelement.length) {
+ stacktraceelement = astacktraceelement[k];
+ if (astacktraceelement.length + 1 - j < astacktraceelement.length) {
+ stacktraceelement1 = astacktraceelement[astacktraceelement.length + 1 - j];
}
}
- this.trackingStackTrace = crashReportCategory.validateStackTrace(stackTraceElement, stackTraceElement1);
- if (stackTrace != null && stackTrace.length >= i && 0 <= i1 && i1 < stackTrace.length) {
- this.uncategorizedStackTrace = new StackTraceElement[i1];
- System.arraycopy(stackTrace, 0, this.uncategorizedStackTrace, 0, this.uncategorizedStackTrace.length);
+ 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);
} else {
this.trackingStackTrace = false;
}
}
- this.details.add(crashReportCategory);
- return crashReportCategory;
+ this.details.add(crashreportsystemdetails);
+ return crashreportsystemdetails;
}
private static String getErrorComment() {
- String[] strings = new String[]{
- "Who set us up the TNT?",
- "Everything's going to plan. No, really, that was supposed to happen.",
- "Uh... Did I do that?",
- "Oops.",
- "Why did you do that?",
- "I feel sad now :(",
- "My bad.",
- "I'm sorry, Dave.",
- "I let you down. Sorry :(",
- "On the bright side, I bought you a teddy bear!",
- "Daisy, daisy...",
- "Oh - I know what I did wrong!",
- "Hey, that tickles! Hehehe!",
- "I blame Dinnerbone.",
- "You should try our sister game, Minceraft!",
- "Don't be sad. I'll do better next time, I promise!",
- "Don't be sad, have a hug! <3",
- "I just don't know what went wrong :(",
- "Shall we play a game?",
- "Quite honestly, I wouldn't worry myself about that.",
- "I bet Cylons wouldn't have this problem.",
- "Sorry :(",
- "Surprise! Haha. Well, this is awkward.",
- "Would you like a cupcake?",
- "Hi. I'm Minecraft, and I'm a crashaholic.",
- "Ooh. Shiny.",
- "This doesn't make any sense!",
- "Why is it breaking :(",
- "Don't do that.",
- "Ouch. That hurt :(",
- "You're mean.",
- "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]",
- "There are four lights!",
- "But it works on my machine."
- };
+ String[] astring = new String[]{"Who set us up the TNT?", "Everything's going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I'm sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don't be sad. I'll do better next time, I promise!", "Don't be sad, have a hug! <3", "I just don't know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn't worry myself about that.", "I bet Cylons wouldn't have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I'm Minecraft, and I'm a crashaholic.", "Ooh. Shiny.", "This doesn't make any sense!", "Why is it breaking :(", "Don't do that.", "Ouch. That hurt :(", "You're mean.", "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]", "There are four lights!", "But it works on my machine."};
try {
- return strings[(int)(Util.getNanos() % (long)strings.length)];
- } catch (Throwable var2) {
+ return astring[(int) (Util.getNanos() % (long) astring.length)];
+ } catch (Throwable throwable) {
return "Witty comment unavailable :(";
}
}
@@ -253,18 +237,21 @@
cause = cause.getCause();
}
- CrashReport report;
- if (cause instanceof ReportedException reportedException) {
- report = reportedException.getReport();
+ CrashReport crashreport;
+
+ if (cause instanceof ReportedException) {
+ ReportedException reportedexception = (ReportedException) cause;
+
+ crashreport = reportedexception.getReport();
} else {
- report = new CrashReport(description, cause);
+ crashreport = new CrashReport(description, cause);
}
- return report;
+ return crashreport;
}
public static void preload() {
MemoryReserve.allocate();
- new CrashReport("Don't panic!", new Throwable()).getFriendlyReport();
+ (new CrashReport("Don't panic!", new Throwable())).getFriendlyReport();
}
}
|