14
14
import java .nio .file .FileSystems ;
15
15
import java .nio .file .Files ;
16
16
import java .util .*;
17
- import java .util .concurrent .atomic .AtomicLong ;
18
17
19
18
@ Mod (modid = Tags .MODID , version = Tags .VERSION , name = Tags .MODNAME , acceptedMinecraftVersions = "[1.7.10]" )
20
19
public class ModDiagram {
@@ -32,10 +31,14 @@ class `%s`["%s"] {
32
31
33
32
@ EventHandler
34
33
public void postInit (FMLPostInitializationEvent event ) {
35
- LOG .info ("Generating mod mermaid diagram..." );
34
+ LOG .info ("Generating mod mermaid diagram and mod list ..." );
36
35
var graph = new StringBuilder ("```mermaid\n classDiagram\n " );
36
+ var list = new StringBuilder ("# Mods " );
37
37
var mods = new ArrayList <>(Loader .instance ().getModList ());
38
38
mods .sort (Comparator .comparing (ModContainer ::getModId ));
39
+
40
+ list .append ('(' ).append (mods .size ()).append (")\n " );
41
+
39
42
for (ModContainer mod : mods ) {
40
43
// Skip forge mod containers
41
44
if (shouldSkip (mod .getModId ())) {
@@ -52,14 +55,24 @@ public void postInit(FMLPostInitializationEvent event) {
52
55
}
53
56
54
57
graph .append ("\n " );
58
+
59
+ list .append ("* " ).append (mod .getName ()).append ("-\\ [" ).append (mod .getModId ().replace ("<" ,"\\ <" )).append ("]-" )
60
+ .append (mod .getVersion ()).append ('\n' );
55
61
}
56
62
graph .append ("```" );
57
63
try {
58
- Files .write (FileSystems .getDefault ().getPath ("./mods .md" ),
64
+ Files .write (FileSystems .getDefault ().getPath ("./mod-diagram .md" ),
59
65
graph .toString ().getBytes (StandardCharsets .UTF_8 ));
60
66
} catch (IOException e ) {
61
67
LOG .error ("Unable to write down mod diagram" , e );
62
68
}
69
+
70
+ try {
71
+ Files .write (FileSystems .getDefault ().getPath ("./mod-list.md" ),
72
+ list .toString ().getBytes (StandardCharsets .UTF_8 ));
73
+ } catch (IOException e ) {
74
+ LOG .error ("Unable to write down mod list" , e );
75
+ }
63
76
}
64
77
65
78
private boolean shouldSkip (String modId ) {
0 commit comments