Skip to content

Commit

Permalink
Remove CN
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed May 27, 2024
1 parent 37052e7 commit 8b15e4d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 45 deletions.
5 changes: 0 additions & 5 deletions src/main/java/com/mohistmc/network/MohistProxySelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public List<Proxy> select(URI uri) {
String defaultMsg = "[NetworkManager] Network protection and blocked by network rules!";
boolean intercept = false;

/*
if (uriString.startsWith("socket")) {
return this.defaultSelector.select(uri);
}
*/
if (intercepts.isEmpty()) {
intercepts = MohistConfig.getStringList0("mohist.networkmanager.intercept", new ArrayList<>());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package com.mohistmc.network.download;


import com.mohistmc.configuration.MohistConfigUtil;
import com.mohistmc.util.i18n.Message;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public enum DownloadSource {

MOHIST("https://maven.mohistmc.com/"),
CHINA("https://libraries.mohistmc.cn:25119/releases/"),
GITHUB("https://mohistmc.github.io/maven/");

public static final DownloadSource defaultSource = Message.isCN() ? CHINA : MOHIST;
public static final DownloadSource defaultSource = MOHIST;
final String url;

DownloadSource(String url) {
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/com/mohistmc/network/download/UpdateUtils.java
Original file line number Diff line number Diff line change
@@ -1,60 +1,26 @@
package com.mohistmc.network.download;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.mohistmc.MohistMC;
import com.mohistmc.util.JarTool;
import com.mohistmc.util.i18n.Message;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import static com.mohistmc.configuration.MohistConfigUtil.bMohist;
import static com.mohistmc.network.download.NetworkUtil.getConn;
import static com.mohistmc.network.download.NetworkUtil.getInput;

public class UpdateUtils {

private static int percentage = 0;

public static void versionCheck() {
System.out.println(Message.getString("update.check"));
System.out.println(Message.getString("update.stopcheck"));

try {
JsonElement root = new JsonParser().parse(new InputStreamReader(getInput("https://ci.codemc.io/job/MohistMC/job/Mohist-1.12.2/lastSuccessfulBuild/api/json")));

String jar_sha = MohistMC.getVersion();
String build_number = "1.12.2-" + root.getAsJsonObject().get("number").toString();
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(root.getAsJsonObject().get("timestamp").toString())));

if (jar_sha.equals(build_number))
System.out.println(Message.getFormatString("update.latest", new Object[]{jar_sha, build_number}));
else {
System.out.println(Message.getFormatString("update.detect", new Object[]{build_number, jar_sha, time}));
if (bMohist("check_update_auto_download")) {
downloadFile("https://ci.codemc.io/job/MohistMC/job/Mohist-1.12.2/lastSuccessfulBuild/artifact/projects/mohist/build/libs/mohist-" + build_number + "-server.jar", new File(getMohistJar().getName()));
restartServer(new ArrayList<>(Arrays.asList("java", "-jar", getMohistJar().getName())));
}
}
} catch (Throwable e) {
System.out.println(Message.getString("check.update.noci"));
}
}

public static void downloadFile(String URL, File f) throws Exception {
URLConnection conn = getConn(URL);
System.out.println(Message.getFormatString("file.download.start", new Object[]{f.getName(), getSize(conn.getContentLength())}));
Expand Down

0 comments on commit 8b15e4d

Please sign in to comment.