Commit a954e68724fad1a977f5d6ad1c586227528dcc4b
1 parent
90695d21
LiteLoader 1.6.2 - re-added CallableJVMFlags hook for crash report, because I re…
…ally can't figure out a better way right now
Showing
1 changed file
with
58 additions
and
0 deletions
java/net/minecraft/src/CallableJVMFlags.java
0 → 100644
1 | +package net.minecraft.src; | ||
2 | + | ||
3 | +import java.lang.management.ManagementFactory; | ||
4 | +import java.lang.management.RuntimeMXBean; | ||
5 | +import java.util.Iterator; | ||
6 | +import java.util.List; | ||
7 | +import java.util.concurrent.Callable; | ||
8 | + | ||
9 | +import com.mumfrey.liteloader.core.CallableLiteLoaderBrand; | ||
10 | +import com.mumfrey.liteloader.core.CallableLiteLoaderMods; | ||
11 | + | ||
12 | +class CallableJVMFlags implements Callable<String> | ||
13 | +{ | ||
14 | + /** Reference to the CrashReport object. */ | ||
15 | + final CrashReport theCrashReport; | ||
16 | + | ||
17 | + CallableJVMFlags(CrashReport par1CrashReport) | ||
18 | + { | ||
19 | + this.theCrashReport = par1CrashReport; | ||
20 | + par1CrashReport.func_85056_g().addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(par1CrashReport)); | ||
21 | + par1CrashReport.func_85056_g().addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(par1CrashReport)); | ||
22 | + } | ||
23 | + | ||
24 | + /** | ||
25 | + * Returns the number of JVM Flags along with the passed JVM Flags. | ||
26 | + */ | ||
27 | + public String getJVMFlagsAsString() | ||
28 | + { | ||
29 | + RuntimeMXBean var1 = ManagementFactory.getRuntimeMXBean(); | ||
30 | + List<String> var2 = var1.getInputArguments(); | ||
31 | + int var3 = 0; | ||
32 | + StringBuilder var4 = new StringBuilder(); | ||
33 | + Iterator<String> var5 = var2.iterator(); | ||
34 | + | ||
35 | + while (var5.hasNext()) | ||
36 | + { | ||
37 | + String var6 = var5.next(); | ||
38 | + | ||
39 | + if (var6.startsWith("-X")) | ||
40 | + { | ||
41 | + if (var3++ > 0) | ||
42 | + { | ||
43 | + var4.append(" "); | ||
44 | + } | ||
45 | + | ||
46 | + var4.append(var6); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + return String.format("%d total; %s", new Object[] {Integer.valueOf(var3), var4.toString()}); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String call() | ||
55 | + { | ||
56 | + return this.getJVMFlagsAsString(); | ||
57 | + } | ||
58 | +} |