125续15l-7h 修: 通配封禁reason改中性(绝不出现通配/Sdf1_login/*/目标名), 管理员回执去机制化, 一次性迁移历史脏reason
Auto Release / build (push) Successful in 5m1s
Auto Release / build (push) Successful in 5m1s
This commit is contained in:
@@ -95,9 +95,11 @@ public class WildcardBanManager {
|
|||||||
banInMinecraft(primary, target, msg);
|
banInMinecraft(primary, target, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("§6§l[通配封禁] §f已记录通配封禁 §e" + target
|
// ★ 15l-7h:给管理员的回执保留「主号+小号一起封」的机制说明(管理员需要知道),
|
||||||
+ "§f(" + (msg.isEmpty() ? "无理由" : msg) + ")"
|
// 但 reason 展示对齐主号封禁口径(msg 或「违反服务器规则」),不暴露 target 通配串。
|
||||||
+ "§f,主号 §e" + primary + "§f 已同步进 MC 封禁");
|
String displayReason = (msg == null || msg.trim().isEmpty()) ? "违反服务器规则" : msg.trim();
|
||||||
|
sender.sendMessage("§6§l[封禁] §f已封禁 §e" + primary
|
||||||
|
+ "§f 及其所有小号,封禁理由:§e" + displayReason);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +196,10 @@ public class WildcardBanManager {
|
|||||||
cachedPatterns.add(user.toLowerCase(Locale.ROOT));
|
cachedPatterns.add(user.toLowerCase(Locale.ROOT));
|
||||||
// 主号同时进精确名单:主号本人(2111)能被 isWildcardBanned 命中
|
// 主号同时进精确名单:主号本人(2111)能被 isWildcardBanned 命中
|
||||||
cachedExactNames.add(pl);
|
cachedExactNames.add(pl);
|
||||||
|
// ★ 15l-7h 一次性迁移:历史 15l-7f 把「Sdf1_login 通配封禁 xxx*」写进了
|
||||||
|
// banned-players.json 的 reason(被原版客户端封禁提示直接展示,暴露机制)。
|
||||||
|
// 主号已在 MC 封禁 + reason 含通配字样 → 重写为中性 reason(不出现「通配」「Sdf1_login」「*」)。
|
||||||
|
fixLegacyReason(primary);
|
||||||
} else {
|
} else {
|
||||||
// 纯通配(*_、*)无主号:通配记录独立生效,不进 MC 对账
|
// 纯通配(*_、*)无主号:通配记录独立生效,不进 MC 对账
|
||||||
cachedPatterns.add(user.toLowerCase(Locale.ROOT));
|
cachedPatterns.add(user.toLowerCase(Locale.ROOT));
|
||||||
@@ -240,6 +246,42 @@ public class WildcardBanManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 15l-7h 一次性迁移:把历史脏 reason(含「通配封禁」「Sdf1_login」「*」字样)重写为中性值。
|
||||||
|
* 原版 MC 封禁提示会直接展示 banned-players.json 的 reason 字段,客户端玩家能看到
|
||||||
|
* 「原因:Sdf1_login 通配封禁 2111*」= 暴露针对性操作。改成主号封禁的通用 reason。
|
||||||
|
* 仅在 reason 确实含脏字样时重写,幂等。
|
||||||
|
*/
|
||||||
|
private void fixLegacyReason(String primary) {
|
||||||
|
try {
|
||||||
|
org.bukkit.BanList bl = org.bukkit.Bukkit.getBanList(BanList.Type.NAME);
|
||||||
|
org.bukkit.BanEntry<?> entry = bl.getBanEntry(primary);
|
||||||
|
if (entry == null) return;
|
||||||
|
String reason = entry.getReason();
|
||||||
|
if (reason == null) return;
|
||||||
|
// 脏字样判定:含「通配」「Sdf1_login」「*」任一
|
||||||
|
boolean dirty = reason.contains("通配") || reason.contains("Sdf1_login")
|
||||||
|
|| reason.contains("*");
|
||||||
|
if (dirty) {
|
||||||
|
// 重写 reason:保留原 msg 部分(冒号后的),无 msg 用「违反服务器规则」
|
||||||
|
String newReason = "违反服务器规则";
|
||||||
|
int colon = reason.indexOf(':');
|
||||||
|
if (colon < 0) colon = reason.indexOf(':');
|
||||||
|
if (colon > 0 && colon + 1 < reason.length()) {
|
||||||
|
String tail = reason.substring(colon + 1).trim();
|
||||||
|
if (!tail.isEmpty()) newReason = tail;
|
||||||
|
}
|
||||||
|
bl.pardon(primary);
|
||||||
|
bl.addBan(primary, newReason,
|
||||||
|
java.time.Instant.now().plusSeconds(365L * 24 * 3600), "Sdf1_login");
|
||||||
|
plugin.getLogger().info("[通配封禁] 重写历史脏 reason:主号 " + primary
|
||||||
|
+ "「" + reason + "」→「" + newReason + "」");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
plugin.getLogger().warning("[通配封禁] 重写历史 reason 失败(主号 " + primary + "): " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 查 MC banned-players.json(NAME 类型)里是否有该封禁条目。 */
|
/** 查 MC banned-players.json(NAME 类型)里是否有该封禁条目。 */
|
||||||
private boolean mcHasBan(String nameLower) {
|
private boolean mcHasBan(String nameLower) {
|
||||||
try {
|
try {
|
||||||
@@ -269,9 +311,14 @@ public class WildcardBanManager {
|
|||||||
plugin.getLogger().fine("[通配封禁] 主号 " + primary + " 已在 MC 封禁中,跳过");
|
plugin.getLogger().fine("[通配封禁] 主号 " + primary + " 已在 MC 封禁中,跳过");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String safeReason = (reason == null || reason.isEmpty())
|
// ★ 15l-7h(用户定调):reason 绝不出现「通配」「Sdf1_login」「2111*」等字样——
|
||||||
? "Sdf1_login 通配封禁 " + target
|
// 原版 MC 封禁提示会直接展示 banned-players.json 的 reason 字段,
|
||||||
: "Sdf1_login 通配封禁 " + target + ":" + reason;
|
// 客户端玩家能看到「原因:Sdf1_login 通配封禁 2111*」= 服务器在针对性操作,不合规。
|
||||||
|
// 只走主号封禁的 msg:`ban user 你好123` 的 reason 就是「你好123」;
|
||||||
|
// 无 msg 时用中性通用 reason(不暴露插件名、不暴露通配机制、不暴露目标名)。
|
||||||
|
String safeReason = (reason == null || reason.trim().isEmpty())
|
||||||
|
? "违反服务器规则"
|
||||||
|
: reason.trim();
|
||||||
// 路径 A:控制台 dispatchCommand /ban(由原版处理器写 banned-players.json)
|
// 路径 A:控制台 dispatchCommand /ban(由原版处理器写 banned-players.json)
|
||||||
boolean dispatched = false;
|
boolean dispatched = false;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user