-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
180 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/shanebeestudios/mcdeob/app/listener/StartButtonListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/main/java/com/shanebeestudios/mcdeob/version/Version.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.shanebeestudios.mcdeob.version; | ||
|
||
import com.shanebeestudios.mcdeob.util.Util; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Locale; | ||
|
||
public class Version { | ||
|
||
private final String version; | ||
private final ReleaseType releaseType; | ||
private final String url; | ||
private final boolean searge; | ||
|
||
private Type type; | ||
private String jarURL; | ||
private String mapURL; | ||
|
||
public Version(String version, ReleaseType releaseType, String url, boolean searge) { | ||
this.version = version; | ||
this.releaseType = releaseType; | ||
this.url = url; | ||
this.searge = searge; | ||
} | ||
|
||
public boolean prepareVersion() { | ||
JSONObject versionInfo = Util.getJsonFromURL(this.url); | ||
JSONObject downloads = versionInfo.getJSONObject("downloads"); | ||
if (downloads.has("server_mappings")) { | ||
String typeName = this.type.getName(); | ||
this.jarURL = downloads.getJSONObject(typeName).getString("url"); | ||
this.mapURL = downloads.getJSONObject(typeName + "_mappings").getString("url"); | ||
return true; | ||
} else if (this.searge) { | ||
String typeName = this.type.getName(); | ||
this.jarURL = downloads.getJSONObject(typeName).getString("url"); | ||
this.mapURL = String.format("https://raw.githubusercontent.com/ShaneBeeStudios/Mappings/refs/heads/main/mappings/mappings_%s_%s.txt", typeName, this.version); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public String getVersion() { | ||
return this.version; | ||
} | ||
|
||
public ReleaseType getReleaseType() { | ||
return this.releaseType; | ||
} | ||
|
||
public Type getType() { | ||
return this.type; | ||
} | ||
|
||
public void setType(Type type) { | ||
this.type = type; | ||
} | ||
|
||
public String getJarURL() { | ||
return this.jarURL; | ||
} | ||
|
||
public String getMapURL() { | ||
return this.mapURL; | ||
} | ||
|
||
public boolean isSearge() { | ||
return this.searge; | ||
} | ||
|
||
public enum Type { | ||
SERVER, | ||
CLIENT; | ||
|
||
public String getName() { | ||
return name().toLowerCase(Locale.ROOT); | ||
} | ||
} | ||
|
||
public enum ReleaseType { | ||
RELEASE, | ||
SNAPSHOT; | ||
|
||
public String getName() { | ||
return name().toLowerCase(Locale.ROOT); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.version; | ||
} | ||
|
||
} |
Oops, something went wrong.