Skip to content

Commit f21650c

Browse files
Update checker URL for cleanroom (#500)
1 parent 1e661ed commit f21650c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/main/java/com/cleanroommc/common/CleanroomContainer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import net.minecraftforge.fml.common.LoadController;
66
import net.minecraftforge.fml.common.ModMetadata;
77

8+
import java.net.MalformedURLException;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
11+
import java.net.URL;
812
import java.util.Arrays;
913

1014
public class CleanroomContainer extends DummyModContainer {
@@ -20,10 +24,19 @@ public CleanroomContainer() {
2024
""";
2125
meta.version = CleanroomVersion.VERSION;
2226
meta.authorList = Arrays.asList("LexManos", "cpw", "fry", "Rongmario", "kappa_maintainer", "Li");
27+
meta.updateJSON = "https://download.cleanroommc.com/api/forge";
2328
}
2429

2530
@Override
2631
public boolean registerBus(EventBus bus, LoadController controller) {
2732
return true;
2833
}
34+
35+
@Override
36+
public URL getUpdateUrl() {
37+
try{
38+
return new URI("https://download.cleanroommc.com/api/forge").toURL();
39+
} catch (MalformedURLException | URISyntaxException ignored){}
40+
return null;
41+
}
2942
}

src/main/java/net/minecraftforge/common/ForgeVersion.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.net.HttpURLConnection;
2727
import java.net.URL;
2828
import java.net.URLConnection;
29+
import java.nio.charset.StandardCharsets;
2930
import java.util.ArrayList;
3031
import java.util.Collections;
3132
import java.util.HashMap;
@@ -216,9 +217,8 @@ private InputStream openUrlStream(URL url) throws IOException
216217
for (int redirects = 0; redirects < MAX_HTTP_REDIRECTS; redirects++)
217218
{
218219
URLConnection c = currentUrl.openConnection();
219-
if (c instanceof HttpURLConnection)
220+
if (c instanceof HttpURLConnection huc)
220221
{
221-
HttpURLConnection huc = (HttpURLConnection) c;
222222
huc.setInstanceFollowRedirects(false);
223223
int responseCode = huc.getResponseCode();
224224
if (responseCode >= 300 && responseCode <= 399)
@@ -250,7 +250,7 @@ private void process(ModContainer mod, URL url)
250250
ComparableVersion target = null;
251251

252252
InputStream con = openUrlStream(url);
253-
String data = new String(ByteStreams.toByteArray(con), "UTF-8");
253+
String data = new String(ByteStreams.toByteArray(con), StandardCharsets.UTF_8);
254254
con.close();
255255

256256
log.debug("[{}] Received version check data:\n{}", mod.getModId(), data);
@@ -375,7 +375,7 @@ public static Map<ModContainer, URL> gatherMods()
375375
return ret;
376376
}
377377

378-
private static Map<ModContainer, CheckResult> results = new ConcurrentHashMap<ModContainer, CheckResult>();
378+
private static final Map<ModContainer, CheckResult> results = new ConcurrentHashMap<>();
379379
private static final CheckResult PENDING_CHECK = new CheckResult(PENDING, null, null, null, null, null);
380380

381381
public static CheckResult getResult(ModContainer mod)

0 commit comments

Comments
 (0)