mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 23:59:21 -04:00
Fix Forge installer for 1.7.10
This commit is contained in:
parent
85b3a42dd3
commit
09be377919
Binary file not shown.
@ -1 +1 @@
|
|||||||
1687691695288
|
1687971356220
|
@ -11,6 +11,7 @@ import java.awt.event.WindowEvent;
|
|||||||
import java.lang.instrument.Instrumentation;
|
import java.lang.instrument.Instrumentation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Timer;
|
||||||
|
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
@ -20,6 +21,8 @@ public class Agent implements AWTEventListener {
|
|||||||
private boolean forgeWindowHandled = false;
|
private boolean forgeWindowHandled = false;
|
||||||
private final boolean suppressProfileCreation;
|
private final boolean suppressProfileCreation;
|
||||||
|
|
||||||
|
private final Timer componentTimer = new Timer();
|
||||||
|
|
||||||
public Agent(boolean ps) {
|
public Agent(boolean ps) {
|
||||||
this.suppressProfileCreation = ps;
|
this.suppressProfileCreation = ps;
|
||||||
}
|
}
|
||||||
@ -30,15 +33,20 @@ public class Agent implements AWTEventListener {
|
|||||||
Window window = windowEvent.getWindow();
|
Window window = windowEvent.getWindow();
|
||||||
if(windowEvent.getID() == WindowEvent.WINDOW_OPENED) {
|
if(windowEvent.getID() == WindowEvent.WINDOW_OPENED) {
|
||||||
if(!forgeWindowHandled) { // false at startup, so we will handle the first window as the Forge one
|
if(!forgeWindowHandled) { // false at startup, so we will handle the first window as the Forge one
|
||||||
handleForgeWindow(window);
|
forgeWindowHandled = handleForgeWindow(window);
|
||||||
forgeWindowHandled = true;
|
if(forgeWindowHandled) {
|
||||||
|
componentTimer.cancel();
|
||||||
|
componentTimer.purge();
|
||||||
|
}else{
|
||||||
|
componentTimer.schedule(new ComponentTimeoutTask(), 30000);
|
||||||
|
}
|
||||||
}else if(window instanceof JDialog) { // expecting a new dialog
|
}else if(window instanceof JDialog) { // expecting a new dialog
|
||||||
handleDialog(window);
|
handleDialog(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleForgeWindow(Window window) {
|
public boolean handleForgeWindow(Window window) {
|
||||||
List<Component> components = new ArrayList<>();
|
List<Component> components = new ArrayList<>();
|
||||||
insertAllComponents(components, window, new MainWindowFilter());
|
insertAllComponents(components, window, new MainWindowFilter());
|
||||||
AbstractButton okButton = null;
|
AbstractButton okButton = null;
|
||||||
@ -56,11 +64,13 @@ public class Agent implements AWTEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(okButton == null) {
|
if(okButton == null) {
|
||||||
System.out.println("Failed to set all the UI components.");
|
System.out.println("Failed to set all the UI components, wil try again in the next window");
|
||||||
System.exit(17);
|
System.exit(17);
|
||||||
|
return false;
|
||||||
}else{
|
}else{
|
||||||
ProfileFixer.storeProfile();
|
ProfileFixer.storeProfile();
|
||||||
EventQueue.invokeLater(okButton::doClick); // do that after forge actually builds its window, otherwise we set the path too fast
|
EventQueue.invokeLater(okButton::doClick); // do that after forge actually builds its window, otherwise we set the path too fast
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +80,7 @@ public class Agent implements AWTEventListener {
|
|||||||
if(components.size() == 1) {
|
if(components.size() == 1) {
|
||||||
// another common trait of them - they only have one option pane in them,
|
// another common trait of them - they only have one option pane in them,
|
||||||
// so we can discard the rest of the dialog structure
|
// so we can discard the rest of the dialog structure
|
||||||
|
// also allows us to discard dialogs with progress bars which older installers use
|
||||||
JOptionPane optionPane = (JOptionPane) components.get(0);
|
JOptionPane optionPane = (JOptionPane) components.get(0);
|
||||||
if(optionPane.getMessageType() == JOptionPane.INFORMATION_MESSAGE) { // forge doesn't emit information messages for other reasons yet
|
if(optionPane.getMessageType() == JOptionPane.INFORMATION_MESSAGE) { // forge doesn't emit information messages for other reasons yet
|
||||||
System.out.println("The install was successful!");
|
System.out.println("The install was successful!");
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package git.artdeell.forgeinstaller;
|
||||||
|
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
public class ComponentTimeoutTask extends TimerTask {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.out.println("Initialization timed out!");
|
||||||
|
System.exit(17);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import java.awt.*;
|
|||||||
public class DialogFilter implements ComponentFilter{
|
public class DialogFilter implements ComponentFilter{
|
||||||
@Override
|
@Override
|
||||||
public boolean checkComponent(Component component) {
|
public boolean checkComponent(Component component) {
|
||||||
return component instanceof JOptionPane;
|
return component instanceof JOptionPane
|
||||||
|
|| component instanceof JProgressBar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user