66import dev .skidfuscator .jghost .tree .GhostClassNode ;
77import dev .skidfuscator .jghost .tree .GhostContents ;
88import dev .skidfuscator .jghost .tree .GhostLibrary ;
9+ import dev .skidfuscator .logger .Logger ;
910import dev .skidfuscator .obfuscator .SkidfuscatorSession ;
1011import lombok .experimental .UtilityClass ;
11- import org .apache .log4j .Logger ;
1212import org .mapleir .app .service .ApplicationClassSource ;
1313import org .mapleir .asm .ClassHelper ;
1414import org .mapleir .asm .ClassNode ;
2424
2525@ UtilityClass
2626public class GhostHelper {
27- private final Logger LOGGER = Logger .getLogger (GhostHelper .class );
28- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File file ) {
29- return getLibraryClassSource (session , file , false );
27+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File file ) {
28+ return getLibraryClassSource (session , logger , file , false );
3029 }
3130
32- public ApplicationClassSource getJvm (final SkidfuscatorSession session , final File file ) {
33- return getLibraryClassSource (session , file , true );
31+ public ApplicationClassSource getJvm (final SkidfuscatorSession session , final Logger logger , final File file ) {
32+ return getLibraryClassSource (session , logger , file , true );
3433 }
3534
36- public ApplicationClassSource getJvm (final boolean fuckit , final File file ) {
37- return getLibraryClassSource (fuckit , file , true );
35+ public ApplicationClassSource getJvm (final Logger logger , final boolean fuckit , final File file ) {
36+ return getLibraryClassSource (logger , fuckit , file , true );
3837 }
3938
40- public ApplicationClassSource getJvm (final boolean fuckit , final File file , final File mappings ) {
41- return getLibraryClassSource (fuckit , file , mappings , true );
39+ public ApplicationClassSource getJvm (final Logger logger , final boolean fuckit , final File file , final File mappings ) {
40+ return getLibraryClassSource (logger , fuckit , file , mappings , true );
4241 }
4342
44- public GhostLibrary getLibrary (final File lib , boolean jre ) {
45- return getLibrary (lib , null , jre );
43+ public GhostLibrary getLibrary (final Logger logger , final File lib , boolean jre ) {
44+ return getLibrary (logger , lib , null , jre );
4645 }
4746
48- public GhostLibrary getLibrary (final File lib , final File folder , boolean jre ) {
49- LOGGER . info ("[+] " + lib .getAbsolutePath ());
47+ public GhostLibrary getLibrary (final Logger logger , final File lib , final File folder , boolean jre ) {
48+ logger . post ("[+] " + lib .getAbsolutePath ());
5049
5150 final StringBuilder outputPath = new StringBuilder ();
5251 if (folder != null ) {
@@ -67,36 +66,36 @@ public GhostLibrary getLibrary(final File lib, final File folder, boolean jre) {
6766 final GhostLibrary library ;
6867
6968 if (!output .exists ()) {
70- LOGGER . info ("[?] Could not find mappings for " + lib .getAbsolutePath () + "... Creating..." );
69+ logger . post ("[?] Could not find mappings for " + lib .getAbsolutePath () + "... Creating..." );
7170 output .getParentFile ().mkdirs ();
7271 output .getParentFile ().mkdir ();
73- library = GhostHelper .createFromLibraryFile (lib );
74- GhostHelper .saveLibraryFile (library , output );
75- LOGGER . info ("[✓] Creating mappings for " + lib .getAbsolutePath () + "!" );
72+ library = GhostHelper .createFromLibraryFile (logger , lib );
73+ GhostHelper .saveLibraryFile (logger , library , output );
74+ logger . post ("[✓] Creating mappings for " + lib .getAbsolutePath () + "!" );
7675 } else {
77- library = GhostHelper .readFromLibraryFile (output );
76+ library = GhostHelper .readFromLibraryFile (logger , output );
7877 }
7978
8079 return library ;
8180 }
8281
83- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File lib , boolean jvm ) {
84- return importFile (session .isFuckIt (), getLibrary (lib , jvm ));
82+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File lib , boolean jvm ) {
83+ return importFile (logger , session .isFuckIt (), getLibrary (logger , lib , jvm ));
8584 }
8685
87- public ApplicationClassSource getLibraryClassSource (final boolean fuckIt , final File lib , boolean jvm ) {
88- return importFile (fuckIt , getLibrary (lib , jvm ));
86+ public ApplicationClassSource getLibraryClassSource (final Logger logger , final boolean fuckIt , final File lib , boolean jvm ) {
87+ return importFile (logger , fuckIt , getLibrary (logger , lib , jvm ));
8988 }
9089
91- public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final File lib , final File mappings , final boolean jvm ) {
92- return importFile (session .isFuckIt (), getLibrary (lib , mappings , jvm ));
90+ public ApplicationClassSource getLibraryClassSource (final SkidfuscatorSession session , final Logger logger , final File lib , final File mappings , final boolean jvm ) {
91+ return importFile (logger , session .isFuckIt (), getLibrary (logger , lib , mappings , jvm ));
9392 }
9493
95- public ApplicationClassSource getLibraryClassSource (final boolean fuckit , final File lib , final File mappings , final boolean jvm ) {
96- return importFile (fuckit , getLibrary (lib , mappings , jvm ));
94+ public ApplicationClassSource getLibraryClassSource (final Logger logger , final boolean fuckit , final File lib , final File mappings , final boolean jvm ) {
95+ return importFile (logger , fuckit , getLibrary (logger , lib , mappings , jvm ));
9796 }
9897
99- public ApplicationClassSource importFile (final boolean fuckit , final GhostLibrary library ) {
98+ public ApplicationClassSource importFile (final Logger logger , final boolean fuckit , final GhostLibrary library ) {
10099 /* Create a new library class source with superior to default priority */
101100 final ApplicationClassSource libraryClassSource = new ApplicationClassSource (
102101 "libraries" ,
@@ -107,12 +106,12 @@ public ApplicationClassSource importFile(final boolean fuckit, final GhostLibrar
107106 .stream ()
108107 .map (e -> ClassHelper .create (e .read ())).collect (Collectors .toList ())
109108 );
110- LOGGER . info ("[✓] Imported " + library .getContents ().getClasses ().size () + " library classes..." );
109+ logger . post ("[✓] Imported " + library .getContents ().getClasses ().size () + " library classes..." );
111110
112111 return libraryClassSource ;
113112 }
114113
115- public GhostLibrary readFromLibraryFile (final File file ) {
114+ public GhostLibrary readFromLibraryFile (final Logger logger , final File file ) {
116115 try {
117116 final FileReader fileReader = new FileReader (file );
118117 final GhostLibrary library = Ghost
@@ -121,12 +120,12 @@ public GhostLibrary readFromLibraryFile(final File file) {
121120 fileReader .close ();
122121 return library ;
123122 } catch (IOException e ) {
124- LOGGER .error ("Failed to download library cache" , e );
123+ logger .error ("Failed to download library cache" , e );
125124 return null ;
126125 }
127126 }
128127
129- public GhostLibrary createFromLibraryFile (final File file ) {
128+ public GhostLibrary createFromLibraryFile (final Logger logger , final File file ) {
130129 final JarInfo jarInfo = new JarInfo (file );
131130 final AbstractJarDownloader <ClassNode > downloader = file .getName ().endsWith (".jmod" )
132131 ? new SingleJmodDownloader <>(jarInfo )
@@ -135,7 +134,7 @@ public GhostLibrary createFromLibraryFile(final File file) {
135134 try {
136135 downloader .download ();
137136 } catch (IOException e ) {
138- LOGGER .error ("Failed to download library" , e );
137+ logger .error ("Failed to download library" , e );
139138 return null ;
140139 }
141140
@@ -149,7 +148,7 @@ public GhostLibrary createFromLibraryFile(final File file) {
149148 ghostLibrary .setSha1 (byteSource .hash (Hashing .sha1 ()).toString ());
150149 ghostLibrary .setSha256 (byteSource .hash (Hashing .sha256 ()).toString ());
151150 } catch (Throwable e ) {
152- LOGGER .error ("Failed to hash library" , e );
151+ logger .error ("Failed to hash library" , e );
153152 return null ;
154153 }
155154
@@ -161,14 +160,14 @@ public GhostLibrary createFromLibraryFile(final File file) {
161160 return ghostLibrary ;
162161 }
163162
164- public void saveLibraryFile (final GhostLibrary library , final File file ) {
163+ public void saveLibraryFile (final Logger logger , final GhostLibrary library , final File file ) {
165164 try {
166165 final FileWriter fileWriter = new FileWriter (file );
167166 final BufferedWriter writer = new BufferedWriter (fileWriter );
168167 writer .write (Ghost .gson ().toJson (library , GhostLibrary .class ));
169168 writer .close ();
170169 } catch (IOException e ) {
171- LOGGER .error ("Failed to download library cache" , e );
170+ logger .error ("Failed to download library cache" , e );
172171 return ;
173172 }
174173 }
0 commit comments