Skip to content
This repository was archived by the owner on Feb 10, 2022. It is now read-only.

Commit dc6fbdf

Browse files
committed
Update package names, sprinkle in some finals
Hopefully I didn't break it.
1 parent 6244e54 commit dc6fbdf

23 files changed

+133
-117
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.idea/
22
.gradle/
33
build/
4+
5+
.project
6+
.classpath
7+
.settings/

bootstrap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

bootstrap/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ dependencies {
1111

1212
jar {
1313
manifest {
14-
attributes("Main-Class": "net.ilexiconn.launcher.Bootstrap")
14+
attributes("Main-Class": "com.mcmoddev.launcher.Bootstrap")
1515
}
1616
}
1717

1818
build.dependsOn(shadowJar)
1919

2020
launch4j {
21-
mainClassName = "net.ilexiconn.launcher.Bootstrap"
21+
mainClassName = "com.mcmoddev.launcher.Bootstrap"
2222
icon = "C:/Users/iLexiconn/Git/mmd-launcher/bootstrap/src/main/resources/icon.ico"
2323
copyConfigurable = project.tasks.shadowJar.outputs.files
2424
jar = "lib/${project.tasks.shadowJar.archiveName}"

bootstrap/src/main/java/net/ilexiconn/launcher/Bootstrap.java renamed to bootstrap/src/main/java/com/mcmoddev/launcher/Bootstrap.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.ilexiconn.launcher;
1+
package com.mcmoddev.launcher;
22

33
import com.google.common.base.Charsets;
44
import com.google.common.hash.Hashing;
@@ -8,8 +8,9 @@
88
import com.google.gson.JsonObject;
99
import com.google.gson.JsonParser;
1010
import com.google.gson.reflect.TypeToken;
11-
import net.ilexiconn.launcher.version.Version;
12-
import net.ilexiconn.launcher.version.VersionAdapter;
11+
import com.mcmoddev.launcher.version.Version;
12+
import com.mcmoddev.launcher.version.VersionAdapter;
13+
1314
import org.apache.commons.io.FileUtils;
1415

1516
import java.io.*;
@@ -19,14 +20,14 @@
1920
import java.util.Map;
2021

2122
public class Bootstrap {
22-
public static final String URL = "http://pastebin.com/raw/kT55bi26";
23+
public static final String URL = "https://raw.githubusercontent.com/MinecraftModDevelopment/MMD-Launcher/gh-pages/update.json";
2324

2425
public File dataDir;
2526
public JsonParser jsonParser;
2627
public Gson gson;
2728

2829
public Version currentVersion;
29-
public String currentMD5;
30+
public String currentSHA256;
3031

3132
public File bootstrapFile;
3233
public File launcherFile;
@@ -38,8 +39,8 @@ public class Bootstrap {
3839
public String[] args;
3940

4041
public static void main(String[] args) {
41-
List<String> argumentList = Arrays.asList(args);
42-
Bootstrap bootstrap = new Bootstrap(argumentList.contains("--portable") || argumentList.contains("-p"));
42+
final List<String> argumentList = Arrays.asList(args);
43+
final Bootstrap bootstrap = new Bootstrap(argumentList.contains("--portable") || argumentList.contains("-p"));
4344
bootstrap.args = args;
4445

4546
try {
@@ -54,22 +55,22 @@ public Bootstrap(boolean portable) {
5455
this.jsonParser = new JsonParser();
5556
this.gson = new GsonBuilder().registerTypeAdapter(Version.class, new VersionAdapter()).setPrettyPrinting().create();
5657

57-
File bootstrapDir = new File(this.dataDir, "bootstrap");
58+
final File bootstrapDir = new File(this.dataDir, "bootstrap");
5859
this.bootstrapFile = new File(bootstrapDir, "bootstrap.json");
5960
this.launcherFile = new File(bootstrapDir, "launcher.jar");
6061

6162
if (bootstrapDir.exists()) {
6263
if (this.bootstrapFile.exists()) {
6364
try {
64-
JsonObject object = this.jsonParser.parse(new FileReader(this.bootstrapFile)).getAsJsonObject();
65+
final JsonObject object = this.jsonParser.parse(new FileReader(this.bootstrapFile)).getAsJsonObject();
6566
this.currentVersion = new Version(object.get("version").getAsString());
6667
} catch (FileNotFoundException e) {
6768
e.printStackTrace();
6869
}
6970
}
7071
if (this.launcherFile.exists()) {
7172
try {
72-
this.currentMD5 = Files.hash(this.launcherFile, Hashing.md5()).toString();
73+
this.currentSHA256 = Files.asByteSource(this.launcherFile).hash(Hashing.sha256()).toString();
7374
} catch (IOException e) {
7475
e.printStackTrace();
7576
}
@@ -84,7 +85,7 @@ public Bootstrap(boolean portable) {
8485
}
8586

8687
public void start() throws IOException {
87-
Map<Version, JsonObject> map = this.gson.fromJson(new InputStreamReader(new URL(Bootstrap.URL).openStream()), new TypeToken<Map<Version, JsonObject>>() {}.getType());
88+
final Map<Version, JsonObject> map = this.gson.fromJson(new InputStreamReader(new URL(Bootstrap.URL).openStream()), new TypeToken<Map<Version, JsonObject>>() {}.getType());
8889
for (Map.Entry<Version, JsonObject> entry : map.entrySet()) {
8990
int compare = entry.getKey().compareTo(this.currentVersion);
9091
if (compare > 0) {
@@ -98,8 +99,8 @@ public void start() throws IOException {
9899
this.newerURL = entry.getValue().get("url").getAsString();
99100
}
100101
} else if (compare == 0) {
101-
String actualMD5 = entry.getValue().get("md5").getAsString();
102-
if (!this.currentMD5.equals(actualMD5)) {
102+
final String actualSHA256 = entry.getValue().get("sha256").getAsString();
103+
if (!this.currentSHA256.equals(actualSHA256)) {
103104
this.newerVersion = entry.getKey();
104105
this.newerURL = entry.getValue().get("url").getAsString();
105106
}
@@ -115,9 +116,9 @@ public void start() throws IOException {
115116
}
116117
}
117118
this.progressbar.display(this.newerURL, this.launcherFile, () -> {
118-
JsonObject object = new JsonObject();
119+
final JsonObject object = new JsonObject();
119120
object.addProperty("version", Bootstrap.this.newerVersion.get());
120-
String json = Bootstrap.this.gson.toJson(object);
121+
final String json = Bootstrap.this.gson.toJson(object);
121122
try {
122123
FileUtils.writeStringToFile(Bootstrap.this.bootstrapFile, json, Charsets.UTF_8);
123124
} catch (IOException e) {
@@ -134,7 +135,7 @@ public void start() throws IOException {
134135
public void launch() {
135136
String[] arguments = {"java", "-jar", this.launcherFile.getAbsolutePath()};
136137
arguments = this.concat(arguments, this.args);
137-
ProcessBuilder process = new ProcessBuilder(arguments);
138+
final ProcessBuilder process = new ProcessBuilder(arguments);
138139
process.directory(this.dataDir);
139140
try {
140141
process.start();
@@ -144,22 +145,22 @@ public void launch() {
144145
}
145146

146147
public String[] concat(String[] a, String[] b) {
147-
int aLength = a.length;
148-
int bLength = b.length;
149-
String[] array = new String[aLength + bLength];
148+
final int aLength = a.length;
149+
final int bLength = b.length;
150+
final String[] array = new String[aLength + bLength];
150151
System.arraycopy(a, 0, array, 0, aLength);
151152
System.arraycopy(b, 0, array, aLength, bLength);
152153
return array;
153154
}
154155

155156
public File getDataFolder() {
156-
String osName = System.getProperty("os.name").toLowerCase();
157+
final String osName = System.getProperty("os.name").toLowerCase();
157158
if (osName.contains("win")) {
158-
return new File(System.getenv("APPDATA"), ".revival-launcher");
159+
return new File(System.getenv("APPDATA"), ".mmd-launcher");
159160
} else if (osName.contains("mac")) {
160-
return new File(System.getProperty("user.home"), "/Library/Application Support/revival-launcher");
161+
return new File(System.getProperty("user.home"), "/Library/Application Support/mmd-launcher");
161162
} else {
162-
return new File(System.getProperty("user.home"), ".revival-launcher");
163+
return new File(System.getProperty("user.home"), ".mmd-launcher");
163164
}
164165
}
165166
}

bootstrap/src/main/java/net/ilexiconn/launcher/ProgressBar.java renamed to bootstrap/src/main/java/com/mcmoddev/launcher/ProgressBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.ilexiconn.launcher;
1+
package com.mcmoddev.launcher;
22

33
import javax.swing.*;
44
import java.awt.*;

bootstrap/src/main/java/net/ilexiconn/launcher/version/Version.java renamed to bootstrap/src/main/java/com/mcmoddev/launcher/version/Version.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.ilexiconn.launcher.version;
1+
package com.mcmoddev.launcher.version;
22

33
public class Version implements Comparable<Version> {
44
private String version;
@@ -21,12 +21,12 @@ public int compareTo(Version version) {
2121
if (version == null) {
2222
return 1;
2323
}
24-
String[] thisParts = this.get().split("\\.");
25-
String[] otherParts = version.get().split("\\.");
26-
int length = Math.max(thisParts.length, otherParts.length);
24+
final String[] thisParts = this.get().split("\\.");
25+
final String[] otherParts = version.get().split("\\.");
26+
final int length = Math.max(thisParts.length, otherParts.length);
2727
for (int i = 0; i < length; i++) {
28-
int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0;
29-
int thatPart = i < otherParts.length ? Integer.parseInt(otherParts[i]) : 0;
28+
final int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0;
29+
final int thatPart = i < otherParts.length ? Integer.parseInt(otherParts[i]) : 0;
3030
if (thisPart < thatPart) {
3131
return -1;
3232
} else if (thisPart > thatPart) {

bootstrap/src/main/java/net/ilexiconn/launcher/version/VersionAdapter.java renamed to bootstrap/src/main/java/com/mcmoddev/launcher/version/VersionAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.ilexiconn.launcher.version;
1+
package com.mcmoddev.launcher.version;
22

33
import com.google.gson.TypeAdapter;
44
import com.google.gson.stream.JsonReader;

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
subprojects {
22
apply plugin: "java"
33

4-
group = "net.ilexiconn"
4+
group = "com.mcmoddev"
55
archivesBaseName = "launcher"
66
version = "0.1.1-develop"
77
sourceCompatibility = targetCompatibility = "1.8"

launcher/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

launcher/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies {
1515

1616
jar {
1717
manifest {
18-
attributes("Main-Class": "net.ilexiconn.launcher.Launcher")
18+
attributes("Main-Class": "com.mcmoddev.launcher.Launcher")
1919
}
2020
}
2121

launcher/src/main/java/net/ilexiconn/launcher/Launcher.java renamed to launcher/src/main/java/com/mcmoddev/launcher/Launcher.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
package net.ilexiconn.launcher;
1+
package com.mcmoddev.launcher;
22

33
import com.google.gson.*;
44
import com.google.gson.reflect.TypeToken;
5-
import net.ilexiconn.launcher.mod.Mod;
6-
import net.ilexiconn.launcher.mod.ModConfig;
7-
import net.ilexiconn.launcher.resource.ResourceLoader;
8-
import net.ilexiconn.launcher.resource.lang.Translator;
9-
import net.ilexiconn.launcher.ui.IProgressCallback;
10-
import net.ilexiconn.launcher.ui.LauncherFrame;
5+
import com.mcmoddev.launcher.mod.Mod;
6+
import com.mcmoddev.launcher.mod.ModConfig;
7+
import com.mcmoddev.launcher.resource.ResourceLoader;
8+
import com.mcmoddev.launcher.resource.lang.Translator;
9+
import com.mcmoddev.launcher.ui.IProgressCallback;
10+
import com.mcmoddev.launcher.ui.LauncherFrame;
11+
1112
import org.apache.commons.io.FileDeleteStrategy;
1213
import org.apache.commons.io.FileUtils;
1314
import uk.co.rx14.jmclaunchlib.LaunchSpec;
@@ -85,7 +86,7 @@ private void init(boolean portable) {
8586
}
8687

8788
if (this.cacheDir.exists()) {
88-
File authFile = new File(this.cacheDir, "auth.json");
89+
final File authFile = new File(this.cacheDir, "auth.json");
8990
if (authFile.exists()) {
9091
try {
9192
this.cache = new JsonParser().parse(new FileReader(authFile)).getAsJsonObject();
@@ -129,7 +130,7 @@ public void putIfNull(JsonObject config, String key, Object value) {
129130
} else if (value instanceof Integer) {
130131
config.addProperty(key, (Integer) value);
131132
} else if (value instanceof String[]) {
132-
JsonArray array = new JsonArray();
133+
final JsonArray array = new JsonArray();
133134
for (String s : (String[]) value) {
134135
array.add(s);
135136
}
@@ -158,7 +159,7 @@ public void startMinecraft(PasswordSupplier passwordSupplier, final IProgressCal
158159
return;
159160
}
160161

161-
Map<String, JsonObject> map = new Gson().fromJson(new InputStreamReader(new URL(this.config.get("url").getAsString()).openStream()), new TypeToken<Map<String, JsonObject>>() {}.getType());
162+
final Map<String, JsonObject> map = new Gson().fromJson(new InputStreamReader(new URL(this.config.get("url").getAsString()).openStream()), new TypeToken<Map<String, JsonObject>>() {}.getType());
162163
List<Mod> modList = map.entrySet().stream().map(entry -> new Mod(entry.getKey(), entry.getValue())).collect(Collectors.toList());
163164
if (!this.modsDir.exists()) {
164165
this.modsDir.mkdirs();
@@ -169,9 +170,9 @@ public void startMinecraft(PasswordSupplier passwordSupplier, final IProgressCal
169170
if (!this.configDir.exists()) {
170171
this.configDir.mkdirs();
171172
}
172-
File[] files = this.modsDir.listFiles();
173+
final File[] files = this.modsDir.listFiles();
173174
if (files != null) {
174-
List<String> modNames = modList.stream().map(Mod::getFileName).collect(Collectors.toList());
175+
final List<String> modNames = modList.stream().map(Mod::getFileName).collect(Collectors.toList());
175176
for (File file : files) {
176177
if (!file.isDirectory() && !modNames.contains(file.getName())) {
177178
System.out.println("Removing mod " + file.getName());
@@ -180,7 +181,7 @@ public void startMinecraft(PasswordSupplier passwordSupplier, final IProgressCal
180181
}
181182
}
182183
modList.removeIf(mod -> !mod.doDownload(new File(mod.getModType().getFile(), mod.getFileName())));
183-
Exception e = this.downloadMods(modList);
184+
final Exception e = this.downloadMods(modList);
184185
if (e != null) {
185186
this.frame.panel.username.setEnabled(true);
186187
this.frame.panel.password.setEnabled(true);
@@ -205,13 +206,13 @@ public void run() {
205206
}
206207
}.start();
207208

208-
LaunchSpec launchSpec = task.getSpec();
209+
final LaunchSpec launchSpec = task.getSpec();
209210
this.frame.panel.loadAvatar(launchSpec.getAuth().getSelectedProfile().getName());
210-
Process process = launchSpec.run(Paths.get(this.config.get("javaHome").getAsString(), "bin", OS.getCURRENT() == OS.WINDOWS ? "java.exe" : "java"));
211+
final Process process = launchSpec.run(Paths.get(this.config.get("javaHome").getAsString(), "bin", OS.getCURRENT() == OS.WINDOWS ? "java.exe" : "java"));
211212

212-
InputStream inputStream = process.getInputStream();
213-
InputStreamReader streamReader = new InputStreamReader(inputStream);
214-
BufferedReader bufferedReader = new BufferedReader(streamReader);
213+
final InputStream inputStream = process.getInputStream();
214+
final InputStreamReader streamReader = new InputStreamReader(inputStream);
215+
final BufferedReader bufferedReader = new BufferedReader(streamReader);
215216
String line;
216217
while ((line = bufferedReader.readLine()) != null) {
217218
System.out.println(line);
@@ -259,13 +260,13 @@ public Exception downloadMods(List<Mod> modList) {
259260
public Exception downloadFile(String string, File file) {
260261
try {
261262
this.frame.panel.currentProgress = 0;
262-
URL url = new URL(string);
263-
HttpURLConnection connection = (HttpURLConnection) (url.openConnection());
264-
long contentLength = connection.getContentLength();
265-
InputStream inputStream = new BufferedInputStream(connection.getInputStream());
266-
OutputStream outputStream = new FileOutputStream(file);
267-
OutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, 1024);
268-
byte[] data = new byte[1024];
263+
final URL url = new URL(string);
264+
final HttpURLConnection connection = (HttpURLConnection) (url.openConnection());
265+
final long contentLength = connection.getContentLength();
266+
final InputStream inputStream = new BufferedInputStream(connection.getInputStream());
267+
final OutputStream outputStream = new FileOutputStream(file);
268+
final OutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, 1024);
269+
final byte[] data = new byte[1024];
269270
long downloaded = 0;
270271
int i;
271272
while ((i = inputStream.read(data, 0, 1024)) >= 0) {
@@ -284,7 +285,7 @@ public Exception downloadFile(String string, File file) {
284285
}
285286

286287
public File getDataFolder() {
287-
String osName = System.getProperty("os.name").toLowerCase();
288+
final String osName = System.getProperty("os.name").toLowerCase();
288289
if (osName.contains("win")) {
289290
return new File(System.getenv("APPDATA"), ".mmd-launcher");
290291
} else if (osName.contains("mac")) {

launcher/src/main/java/net/ilexiconn/launcher/mod/Mod.java renamed to launcher/src/main/java/com/mcmoddev/launcher/mod/Mod.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.ilexiconn.launcher.mod;
1+
package com.mcmoddev.launcher.mod;
22

33
import com.google.common.hash.Hashing;
44
import com.google.common.io.Files;
@@ -13,7 +13,7 @@ public class Mod {
1313
private String name;
1414
private String fileName;
1515
private String url;
16-
private String md5;
16+
private String sha256;
1717
private ModType modType;
1818

1919
private boolean hasConfig;
@@ -23,12 +23,12 @@ public Mod(String name, JsonObject object) {
2323
this.name = name;
2424
this.fileName = object.get("file").getAsString();
2525
this.url = object.has("url") ? object.get("url").getAsString() : null;
26-
this.md5 = object.has("md5") ? object.get("md5").getAsString().toLowerCase(Locale.ENGLISH) : null;
26+
this.sha256 = object.has("sha256") ? object.get("sha256").getAsString().toLowerCase(Locale.ENGLISH) : null;
2727
this.modType = object.has("type") ? ModType.valueOf(object.get("type").getAsString().toUpperCase(Locale.ENGLISH)) : ModType.MOD;
2828

2929
this.hasConfig = object.has("config");
3030
if (this.hasConfig) {
31-
JsonArray array = object.get("config").getAsJsonArray();
31+
final JsonArray array = object.get("config").getAsJsonArray();
3232
this.configs = new ModConfig[array.size()];
3333
for (int i = 0; i < array.size(); i++) {
3434
this.configs[i] = new ModConfig(array.get(i).getAsJsonObject());
@@ -48,8 +48,8 @@ public String getURL() {
4848
return url;
4949
}
5050

51-
public String getMD5() {
52-
return md5;
51+
public String getSHA256() {
52+
return sha256;
5353
}
5454

5555
public ModType getModType() {
@@ -71,8 +71,8 @@ public boolean doDownload(File file) {
7171
return true;
7272
} else {
7373
try {
74-
String md5 = Files.hash(file, Hashing.md5()).toString();
75-
return this.getMD5() != null && !this.getMD5().equals(md5);
74+
final String obtained_sha256 = Files.asByteSource(file).hash(Hashing.sha256()).toString();
75+
return this.getSHA256() != null && !this.getSHA256().equals(obtained_sha256);
7676
} catch (IOException e) {
7777
e.printStackTrace();
7878
return true;

0 commit comments

Comments
 (0)