Skip to content

Commit

Permalink
7.2.23
Browse files Browse the repository at this point in the history
Revert and cleanup
  • Loading branch information
Osiris-Team committed May 14, 2023
1 parent 78caa00 commit b9efe54
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<groupId>com.osiris.autoplug.client</groupId>
<artifactId>autoplug-client</artifactId>
<version>7.2.22</version>
<version>7.2.23</version>
<packaging>jar</packaging>

<name>AutoPlug-Client</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/osiris/autoplug/client/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: \"<game-name> 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 (<username> <password>).");
.setComments("Some games require you to be logged in. Add your username and password, separated by a space below (<username> <password>).",
"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" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
53 changes: 6 additions & 47 deletions src/main/java/com/osiris/autoplug/client/utils/SteamCMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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;
Expand All @@ -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<String, String> errorResolutions = new HashMap<String, String>() {{
put("Invalid platform", "This server does not support this OS; nothing we can do about it.");
Expand Down Expand Up @@ -126,14 +124,11 @@ public boolean installOrUpdateServer(String appId, Consumer<String> onLog, Consu
List<String> 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?!
Expand All @@ -145,46 +140,10 @@ public boolean installOrUpdateServer(String appId, Consumer<String> 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<String> steamGuardKey = new AtomicReference<>();
Consumer<String> 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();
Expand All @@ -206,4 +165,4 @@ public String getResolutionForError(String error) {
return "Unknown. :(";
}

}
}
11 changes: 4 additions & 7 deletions src/main/java/com/osiris/autoplug/client/utils/UtilsNative.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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" +
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/osiris/autoplug/client/utils/io/UFDataOut.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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));
}
}

0 comments on commit b9efe54

Please sign in to comment.