diff --git a/pom.xml b/pom.xml
index 13b887e7..8062061d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
com.osiris.autoplug.client
autoplug-client
- 7.2.22
+ 7.2.23
jar
AutoPlug-Client
diff --git a/src/main/java/com/osiris/autoplug/client/Server.java b/src/main/java/com/osiris/autoplug/client/Server.java
index 55e921b1..8d0f2058 100644
--- a/src/main/java/com/osiris/autoplug/client/Server.java
+++ b/src/main/java/com/osiris/autoplug/client/Server.java
@@ -311,7 +311,7 @@ private static void createProcess() throws Exception {
ansi.a(line).reset();
}
System.out.println(ansi);
- ConAutoPlugConsoleSend.send("" + ansi);
+ ConAutoPlugConsoleSend.send(String.valueOf(ansi));
} catch (Exception e) {
AL.warn(e);
}
diff --git a/src/main/java/com/osiris/autoplug/client/configs/SharedFilesConfig.java b/src/main/java/com/osiris/autoplug/client/configs/SharedFilesConfig.java
index 6f08d5e8..67bdaf6b 100644
--- a/src/main/java/com/osiris/autoplug/client/configs/SharedFilesConfig.java
+++ b/src/main/java/com/osiris/autoplug/client/configs/SharedFilesConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -42,13 +42,12 @@ public SharedFilesConfig() throws IOException, DuplicateKeyException, YamlReader
enable = put(name, "enable").setDefValues("false").setComments("Enable/Disable sharing folders from this server to other servers.\n" +
"NOTE: CHANGES TO THIS FILE REQUIRE A AUTOPLUG RESTART TO TAKE AFFECT!\n");
+ //TODO "More control is in TODO.\n" +
copy_from = put(name, "copy-from").setDefValues("./plugins", "./server.jar")
.setComments("List of folders to watch. Once a file event happens, that event/change gets shared/sent to the servers in the 'send-to' list.\n" +
"All folders must be sub-folders of the server root and thus start with './' (the servers root directory).\n" +
"If you want to watch all files from your server simply add './' below.\n" +
- "Note that sub-folders of the added folders below are also watched. \n" +
- //TODO "More control is in TODO.\n" +
- ""
+ "Note that sub-folders of the added folders below are also watched. \n"
);
send_to = put(name, "send-to").addDefValues("C:\\User\\Peter\\servers\\my-second-server")
diff --git a/src/main/java/com/osiris/autoplug/client/configs/UpdaterConfig.java b/src/main/java/com/osiris/autoplug/client/configs/UpdaterConfig.java
index 531c8078..f8a1cdf6 100644
--- a/src/main/java/com/osiris/autoplug/client/configs/UpdaterConfig.java
+++ b/src/main/java/com/osiris/autoplug/client/configs/UpdaterConfig.java
@@ -141,7 +141,8 @@ public UpdaterConfig() throws IOException, DuplicateKeyException, YamlReaderExce
"- Any Steam game (enter the app-id below, go to https://steamdb.info/ and search for: \" server\" to find the app-id)\n" +
"Note: If you change this, also reset the \"build-id\" to 0 to guarantee correct update-detection.");
server_steamcmd_login = put(name, "server-updater", "steam-cmd-login")
- .setComments("Some games require you to be logged in. Add your username and password, separated by a space below ( ).");
+ .setComments("Some games require you to be logged in. Add your username and password, separated by a space below ( ).",
+ "Note that SteamGuard must be disabled.");
server_version = put(name, "server-updater", "version").setComments(
"Select the servers' version. A list of supported version can be found in the links below:\n" +
"- Minecraft versions: https://papermc.io/api/v2/projects/paper | https://papermc.io/api/v2/projects/waterfall | https://papermc.io/api/v2/projects/travertine | https://papermc.io/api/v2/projects/velocity | https://purpur.pl3x.net/downloads | https://fabricmc.net/use/installer\n" +
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/java/TaskJavaUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/java/TaskJavaUpdater.java
index fa0f38b3..9ce92741 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/java/TaskJavaUpdater.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/java/TaskJavaUpdater.java
@@ -280,7 +280,7 @@ else if (actualOsType.contains("sunos"))
archiver.extract(download.getNewCacheDest(), final_dir_dest);
setStatus("Java update was installed successfully (" + currentBuildId + " -> " + latestBuildId + ")!");
- updaterConfig.java_updater_build_id.setValues("" + latestBuildId);
+ updaterConfig.java_updater_build_id.setValues(String.valueOf(latestBuildId));
updaterConfig.save();
finish(true);
} else {
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
index bebe3351..d13d4056 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/TaskModsUpdater.java
@@ -329,7 +329,7 @@ else if (code == 3)
matchingResult.setResultCode((byte) 6);
YamlSection jenkinsBuildId = modsConfig.get(
modsConfigName, download.getPlName(), "alternatives", "jenkins", "build-id");
- jenkinsBuildId.setValues("" + download.searchResult.jenkinsId);
+ jenkinsBuildId.setValues(String.valueOf(download.searchResult.jenkinsId));
YamlSection version = modsConfig.get(
modsConfigName, download.getPlName(), "version");
version.setValues(download.searchResult.getLatestVersion());
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java
index f014e4ff..562fef25 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java
@@ -187,9 +187,9 @@ else if (e.getHttpErrorCode() == 404) {
// The plugin devs can add their spigot/bukkit ids to their plugin.yml files
if (installedPlugin.getSpigotId() != 0 && spigotId.asString() != null && spigotId.asInt() == 0) // Don't update the value, if the user has already set it
- spigotId.setValues("" + installedPlugin.getSpigotId());
+ spigotId.setValues(String.valueOf(installedPlugin.getSpigotId()));
if (installedPlugin.getBukkitId() != 0 && bukkitId.asString() != null && bukkitId.asInt() == 0)
- bukkitId.setValues("" + installedPlugin.getBukkitId());
+ bukkitId.setValues(String.valueOf(installedPlugin.getBukkitId()));
// Fetch missing details from the AutoPlug-Web database
if (isPremiumServer) {
@@ -448,7 +448,7 @@ else if (code == 3)
matchingResult.setResultCode((byte) 6);
YamlSection jenkinsBuildId = pluginsConfig.get(
pluginsConfigName, finishedDownloadTask.getPlName(), "alternatives", "jenkins", "build-id");
- jenkinsBuildId.setValues("" + finishedDownloadTask.searchResult.jenkinsId);
+ jenkinsBuildId.setValues(String.valueOf(finishedDownloadTask.searchResult.jenkinsId));
YamlSection version = pluginsConfig.get(
pluginsConfigName, finishedDownloadTask.getPlName(), "version");
version.setValues(finishedDownloadTask.searchResult.getLatestVersion());
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/JenkinsSearch.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/JenkinsSearch.java
index b2890c84..1c414f85 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/JenkinsSearch.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/JenkinsSearch.java
@@ -31,7 +31,7 @@ public SearchResult search(String project_url, String providedArtifactName, int
JsonObject json_project = Json.getAsObject(project_url + (project_url.endsWith("/") ? "" : "/") + "api/json");
JsonObject json_last_successful_build = json_project.get("lastSuccessfulBuild").getAsJsonObject();
latest_build_id = json_last_successful_build.get("number").getAsInt();
- latestVersion = "" + latest_build_id;
+ latestVersion = String.valueOf(latest_build_id);
if (latest_build_id > build_id) {
resultCode = 1;
String buildUrl = json_last_successful_build.get("url").getAsString();
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
index 5cd35314..537eb280 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/bukkit/BukkitSearchById.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -56,7 +56,7 @@ public SearchResult search(MinecraftPlugin plugin) {
if (new UtilsVersion().compare(plugin.getVersion(), latest)) code = 1;
AL.debug(this.getClass(), "[" + plugin.getName() + "] Finished check with results: code:" + code + " latest:" + latest + " downloadURL:" + downloadUrl + " type:" + downloadType + " ");
- SearchResult result = new SearchResult(plugin, code, latest, downloadUrl, downloadType, null, "" + bukkitId, false);
+ SearchResult result = new SearchResult(plugin, code, latest, downloadUrl, downloadType, null, String.valueOf(bukkitId), false);
result.setException(exception);
return result;
}
diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
index 301f8b47..7a581ff1 100644
--- a/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
+++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/search/spigot/SpigotSearchById.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -54,7 +54,7 @@ public SearchResult search(MinecraftPlugin plugin) {
}
AL.debug(this.getClass(), "[" + plugin.getName() + "] Finished check with results: code:" + code + " latest:" + latest + " downloadURL:" + downloadUrl + " type:" + type + " ");
- SearchResult result = new SearchResult(plugin, code, latest, downloadUrl, type, "" + spigotId, null, isPremium);
+ SearchResult result = new SearchResult(plugin, code, latest, downloadUrl, type, String.valueOf(spigotId), null, isPremium);
result.setException(exception);
return result;
}
diff --git a/src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java b/src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java
index f769e032..9c971e52 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java
@@ -9,10 +9,8 @@
package com.osiris.autoplug.client.utils;
import com.osiris.autoplug.client.configs.UpdaterConfig;
-import com.osiris.autoplug.client.console.ThreadUserInput;
import com.osiris.autoplug.client.tasks.updater.TaskDownload;
import com.osiris.autoplug.client.utils.io.AsyncReader;
-import com.osiris.autoplug.client.utils.tasks.MyBThreadManager;
import com.osiris.autoplug.client.utils.terminal.AsyncTerminal;
import com.osiris.betterthread.BThreadManager;
import com.osiris.dyml.exceptions.*;
@@ -29,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import static com.osiris.jprocesses2.util.OS.isMac;
@@ -42,6 +39,7 @@ public class SteamCMD {
private final String steamcmdExtension = isWindows ? ".exe" : ".sh";
private final String steamcmdExecutable = "steamcmd" + steamcmdExtension;
// removed "{APP} validate" because it takes ages, doesn't work?
+ private final String steamcmdCommand = "+login {LOGIN} +force_install_dir \"{DESTINATION}\" +app_update {APP} +quit";
private final String steamcmdUrl = "https://steamcdn-a.akamaihd.net/client/installer/" + steamcmdArchive;
public Map errorResolutions = new HashMap() {{
put("Invalid platform", "This server does not support this OS; nothing we can do about it.");
@@ -126,14 +124,11 @@ public boolean installOrUpdateServer(String appId, Consumer onLog, Consu
List logErrLines = new ArrayList<>();
AtomicBoolean isFinished = new AtomicBoolean(false);
AtomicBoolean isSuccess = new AtomicBoolean(true);
- AtomicBoolean isLoginSuccess = new AtomicBoolean(false);
// Doesn't work when directly executing via ProcessBuilder thats why we execute it from an
// actual terminal
AsyncTerminal terminal = new AsyncTerminal(destDir, line -> { // Without a reader it seems to never finish
onLog.accept(line);
logLines.add(line);
- if (line.toLowerCase().contains("logged in"))
- isLoginSuccess.set(true);
if (line.toLowerCase().startsWith("Success! App".toLowerCase()))
isFinished.set(true);
if (line.toLowerCase().startsWith("ERROR!".toLowerCase())) // Case actually changes without reason?!
@@ -145,46 +140,10 @@ public boolean installOrUpdateServer(String appId, Consumer onLog, Consu
onLogErr.accept(line);
logErrLines.add(line);
},
- destExe.getAbsolutePath());
- Thread.sleep(5000);
- // private final String steamcmdCommand = "+login {LOGIN} +force_install_dir \"{DESTINATION}\" +app_update {APP} +quit";
- while (!isLoginSuccess.get()) {
- terminal.sendCommands("login " + login);
- Thread.sleep(10000);
- if (isLoginSuccess.get()) break;
- try {
- MyBThreadManager.lastCreatedPrinter.get().interrupt();
- } catch (Exception e) {
- }
- AL.info("Paused task printing, login into Steam timed out (10 seconds).");
- AL.info("Steam Guard key seems to be needed (check your email)!");
- AL.info("Insert it below and press enter:");
- AtomicReference steamGuardKey = new AtomicReference<>();
- Consumer code = steamGuardKey::set;
- ThreadUserInput.onReadLine.add(code);
- while (steamGuardKey.get() == null) Thread.sleep(100);
- String key = steamGuardKey.get();
- AL.info("Steam Guard key " + key + " will be provided to SteamCMD...");
- terminal.sendCommands(key);
- Thread.sleep(10000);
- ThreadUserInput.onReadLine.remove(code);
- if (isLoginSuccess.get()) {
- AL.info("Success! Continuing task printing!");
- try {
- new Thread(() -> {
- MyBThreadManager.lastCreatedPrinter.get().run(); // Since we cannot start a stopped thread again
- }).start();
- } catch (Exception e) {
- AL.warn(e);
- }
- break;
- } else {
- AL.info("Failed! Please try again.");
- }
- }
- terminal.sendCommands("force_install_dir \"" + gameInstallDir.getAbsolutePath() + "\"",
- "app_update " + appId,
- "quit");
+ destExe.getAbsolutePath() + " " + steamcmdCommand
+ .replace("{LOGIN}", login)
+ .replace("{DESTINATION}", gameInstallDir.getAbsolutePath())
+ .replace("{APP}", appId));
Thread thread = new Thread(() -> {
terminal.process.destroy();
@@ -206,4 +165,4 @@ public String getResolutionForError(String error) {
return "Unknown. :(";
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/osiris/autoplug/client/utils/UtilsNative.java b/src/main/java/com/osiris/autoplug/client/utils/UtilsNative.java
index 568ecdde..e5b556ad 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/UtilsNative.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/UtilsNative.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Osiris-Team.
+ * Copyright (c) 2022-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -47,22 +47,19 @@ public void register(File jar) throws IOException, InterruptedException {
startScript.getParentFile().mkdirs();
startScript.createNewFile();
}
- String scriptContent = "" +
- (OSUtils.IS_WINDOWS ? "@echo off\n" : "") +
+ String scriptContent = (OSUtils.IS_WINDOWS ? "@echo off\n" : "") +
"echo Starting AutoPlug-Client..." +
"echo No need to worry about this window, its just AutoPlug starting automatically in the background.\n" +
"echo It will disappear in 10 seconds, then you should be able to access the terminal over the system-tray.\n" +
"echo To abort enter CTRL+C or close this window.\n";
if (OSUtils.IS_WINDOWS) {
- scriptContent += "" +
- "cd /d \"" + jar.getParentFile().getAbsolutePath() + "\"\n" +
+ scriptContent += "cd /d \"" + jar.getParentFile().getAbsolutePath() + "\"\n" +
"cd\n" +
"timeout /t 10 /nobreak\n" +
"start \"\" javaw -jar \"" + jar.getAbsolutePath() + "\"\n" // "javaw" to start without terminal, "start" to start async and be able to exit this terminal
;
} else {
- scriptContent += "" +
- "sleep 10\n" +
+ scriptContent += "sleep 10\n" +
"cdWorkingDir () {\n" + // cd executed in a function to avoid sub-shell creation and have correct cd command execution
" cd \"" + jar.getParentFile().getAbsolutePath() + "\"\n" +
"}\n" +
diff --git a/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java b/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
index c3625efe..40e600c8 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/UtilsVersion.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -30,8 +30,8 @@ public boolean compare(@Nullable String currentVersion, @Nullable String latestV
Objects.requireNonNull(latestVersion);
// First duplicate the strings so the original ones don't get altered
- String currentVersionDUPLICATE = "" + currentVersion;
- String latestVersionDUPLICATE = "" + latestVersion;
+ String currentVersionDUPLICATE = currentVersion;
+ String latestVersionDUPLICATE = latestVersion;
// Remove left and right spaces
currentVersionDUPLICATE = currentVersionDUPLICATE.trim();
diff --git a/src/main/java/com/osiris/autoplug/client/utils/io/UFDataOut.java b/src/main/java/com/osiris/autoplug/client/utils/io/UFDataOut.java
index 0a267e39..07e822d6 100644
--- a/src/main/java/com/osiris/autoplug/client/utils/io/UFDataOut.java
+++ b/src/main/java/com/osiris/autoplug/client/utils/io/UFDataOut.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Osiris-Team.
+ * Copyright (c) 2021-2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
@@ -52,22 +52,22 @@ public void writeFile(File file) throws IOException {
}
public void writeByte(byte val) throws IOException {
- writeLine("" + val);
+ writeLine(String.valueOf(val));
}
public void writeShort(short val) throws IOException {
- writeLine("" + val);
+ writeLine(String.valueOf(val));
}
public void writeInt(int val) throws IOException {
- writeLine("" + val);
+ writeLine(String.valueOf(val));
}
public void writeLong(long val) throws IOException {
- writeLine("" + val);
+ writeLine(String.valueOf(val));
}
public void writeFloat(float val) throws IOException {
- writeLine("" + val);
+ writeLine(String.valueOf(val));
}
}