Skip to content

Commit 79a65b9

Browse files
committed
8.3.6 beta - potential fix for general config resets
1 parent 19250c7 commit 79a65b9

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

src/main/java/com/osiris/autoplug/client/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public static void main(String[] _args) {
268268
try {
269269
if (generalConfig.autoplug_system_tray.asBoolean()) {
270270
now = System.currentTimeMillis();
271-
new MainWindow();
271+
new MainWindow(generalConfig);
272272
AL.info("Started system-tray GUI, took " + (System.currentTimeMillis() - now) + "ms");
273273
}
274274
} catch (Exception e) {

src/main/java/com/osiris/autoplug/client/configs/BackupConfig.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public BackupConfig() throws IOException, DuplicateKeyException, YamlReaderExcep
121121
"./plugins/WorldBorder"
122122
);
123123
backup_upload = put(name, "upload", "enable").setDefValues("false").setComments(
124-
"Upload the newly generated backup zip to the FTPS/SFTP server.");
124+
"Upload the newly generated backup zip to the FTPS/SFTP server or Google Drive.");
125125
backup_upload_delete_on_complete = put(name, "upload", "delete-on-complete").setDefValues("false").setComments(
126126
"Deletes the newly generated backup zip, directly after uploading finishes.");
127127
backup_upload_host = put(name, "upload", "host").setComments(
@@ -144,7 +144,7 @@ public BackupConfig() throws IOException, DuplicateKeyException, YamlReaderExcep
144144
"3. When enabled, your browser will automatically open for authentication\n" +
145145
"4. After authentication, a refresh token is saved for future use\n" +
146146
"\n" +
147-
"Google-Drive Setup:\n" +
147+
"Google-Drive Setup (assuming your server is hosted on a regular PC, meaning your system has a GUI and web-browser):\n" +
148148
"1. Create a project in Google Cloud Console (or use an existing one) and enter its project_id below: https://developers.google.com/workspace/guides/create-project\n" +
149149
"2. Enable the Google Drive API: https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com\n" +
150150
"3. Create OAuth 2.0 login panel: https://console.cloud.google.com/auth/branding\n" +
@@ -155,6 +155,10 @@ public BackupConfig() throws IOException, DuplicateKeyException, YamlReaderExcep
155155
"8. Your browser will automatically open for authentication, or you can find the URL in the console and open it manually\n" +
156156
"9. After authentication, backups will be uploaded to your Google Drive\n" +
157157
"\n" +
158+
"Google-Drive Setup (assuming your server has no GUI and no web-browser, typical hosted linux server setup):\n" +
159+
"1. Ensure you have done all the steps above at least once until step 5\n" +
160+
"2. " +
161+
"\n" +
158162
"!!!IMPORTANT!!! This file contains sensitive data - do not share it with anyone!\n");
159163
backup_upload_alternatives_google_drive_enable = put(name, "upload", "alternatives", "google-drive", "enable").setDefValues("false");
160164
backup_upload_alternatives_google_drive_project_id = put(name, "upload", "alternatives", "google-drive", "project-id").setComments(

src/main/java/com/osiris/autoplug/client/configs/GeneralConfig.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public GeneralConfig(boolean save) throws IOException, DuplicateKeyException, Ya
5050
addSingletonConfigFileEventListener(e -> {
5151

5252
try {
53-
GD.determineTarget(this);
53+
// Saving this file in this event causes an infinite loop, thus don't
54+
//GD.determineTarget(this);
5455
} catch (Exception ex) {
5556
AL.warn(ex);
5657
}
@@ -66,7 +67,7 @@ public GeneralConfig(boolean save) throws IOException, DuplicateKeyException, Ya
6667
try {
6768
if (this.autoplug_system_tray.asBoolean()) {
6869
boolean firstStart = MainWindow.GET == null;
69-
new MainWindow();
70+
new MainWindow(this);
7071
if (firstStart) AL.info("Started system-tray GUI.");
7172
} else {
7273
boolean isRunning = MainWindow.GET != null;
@@ -110,7 +111,8 @@ public GeneralConfig(boolean save) throws IOException, DuplicateKeyException, Ya
110111
"If you have no GUI its recommended to install software like \"screen\" for virtual terminals and edit the script accordingly.");
111112
autoplug_target_software = put(name, "autoplug", "target-software").setComments(
112113
"Select the target software AutoPlug was installed on.",
113-
"Available options: MINECRAFT_CLIENT, MINECRAFT_SERVER, MINDUSTRY_SERVER, OTHER.");
114+
"Available options: MINECRAFT_CLIENT, MINECRAFT_SERVER, MINDUSTRY_SERVER, OTHER.",
115+
"If value changed -> restart AutoPlug.");
114116
autoplug_system_tray = put(name, "autoplug", "system-tray", "enable").setDefValues("false");
115117
autoplug_system_tray_theme = put(name, "autoplug", "system-tray", "theme").setDefValues("light")
116118
.setComments("Select between: light, dark and darcula.");

src/main/java/com/osiris/autoplug/client/ui/MainWindow.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ public class MainWindow extends JFrame {
3232
* There should always be only one instance of {@link MainWindow}.
3333
*/
3434
public static MainWindow GET = null;
35+
public static final Object lockUI = new Object();
3536
public TrayIcon trayIcon;
3637

37-
public MainWindow() throws Exception {
38-
if (GET != null) return;
39-
GET = this;
40-
initTheme();
38+
public MainWindow(GeneralConfig generalConfig) throws Exception {
39+
synchronized (lockUI){
40+
if (GET != null) {
41+
GET.close(); // There should only be one, thus stop old
42+
}
43+
GET = this;
44+
}
45+
initTheme(generalConfig);
4146
start();
4247
this.addKeyListener(new KeyListener() {
4348
@Override

src/main/java/com/osiris/autoplug/client/utils/GD.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.util.Arrays;
2223
import java.util.Scanner;
2324

2425
/**
@@ -64,7 +65,7 @@ public static void determineTarget(GeneralConfig generalConfig) throws YamlReade
6465
for (String comment : generalConfig.autoplug_target_software.getComments()) {
6566
AL.info(comment);
6667
}
67-
AL.info("Please enter a valid option and press enter:");
68+
AL.info("Please enter a valid option for target ("+ Arrays.stream(Target.values()).map(t -> " "+t.name()) +") and press enter:");
6869
target = new Scanner(System.in).nextLine();
6970
generalConfig.autoplug_target_software.setValues(target);
7071
generalConfig.save();

0 commit comments

Comments
 (0)