Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod_name=TrueUUID
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GNU LGPL 3.0
# The mod version. See https://semver.org/
mod_version=1.0.4
mod_version=1.0.5
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/alini/trueuuid/Trueuuid.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void onConfigLoad(ModConfigEvent.Loading event) {
} else {
// =====MoJang网络连通性测试=====
try {
String testUrl = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=Mojang&serverId=test";
String testUrl = TrueuuidConfig.COMMON.mojangReverseProxy.get()+"/session/minecraft/hasJoined?username=Mojang&serverId=test";
java.net.URL url = new java.net.URL(testUrl);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static int cmdNomojangToggle(CommandSourceStack src) {

private static int mojangStatus(CommandSourceStack src) {
try {
String testUrl = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=Mojang&serverId=test";
String testUrl = TrueuuidConfig.COMMON.mojangReverseProxy.get()+"/session/minecraft/hasJoined?username=Mojang&serverId=test";
java.net.URL url = new java.net.URL(testUrl);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/cn/alini/trueuuid/config/TrueuuidConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static void register() {
public static boolean debug() { return COMMON.debug.get(); }
// 新增 nomojang 开关访问器
public static boolean nomojangEnabled() { return COMMON.nomojangEnabled.get(); }
public static String mojangReverseProxy() { return COMMON.mojangReverseProxy.get(); }

public static final class Common {
public final ModConfigSpec.LongValue timeoutMs;
Expand All @@ -54,6 +55,7 @@ public static final class Common {

// 新增 nomojang 配置
public final ModConfigSpec.BooleanValue nomojangEnabled;
public final ModConfigSpec.ConfigValue<String> mojangReverseProxy;

// 新增:策略相关
public final ModConfigSpec.BooleanValue knownPremiumDenyOffline;
Expand Down Expand Up @@ -92,6 +94,7 @@ public static final class Common {
// 新增:跳过 Mojang 会话认证(开启后不再通过 sessionserver 验证)
nomojangEnabled = b.comment("开启后关闭对 Mojang 会话服务的在线校验逻辑;同 IP 且近期有正版成功的名称按正版 UUID 处理,其余直接按离线进入处理。")
.define("nomojang.enabled", false);
mojangReverseProxy = b.comment("mojang的反代地址,专门为那些不想给服务器开代理的人使用,默认为mojang地址").define("mojangReverseProxy", "https://sessionserver.mojang.com");
b.pop();
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/alini/trueuuid/server/SessionCheck.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// java
package cn.alini.trueuuid.server;

import cn.alini.trueuuid.config.TrueuuidConfig;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

Expand Down Expand Up @@ -42,7 +43,7 @@ private static class Prop {
* 异步版本:不阻塞调用线程,返回 CompletableFuture\<Optional\<HasJoinedResult\>\>
*/
public static CompletableFuture<Optional<HasJoinedResult>> hasJoinedAsync(String username, String serverId, String ip) {
String url = "https://sessionserver.mojang.com/session/minecraft/hasJoined"
String url = TrueuuidConfig.COMMON.mojangReverseProxy.get()+"/session/minecraft/hasJoined"
+ "?username=" + URLEncoder.encode(username, StandardCharsets.UTF_8)
+ "&serverId=" + URLEncoder.encode(serverId, StandardCharsets.UTF_8);

Expand Down