修复封禁广播Long拆箱NPE + syncBans/syncAdmins改POST避免URL超长

- handleBanCommand中long expireMs→Long expireMs,避免null拆箱异常
- syncBans/syncAdmins从httpGet改为httpPost,防止55条封禁数据URL过长
- sync.php已部署含sync_bans/sync_admins case的版本到线上
This commit is contained in:
2026-07-13 00:35:09 +08:00
parent c0ab91edba
commit e7402985d5
2 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -2919,7 +2919,7 @@ public class Main extends JavaPlugin
String reason = entry.getReason() != null ? entry.getReason() : "已被服务器封禁";
String source = entry.getSource() != null ? entry.getSource() : "Server";
java.util.Date expireDate = entry.getExpiration();
long expireMs = expireDate != null ? expireDate.getTime() : null;
Long expireMs = expireDate != null ? expireDate.getTime() : null;
broadcastBanWarning(target, org.bukkit.BanList.Type.NAME, reason, expireMs, source);
} else {
// IP封禁:target可能是玩家名或IP,尝试解析为IP
@@ -2934,7 +2934,7 @@ public class Main extends JavaPlugin
String reason = entry.getReason() != null ? entry.getReason() : "已被服务器封禁";
String source = entry.getSource() != null ? entry.getSource() : "Server";
java.util.Date expireDate = entry.getExpiration();
long expireMs = expireDate != null ? expireDate.getTime() : null;
Long expireMs = expireDate != null ? expireDate.getTime() : null;
broadcastBanWarning(ip, org.bukkit.BanList.Type.IP, reason, expireMs, source);
}
+10 -10
View File
@@ -3488,11 +3488,11 @@ public class WebManager {
}
sb.append("]");
Map<String, String> params = new LinkedHashMap<>();
params.put("action", "sync_admins");
params.put("secret", secretKey);
params.put("admins", sb.toString());
String resp = httpGet("api/sync.php", params);
// ★ 改用POST避免GET URL过长
Map<String, Object> body = new LinkedHashMap<>();
body.put("secret", secretKey);
body.put("admins", sb.toString());
String resp = httpPost("api/sync.php?action=sync_admins", mapToJson(body));
plugin.getLogger().info("[防护-sync] 管理员列表同步: " + adminNames.size() + "人 → " + resp);
} catch (Exception e) {
plugin.getLogger().warning("[防护-sync] 管理员列表同步异常: " + e.getMessage());
@@ -3559,11 +3559,11 @@ public class WebManager {
}
lastBansHash = currentHash;
Map<String, String> params = new LinkedHashMap<>();
params.put("action", "sync_bans");
params.put("secret", secretKey);
params.put("bans", sb.toString());
String resp = httpGet("api/sync.php", params);
// ★ 改用POST避免GET URL过长(55条封禁URL可达数KB)
Map<String, Object> body = new LinkedHashMap<>();
body.put("secret", secretKey);
body.put("bans", sb.toString());
String resp = httpPost("api/sync.php?action=sync_bans", mapToJson(body));
plugin.getLogger().info("[防护-sync] 封禁名单同步: " + (nameEntries.size() + ipEntries.size()) + "条 → " + resp);
} catch (Exception e) {
plugin.getLogger().warning("[防护-sync] 封禁名单同步异常: " + e.getMessage());