Skip to content

Commit

Permalink
Added rudimentary check for a post-1.5.2 client.
Browse files Browse the repository at this point in the history
Also fixed a compile issue with strMCServerURL not being declared.
  • Loading branch information
oldmud0 committed Apr 18, 2015
1 parent 70ce19c commit 0a3d167
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Source/YAMS-Library/Functions/AutoUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static class AutoUpdate

//Minecraft URLs
public static string strMCClientURL = "https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft.jar";
public static string strMCServerURL;
public static string strMCVersionFile = "https://s3.amazonaws.com/Minecraft.Download/versions/versions.json";

//YAMS URLs
Expand Down Expand Up @@ -76,7 +77,7 @@ public static void CheckUpdates(bool bolForce = false, bool bolManual = false)
JObject mojangVers = JObject.Parse(jsonMojang);
string releaseVer = (string)mojangVers["latest"]["release"];
string snapshotVer = (string)mojangVers["latest"]["snapshot"];
string strMCServerURL = "https://s3.amazonaws.com/Minecraft.Download/versions/" + releaseVer + "/minecraft_server." + releaseVer + ".jar";
strMCServerURL = "https://s3.amazonaws.com/Minecraft.Download/versions/" + releaseVer + "/minecraft_server." + releaseVer + ".jar";
string strMCPreServerURL = "https://s3.amazonaws.com/Minecraft.Download/versions/" + snapshotVer + "/minecraft_server." + snapshotVer + ".jar";

if (bolForce)
Expand Down
23 changes: 19 additions & 4 deletions Source/YAMS-Library/Functions/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,39 @@ public static bool HasJDK()

}

/// <summary>
/// Looks for a working Minecraft client in any given root folder. Useful for custom paths.
/// This works only with the vanilla launcher.
/// </summary>
/// <param name="root">the path to the .minecraft folder</param>
/// <returns>boolean indicating if the minecraft client is in the specified folder</returns>
public static bool HasMCClient(string root)
{
//minecraft.jar is deprecated, but possibly working
if (File.Exists(Path.Combine(root, @"bin\minecraft.jar"))) return true;

//If there is a versions folder, assume that there is a jar file in one of the folders.
if (Directory.Exists(Path.Combine(root, @"versions\")) && Directory.GetDirectories(Path.Combine(root, @"versions\")).Length != 0) return true;

return false;
}

/// <summary>
/// Looks for the Minecraft client in the system user's profile, the service runs as LOCAL SYSTEM, so for
/// some of the third party apps we need to see if it is in this profile too
/// </summary>
/// <returns>boolean indicating if the minecraft client is in the SYSTEM account's AppData</returns>
public static bool HasMCClientSystem()
{
if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"config\systemprofile\AppData\Roaming\.minecraft\bin\minecraft.jar"))) return true;
else return false;
return HasMCClient(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"config\systemprofile\AppData\Roaming\.minecraft\"));
}
/// <summary>
/// Checks if the Minecraft client is installed locally
/// </summary>
/// <returns>boolean indicating if the Minecraft jar is in the local user's AppData</returns>
public static bool HasMCClientLocal()
{
if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @".minecraft\bin\minecraft.jar"))) return true;
else return false;
return HasMCClient(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @".minecraft\"));
}
public static void CopyMCClient()
{
Expand Down

0 comments on commit 0a3d167

Please sign in to comment.