11package io .github .zekerzhayard .forgewrapper .installer .util ;
22
33import java .io .File ;
4- import java .util . function . Predicate ;
4+ import java .lang . reflect . Method ;
55
6- import net .minecraftforge .installer .actions .ClientInstall ;
6+ import net .minecraftforge .installer .actions .PostProcessors ;
77import net .minecraftforge .installer .actions .ProgressCallback ;
88import net .minecraftforge .installer .json .Install ;
99import net .minecraftforge .installer .json .InstallV1 ;
@@ -16,23 +16,22 @@ public Install loadInstallProfile() {
1616 }
1717
1818 @ Override
19- public boolean runClientInstall (Install profile , ProgressCallback monitor , File libraryDir , File minecraftJar , File installerJar ) {
20- return new ClientInstall4MultiMC (profile , monitor , libraryDir , minecraftJar ).run (null , input -> true , installerJar );
21- }
19+ public boolean runClientInstall (Install profile , ProgressCallback monitor , File libraryDir , File minecraftJar ,
20+ File installerJar ) {
21+ PostProcessors processors = new PostProcessors (
22+ profile instanceof InstallV1 ? (InstallV1 ) profile : new InstallV1 (profile ), true , monitor );
2223
23- public static class ClientInstall4MultiMC extends ClientInstall {
24- protected File libraryDir ;
25- protected File minecraftJar ;
24+ try {
25+ Method method = processors .getClass ().getMethod ("process" , File .class , File .class , File .class , File .class );
26+ Object result = method .invoke (processors , libraryDir , minecraftJar , libraryDir .getParentFile (),
27+ installerJar );
2628
27- public ClientInstall4MultiMC (Install profile , ProgressCallback monitor , File libraryDir , File minecraftJar ) {
28- super (profile instanceof InstallV1 ? (InstallV1 ) profile : new InstallV1 (profile ), monitor );
29- this .libraryDir = libraryDir ;
30- this .minecraftJar = minecraftJar ;
31- }
29+ if (method .getReturnType () == boolean .class )
30+ return (boolean ) result ;
3231
33- @ Override
34- public boolean run ( File target , Predicate < String > optionals , File installer ) {
35- return this . processors . process ( this . libraryDir , this . minecraftJar , this . libraryDir . getParentFile (), installer );
32+ return result != null ;
33+ } catch ( ReflectiveOperationException e ) {
34+ throw new RuntimeException ( e );
3635 }
3736 }
3837}
0 commit comments