Skip to content

Commit 89e1e19

Browse files
committed
fix: add ServerUtil.java
1 parent 05be7d7 commit 89e1e19

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.lnlfly.util;
2+
3+
import com.lnlfly.config.ModConfig;
4+
5+
public class ServerUtil {
6+
public static String normalizeHost(String address) {
7+
if (address == null) return "";
8+
String value = address.trim();
9+
int colon = value.indexOf(':');
10+
if (colon > 0 && value.indexOf(']') < 0) {
11+
return value.substring(0, colon);
12+
}
13+
return value;
14+
}
15+
16+
public static boolean isTargetServer(String address) {
17+
String target = ModConfig.get().targetServerAddress;
18+
if (target == null) return false;
19+
20+
String targetHost = normalizeHost(target);
21+
String host = normalizeHost(address);
22+
return !targetHost.isEmpty() && targetHost.equalsIgnoreCase(host);
23+
}
24+
}

0 commit comments

Comments
 (0)