Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcd746ecca | ||
|
|
fd3edcd8dc | ||
|
|
91c622c4b7 | ||
|
|
ea301c7e34 | ||
|
|
8d6f25e8c5 | ||
|
|
d47267b09f | ||
|
|
3bbdf43062 | ||
|
|
1bdb52f34c | ||
|
|
8a76fc6ce6 | ||
|
|
25afbb4044 | ||
|
|
cf08c478bb | ||
|
|
3e3fb98808 | ||
|
|
be02745b6d | ||
|
|
60c030b7b4 | ||
|
|
c5cb3ebe1c | ||
|
|
a37fa6aa1a | ||
|
|
b0f8c43835 | ||
|
|
1f411203da | ||
|
|
4982f50c99 | ||
|
|
150d158a28 | ||
|
|
fd0e9e253e | ||
|
|
9067e05f2d | ||
|
|
afb8016367 | ||
|
|
58c698a9d0 | ||
|
|
1d8a5e17fc | ||
|
|
2f44462a2a | ||
|
|
8670ced16b | ||
|
|
e34adbbef5 | ||
|
|
9743040d9e | ||
|
|
c1cf152e75 | ||
|
|
3d6c87e244 | ||
|
|
82321fa403 | ||
|
|
8566c139ec | ||
|
|
6c55e6d8e6 | ||
|
|
104564141a | ||
|
|
ae788f94d1 | ||
|
|
02881c34a5 | ||
|
|
d699bae862 | ||
|
|
c70d2fdcfc | ||
|
|
4af3ea4758 | ||
|
|
fe6786deb1 | ||
|
|
c2d11cf979 | ||
|
|
0525539180 | ||
|
|
56c4069173 | ||
|
|
4b92969c64 | ||
|
|
61813a529e | ||
|
|
5aee3afa5e | ||
|
|
89e6de4415 | ||
|
|
10fb36c47a | ||
|
|
d4b9d6a891 | ||
|
|
290042789f | ||
|
|
67f8d6e7fb | ||
|
|
6a5af09ed3 | ||
|
|
13ee2eb515 | ||
|
|
d2835dd272 | ||
|
|
b6dfad4aed | ||
|
|
88e2dfa04c | ||
|
|
f5dcd5f455 | ||
|
|
fa0ea9c7e9 | ||
|
|
d159d2fb11 | ||
|
|
778bf5e4c2 | ||
|
|
a7018e1e4f | ||
|
|
d0323ea975 | ||
|
|
6892c47599 | ||
|
|
2da1f2be9e | ||
|
|
59bf992162 | ||
|
|
a0f84ee542 | ||
|
|
cf84426bf6 | ||
|
|
9443a5cf1b | ||
|
|
74db3d022b | ||
|
|
7b8aa4e194 | ||
|
|
7c649675d6 | ||
|
|
a44bc88bd0 | ||
|
|
49d86c9e85 | ||
|
|
2c006d35b5 | ||
|
|
687b592d69 | ||
|
|
a2c92d9150 | ||
|
|
325d363f4b | ||
|
|
74e2c60d60 | ||
|
|
ad17f9ccba | ||
|
|
b65562850f | ||
|
|
956ee0e940 | ||
|
|
f7f47e6178 | ||
|
|
7b62075dc7 | ||
|
|
d7d51cbb6b | ||
|
|
6eaa883849 | ||
|
|
8a693e6417 | ||
|
|
8718dc6e87 | ||
|
|
51f56b9e18 | ||
|
|
0b3a8debdd | ||
|
|
340726205c | ||
|
|
ba73ebfdb2 | ||
|
|
5e9bd5f6bf | ||
|
|
474b912afe | ||
|
|
5b705d0af2 | ||
|
|
7525b8f6b5 | ||
|
|
2090939e87 | ||
|
|
14c288a77c | ||
|
|
c92e79160c | ||
|
|
a21e95df68 | ||
|
|
0b5422395c | ||
|
|
b7b564a091 |
@@ -1,21 +0,0 @@
|
|||||||
name: Check Source
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check workspace
|
|
||||||
run: |
|
|
||||||
echo "=== PWD ==="
|
|
||||||
pwd
|
|
||||||
echo "=== LS ==="
|
|
||||||
ls -la
|
|
||||||
echo "=== FIND POM ==="
|
|
||||||
find / -name "pom.xml" 2>/dev/null
|
|
||||||
echo "=== ENV ==="
|
|
||||||
env | grep -iE "workspace|repo|git" | sort
|
|
||||||
echo "=== DONE ==="
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
name: Simple Test
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Hello
|
|
||||||
run: echo "Hello from Gitea Actions!"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
name: Test Env
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Show env
|
|
||||||
run: |
|
|
||||||
echo "=== ENV ==="
|
|
||||||
env | sort
|
|
||||||
echo "=== DONE ==="
|
|
||||||
+5
-1
@@ -121,5 +121,9 @@ test.*
|
|||||||
*.md
|
*.md
|
||||||
# 过滤readme和配置文件
|
# 过滤readme和配置文件
|
||||||
!readme.md
|
!readme.md
|
||||||
!scr/main/resources
|
!src/main/resources
|
||||||
!src/main/resources/**/*.*
|
!src/main/resources/**/*.*
|
||||||
|
# openai资源文件已启用(第58批 AI聊天功能)
|
||||||
|
!src/main/resources/openai/
|
||||||
|
!src/main/resources/openai/*.json
|
||||||
|
!src/main/resources/openai/*.txt
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -65,6 +65,10 @@ public class AreaProtection implements Listener {
|
|||||||
= new HashMap<>();
|
= new HashMap<>();
|
||||||
private final Map<String, AreaConfig> areas =
|
private final Map<String, AreaConfig> areas =
|
||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
|
// ★ 第65批修复(#345):landId 内存缓存,避免每次传送同步查 SQLite
|
||||||
|
// landId 在领地创建时分配,之后不变 → 适合缓存
|
||||||
|
// areas.put/remove 时同步清缓存
|
||||||
|
private final Map<String, Integer> landIdCache = new ConcurrentHashMap<>();
|
||||||
private Connection dbConnection;
|
private Connection dbConnection;
|
||||||
// ★ 防止"无法识别效果"刷屏:同一名称只警告一次
|
// ★ 防止"无法识别效果"刷屏:同一名称只警告一次
|
||||||
private static final Set<String> UNKNOWN_EFFECT_WARNINGS = ConcurrentHashMap.newKeySet();
|
private static final Set<String> UNKNOWN_EFFECT_WARNINGS = ConcurrentHashMap.newKeySet();
|
||||||
@@ -1119,6 +1123,8 @@ public class AreaProtection implements Listener {
|
|||||||
|
|
||||||
public void loadAllAreas() {
|
public void loadAllAreas() {
|
||||||
areas.clear();
|
areas.clear();
|
||||||
|
// ★ 第65批修复(#345):领地数据变更时清 landId 缓存
|
||||||
|
landIdCache.clear();
|
||||||
|
|
||||||
// ★ 优先从数据库加载
|
// ★ 优先从数据库加载
|
||||||
loadAreasFromDb();
|
loadAreasFromDb();
|
||||||
@@ -1259,6 +1265,7 @@ public class AreaProtection implements Listener {
|
|||||||
try { ac.badEffects = parseEffectsString(rs.getString("bad_effects")); } catch (Exception ignored) { ac.badEffects = new ArrayList<>(); }
|
try { ac.badEffects = parseEffectsString(rs.getString("bad_effects")); } catch (Exception ignored) { ac.badEffects = new ArrayList<>(); }
|
||||||
try { ac.confiscateCount = rs.getInt("confiscate_count"); } catch (Exception ignored) {}
|
try { ac.confiscateCount = rs.getInt("confiscate_count"); } catch (Exception ignored) {}
|
||||||
try { ac.returnOnLeave = rs.getInt("return_on_leave") == 1; } catch (Exception ignored) {}
|
try { ac.returnOnLeave = rs.getInt("return_on_leave") == 1; } catch (Exception ignored) {}
|
||||||
|
try { ac.parentId = rs.getInt("parent_id"); } catch (Exception ignored) { ac.parentId = 0; } // ★ 第57批续21
|
||||||
try { ac.warpX = rs.getDouble("warp_x"); } catch (Exception ignored) {}
|
try { ac.warpX = rs.getDouble("warp_x"); } catch (Exception ignored) {}
|
||||||
try { ac.warpY = rs.getDouble("warp_y"); } catch (Exception ignored) {}
|
try { ac.warpY = rs.getDouble("warp_y"); } catch (Exception ignored) {}
|
||||||
try { ac.warpZ = rs.getDouble("warp_z"); } catch (Exception ignored) {}
|
try { ac.warpZ = rs.getDouble("warp_z"); } catch (Exception ignored) {}
|
||||||
@@ -1483,7 +1490,8 @@ public class AreaProtection implements Listener {
|
|||||||
+ "enable_announce INTEGER DEFAULT 0,"
|
+ "enable_announce INTEGER DEFAULT 0,"
|
||||||
+ "announce_template TEXT DEFAULT '',"
|
+ "announce_template TEXT DEFAULT '',"
|
||||||
+ "txt_content TEXT DEFAULT '',"
|
+ "txt_content TEXT DEFAULT '',"
|
||||||
+ "created_at INTEGER NOT NULL)");
|
+ "created_at INTEGER NOT NULL,"
|
||||||
|
+ "parent_id INTEGER DEFAULT 0)");
|
||||||
|
|
||||||
// ★ 领地权限表(管理员/用户/访客三级权限)
|
// ★ 领地权限表(管理员/用户/访客三级权限)
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
@@ -1567,6 +1575,8 @@ public class AreaProtection implements Listener {
|
|||||||
// ★ 违禁品管理面板(2026-10-11):没收计数 + 退出是否归还
|
// ★ 违禁品管理面板(2026-10-11):没收计数 + 退出是否归还
|
||||||
try { stmt.executeUpdate("ALTER TABLE area_lands ADD COLUMN confiscate_count INTEGER DEFAULT 0"); } catch (Exception ignored) {}
|
try { stmt.executeUpdate("ALTER TABLE area_lands ADD COLUMN confiscate_count INTEGER DEFAULT 0"); } catch (Exception ignored) {}
|
||||||
try { stmt.executeUpdate("ALTER TABLE area_lands ADD COLUMN return_on_leave INTEGER DEFAULT 0"); } catch (Exception ignored) {}
|
try { stmt.executeUpdate("ALTER TABLE area_lands ADD COLUMN return_on_leave INTEGER DEFAULT 0"); } catch (Exception ignored) {}
|
||||||
|
// ★ 第57批续21 子领地列:旧库补列(已存在则忽略)
|
||||||
|
try { stmt.executeUpdate("ALTER TABLE area_lands ADD COLUMN parent_id INTEGER DEFAULT 0"); } catch (Exception ignored) {}
|
||||||
|
|
||||||
// ★ 全局配置默认值
|
// ★ 全局配置默认值
|
||||||
try {
|
try {
|
||||||
@@ -2568,6 +2578,47 @@ public class AreaProtection implements Listener {
|
|||||||
&& z >= minZ && z <= maxZ;
|
&& z >= minZ && z <= maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第57批续21:查找【完全包含】指定矩形区域(世界+归一化坐标)的主领地(parentId==0)。
|
||||||
|
* 子领地(有父)不视为"包含方"——部分重叠只算与父领地重叠,避免在子领地内再嵌套(仅1级)。
|
||||||
|
* 多个主领地都完全包含时返回第一个(子领地完全包含于唯一主领地,正常不会多)。
|
||||||
|
* @return 主领地的 AreaConfig;无则 null
|
||||||
|
*/
|
||||||
|
public AreaConfig findContainingMainLand(String world, int nx1, int nz1, int nx2, int nz2) {
|
||||||
|
if (world == null) return null;
|
||||||
|
int minX = Math.min(nx1, nx2), maxX = Math.max(nx1, nx2);
|
||||||
|
int minZ = Math.min(nz1, nz2), maxZ = Math.max(nz1, nz2);
|
||||||
|
for (AreaConfig other : areas.values()) {
|
||||||
|
if (other == null) continue;
|
||||||
|
if (other.parentId != 0) continue; // 只看主领地
|
||||||
|
if (!other.world.equalsIgnoreCase(world)) continue;
|
||||||
|
int oMinX = Math.min(other.x1, other.x2), oMaxX = Math.max(other.x1, other.x2);
|
||||||
|
int oMinZ = Math.min(other.z1, other.z2), oMaxZ = Math.max(other.z1, other.z2);
|
||||||
|
// 完全包含:other ⊇ new
|
||||||
|
if (oMinX <= minX && oMaxX >= maxX && oMinZ <= minZ && oMaxZ >= maxZ) {
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第57批续21:创建子领地的身份闸门——判定玩家是否具备主领地的
|
||||||
|
* 领地主 / 领地管理员 / 插件管理员 任一身份(授权管理员=该领地里 role='admin' 的行)。
|
||||||
|
* 只有合格者才允许在主领地内创建子领地;不合格一律拒绝。
|
||||||
|
*/
|
||||||
|
public boolean isQualifiedLandManager(Player p, AreaConfig mainLand) {
|
||||||
|
if (p == null || mainLand == null) return false;
|
||||||
|
if (isAreaAdmin(p)) return true; // 插件管理员(OP/ScoreboardTag)
|
||||||
|
if (samePlayer(p.getName(), mainLand.owner)) return true; // 领地主
|
||||||
|
int lid = getLandIdFromDb(mainLand.name);
|
||||||
|
if (lid > 0) {
|
||||||
|
PermRow row = findPermRowExact(lid, p.getName());
|
||||||
|
if (row != null && "admin".equalsIgnoreCase(row.role)) return true; // 授权领地管理员
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取玩家在指定领地的权限级别
|
* 获取玩家在指定领地的权限级别
|
||||||
*/
|
*/
|
||||||
@@ -2584,6 +2635,21 @@ public class AreaProtection implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2.5) ★ 第57批续21 子领地继承:玩家对本领地无直接角色,但父领地里是
|
||||||
|
// 领地主/授权管理员/插件管理员 → 在子领地内同样行使管理权(防越权绕过)。
|
||||||
|
// 子领地 owner=主领地主,上面第2步已覆盖 owner;这里补授权管理员/插件管理员继承。
|
||||||
|
if (ac != null && ac.parentId > 0 && dbConnection != null) {
|
||||||
|
String parentName = findLandNameById(ac.parentId);
|
||||||
|
if (parentName != null) {
|
||||||
|
AreaConfig parent = areas.get(parentName);
|
||||||
|
if (parent != null
|
||||||
|
&& !samePlayer(player.getName(), parent.owner)
|
||||||
|
&& isQualifiedLandManager(player, parent)) {
|
||||||
|
return PermissionLevel.ADMIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 领地角色(DB,仅限该领地;2026-10-11 精确匹配,一次查询判 admin/member 两态)
|
// 3. 领地角色(DB,仅限该领地;2026-10-11 精确匹配,一次查询判 admin/member 两态)
|
||||||
// admin → ADMIN(/protect setadmin 或领地所有者GUI设置)
|
// admin → ADMIN(/protect setadmin 或领地所有者GUI设置)
|
||||||
// member(未过期) → MEMBER:已授权成员,不受领地全局默认权限限制
|
// member(未过期) → MEMBER:已授权成员,不受领地全局默认权限限制
|
||||||
@@ -2962,43 +3028,81 @@ public class AreaProtection implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
* 拉黑时撤销该玩家在所有领地的管理员身份(admin -> visitor)。
|
* 拉黑时撤销该玩家在所有领地的管理员身份(admin -> visitor)。
|
||||||
|
|
||||||
* 走 normName 定位(历史数据大小写可能不一致),逐行 UPDATE。
|
* 走 normName 定位(历史数据大小写可能不一致),逐行 UPDATE。
|
||||||
|
|
||||||
* @return 撤销的管理员身份数量
|
* @return 撤销的管理员身份数量
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int demoteBlacklistAdmins(String playerName) {
|
public int demoteBlacklistAdmins(String playerName) {
|
||||||
|
|
||||||
if (dbConnection == null || playerName == null || playerName.isEmpty()) return 0;
|
if (dbConnection == null || playerName == null || playerName.isEmpty()) return 0;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
String target = normName(playerName);
|
String target = normName(playerName);
|
||||||
|
|
||||||
java.util.List<Integer> ids = new java.util.ArrayList<>();
|
java.util.List<Integer> ids = new java.util.ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PreparedStatement sel = dbConnection.prepareStatement(
|
PreparedStatement sel = dbConnection.prepareStatement(
|
||||||
|
|
||||||
"SELECT id, player_name FROM area_land_permissions WHERE role = 'admin'");
|
"SELECT id, player_name FROM area_land_permissions WHERE role = 'admin'");
|
||||||
|
|
||||||
ResultSet rs = sel.executeQuery();
|
ResultSet rs = sel.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
String pn = rs.getString("player_name");
|
String pn = rs.getString("player_name");
|
||||||
|
|
||||||
if (pn != null && normName(pn).equals(target)) {
|
if (pn != null && normName(pn).equals(target)) {
|
||||||
|
|
||||||
ids.add(rs.getInt("id"));
|
ids.add(rs.getInt("id"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
sel.close();
|
sel.close();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int id : ids) {
|
for (int id : ids) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
PreparedStatement up = dbConnection.prepareStatement(
|
PreparedStatement up = dbConnection.prepareStatement(
|
||||||
|
|
||||||
"UPDATE area_land_permissions SET role = 'visitor' WHERE id = ?");
|
"UPDATE area_land_permissions SET role = 'visitor' WHERE id = ?");
|
||||||
|
|
||||||
up.setInt(1, id);
|
up.setInt(1, id);
|
||||||
|
|
||||||
count += up.executeUpdate();
|
count += up.executeUpdate();
|
||||||
|
|
||||||
up.close();
|
up.close();
|
||||||
|
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入一条领地权限记录(角色为 member/visitor),已存在则忽略
|
* 插入一条领地权限记录(角色为 member/visitor),已存在则忽略
|
||||||
* 用于 PHP 端添加成员时同步到 Java
|
* 用于 PHP 端添加成员时同步到 Java
|
||||||
@@ -3123,6 +3227,62 @@ public class AreaProtection implements Listener {
|
|||||||
return n.endsWith("_SIGN");
|
return n.endsWith("_SIGN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第57批续22: 子领地创建时继承主领地权限一次。
|
||||||
|
* 后续子领地权限由子领地主/管理员/子领地授权管理员单独调配,
|
||||||
|
* 不再跟随主领地变化。
|
||||||
|
* 继承范围: deny* 权限开关、出入提示、游戏模式强制、公共建筑标记。
|
||||||
|
* 不继承: owner(创建者)、坐标、parentId、createCost。
|
||||||
|
*/
|
||||||
|
private void copyLandPermissions(AreaConfig src, AreaConfig dst) {
|
||||||
|
if (src == null || dst == null) return;
|
||||||
|
dst.denyBlockPlace = src.denyBlockPlace;
|
||||||
|
dst.denyBlockBreak = src.denyBlockBreak;
|
||||||
|
dst.denySignEdit = src.denySignEdit;
|
||||||
|
dst.denyContainer = src.denyContainer;
|
||||||
|
dst.denyPVP = src.denyPVP;
|
||||||
|
dst.denyFallDamage = src.denyFallDamage;
|
||||||
|
dst.denyHunger = src.denyHunger;
|
||||||
|
dst.denyAllDamage = src.denyAllDamage;
|
||||||
|
dst.denyMount = src.denyMount;
|
||||||
|
dst.allowDrop = src.allowDrop;
|
||||||
|
dst.denyEnderPearl = src.denyEnderPearl;
|
||||||
|
dst.denyBow = src.denyBow;
|
||||||
|
dst.denyPotion = src.denyPotion;
|
||||||
|
dst.denyExplosion = src.denyExplosion;
|
||||||
|
dst.denyMove = src.denyMove;
|
||||||
|
dst.allowPickup = src.allowPickup;
|
||||||
|
dst.denyFire = src.denyFire;
|
||||||
|
dst.denyThrownProjectiles = src.denyThrownProjectiles;
|
||||||
|
dst.denyGlowing = src.denyGlowing;
|
||||||
|
dst.denyRedstoneInteraction = src.denyRedstoneInteraction;
|
||||||
|
dst.denyDoorInteraction = src.denyDoorInteraction;
|
||||||
|
dst.denyNoteblockJukebox = src.denyNoteblockJukebox;
|
||||||
|
dst.denyLead = src.denyLead;
|
||||||
|
dst.denyCropHarvest = src.denyCropHarvest;
|
||||||
|
dst.denyFarmlandTrample = src.denyFarmlandTrample;
|
||||||
|
dst.denyEnderTeleport = src.denyEnderTeleport;
|
||||||
|
dst.denyWoolShear = src.denyWoolShear;
|
||||||
|
dst.denyAnimalFeeding = src.denyAnimalFeeding;
|
||||||
|
dst.denySpawnEgg = src.denySpawnEgg;
|
||||||
|
dst.denyWax = src.denyWax;
|
||||||
|
dst.denyMobAttack = src.denyMobAttack;
|
||||||
|
dst.denyVillagerTrade = src.denyVillagerTrade;
|
||||||
|
dst.denyRaid = src.denyRaid;
|
||||||
|
dst.denyFireSpread = src.denyFireSpread;
|
||||||
|
dst.denyAllEffects = src.denyAllEffects;
|
||||||
|
dst.denyItemFrame = src.denyItemFrame;
|
||||||
|
dst.denyEntityInteract = src.denyEntityInteract;
|
||||||
|
dst.enterMsg = src.enterMsg;
|
||||||
|
dst.leaveMsg = src.leaveMsg;
|
||||||
|
dst.enforceGameMode = src.enforceGameMode;
|
||||||
|
dst.isPublicBuilding = src.isPublicBuilding;
|
||||||
|
dst.allowVisitorTeleport = src.allowVisitorTeleport;
|
||||||
|
dst.peaceMode = src.peaceMode;
|
||||||
|
dst.peaceModeDuration = src.peaceModeDuration;
|
||||||
|
dst.clearAllBadEffects = src.clearAllBadEffects;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取领地默认deny状态(按字段名映射)
|
* 获取领地默认deny状态(按字段名映射)
|
||||||
*/
|
*/
|
||||||
@@ -3515,6 +3675,12 @@ public class AreaProtection implements Listener {
|
|||||||
String newArea = null;
|
String newArea = null;
|
||||||
String forcedMode = null;
|
String forcedMode = null;
|
||||||
|
|
||||||
|
// ★ 第57批续22: 收集所有匹配领地,选面积最小的。
|
||||||
|
// 子领地完全包含在主领地内,ConcurrentHashMap 遍历顺序不定,
|
||||||
|
// 先 break 可能命中主领地 → 子领地 deny_move=1 不生效。
|
||||||
|
// 面积最小 = 子领地(完全包含时面积必然更小),天然优先级正确。
|
||||||
|
AreaConfig bestAc = null;
|
||||||
|
String bestName = null;
|
||||||
for (Map.Entry<String, AreaConfig> entry
|
for (Map.Entry<String, AreaConfig> entry
|
||||||
: areas.entrySet()) {
|
: areas.entrySet()) {
|
||||||
AreaConfig ac = entry.getValue();
|
AreaConfig ac = entry.getValue();
|
||||||
@@ -3530,11 +3696,25 @@ public class AreaProtection implements Listener {
|
|||||||
if (px >= minX && px <= maxX
|
if (px >= minX && px <= maxX
|
||||||
&& pz >= minZ && pz <= maxZ
|
&& pz >= minZ && pz <= maxZ
|
||||||
&& py >= ac.yMin && py <= ac.yMax) {
|
&& py >= ac.yMin && py <= ac.yMax) {
|
||||||
newArea = entry.getKey();
|
if (bestAc == null) {
|
||||||
forcedMode = ac.enforceGameMode;
|
bestAc = ac;
|
||||||
break;
|
bestName = entry.getKey();
|
||||||
|
} else {
|
||||||
|
long bestArea = (long)(Math.abs(bestAc.x1 - bestAc.x2) + 1)
|
||||||
|
* (Math.abs(bestAc.z1 - bestAc.z2) + 1);
|
||||||
|
long curArea = (long)(Math.abs(ac.x1 - ac.x2) + 1)
|
||||||
|
* (Math.abs(ac.z1 - ac.z2) + 1);
|
||||||
|
if (curArea <= bestArea) {
|
||||||
|
bestAc = ac;
|
||||||
|
bestName = entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bestName != null) {
|
||||||
|
newArea = bestName;
|
||||||
|
forcedMode = bestAc.enforceGameMode;
|
||||||
|
}
|
||||||
|
|
||||||
/* plugin.getLogger().info(
|
/* plugin.getLogger().info(
|
||||||
"[防护-移动] " + p.getName()
|
"[防护-移动] " + p.getName()
|
||||||
@@ -5355,6 +5535,8 @@ public class AreaProtection implements Listener {
|
|||||||
*/
|
*/
|
||||||
public void deleteLand(String name) {
|
public void deleteLand(String name) {
|
||||||
areas.remove(name);
|
areas.remove(name);
|
||||||
|
// ★ 第65批修复(#345):清 landId 缓存
|
||||||
|
landIdCache.remove(name);
|
||||||
// 删除数据库记录
|
// 删除数据库记录
|
||||||
try {
|
try {
|
||||||
if (dbConnection != null && !dbConnection.isClosed()) {
|
if (dbConnection != null && !dbConnection.isClosed()) {
|
||||||
@@ -5896,6 +6078,35 @@ public class AreaProtection implements Listener {
|
|||||||
BondManager bnd = plugin.getBonds();
|
BondManager bnd = plugin.getBonds();
|
||||||
int bal = (bnd != null) ? bnd.getBonds(p.getName()) : 0;
|
int bal = (bnd != null) ? bnd.getBonds(p.getName()) : 0;
|
||||||
p.sendMessage("§e§l[防护] §f选区完成!面积: §a" + a + "㎡§7(" + w + "×" + l + ") 单价: §f" + pricePerSqm + "/㎡" + src + " 预估: §e" + totalCost + "§7债券 余额: §a" + bal);
|
p.sendMessage("§e§l[防护] §f选区完成!面积: §a" + a + "㎡§7(" + w + "×" + l + ") 单价: §f" + pricePerSqm + "/㎡" + src + " 预估: §e" + totalCost + "§7债券 余额: §a" + bal);
|
||||||
|
boolean canCreateSub = true; // ★ 续21修1: 身份不合格/部分重叠时不展示确认创建按钮
|
||||||
|
// ★ 第57批续21 圈地棒选区后智能识别:若落在已有领地内,提示需具备该领地管理身份才能建子领地
|
||||||
|
{
|
||||||
|
int sx1 = Math.min(lp1.getBlockX(), newLoc.getBlockX());
|
||||||
|
int sx2 = Math.max(lp1.getBlockX(), newLoc.getBlockX());
|
||||||
|
int sz1 = Math.min(lp1.getBlockZ(), newLoc.getBlockZ());
|
||||||
|
int sz2 = Math.max(lp1.getBlockZ(), newLoc.getBlockZ());
|
||||||
|
AreaConfig selMain = findContainingMainLand(p.getWorld().getName(), sx1, sz1, sx2, sz2);
|
||||||
|
if (selMain != null) {
|
||||||
|
// 身份判定静默:不合格则不展示按钮,不提示原因
|
||||||
|
if (!isQualifiedLandManager(p, selMain)) {
|
||||||
|
canCreateSub = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (AreaConfig sot : areas.values()) {
|
||||||
|
if (sot == null || sot.parentId != 0) continue;
|
||||||
|
if (!sot.world.equalsIgnoreCase(p.getWorld().getName())) continue;
|
||||||
|
int so1x = Math.min(sot.x1, sot.x2), so2x = Math.max(sot.x1, sot.x2);
|
||||||
|
int so1z = Math.min(sot.z1, sot.z2), so2z = Math.max(sot.z1, sot.z2);
|
||||||
|
if (sx1 <= so2x && sx2 >= so1x && sz1 <= so2z && sz2 >= so1z) {
|
||||||
|
canCreateSub = false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (canCreateSub) {
|
||||||
// ★ 一键创建超链接:自动用玩家名,冲突则加数字(重名不区分大小写)
|
// ★ 一键创建超链接:自动用玩家名,冲突则加数字(重名不区分大小写)
|
||||||
String autoName = p.getName();
|
String autoName = p.getName();
|
||||||
if (areaNameExists(autoName)) {
|
if (areaNameExists(autoName)) {
|
||||||
@@ -5911,6 +6122,9 @@ public class AreaProtection implements Listener {
|
|||||||
.clickEvent(ClickEvent.runCommand("/protect confirm_create " + finalAutoName))
|
.clickEvent(ClickEvent.runCommand("/protect confirm_create " + finalAutoName))
|
||||||
);
|
);
|
||||||
p.sendMessage(Component.text("§7或输入 §f/protect 创建 <自定义名> §7指定领地名"));
|
p.sendMessage(Component.text("§7或输入 §f/protect 创建 <自定义名> §7指定领地名"));
|
||||||
|
} else {
|
||||||
|
// 身份/范围限制:静默隐藏按钮,不提示原因
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7785,8 +7999,51 @@ public class AreaProtection implements Listener {
|
|||||||
if (!pos1.containsKey(cp.getUniqueId()) || !pos2.containsKey(cp.getUniqueId())) {
|
if (!pos1.containsKey(cp.getUniqueId()) || !pos2.containsKey(cp.getUniqueId())) {
|
||||||
cp.sendMessage("§c请先用工具选点"); return true;
|
cp.sendMessage("§c请先用工具选点"); return true;
|
||||||
}
|
}
|
||||||
|
// ★ 第57批续21 提前取选区坐标(供空间重叠识别,原在下方重复声明已移除)
|
||||||
|
Location cl1 = pos1.get(cp.getUniqueId());
|
||||||
|
Location cl2 = pos2.get(cp.getUniqueId());
|
||||||
|
int cw = Math.abs(cl2.getBlockX() - cl1.getBlockX()) + 1;
|
||||||
|
int cl = Math.abs(cl2.getBlockZ() - cl1.getBlockZ()) + 1;
|
||||||
|
int cArea = cw * cl;
|
||||||
// 检查重名(不区分大小写)
|
// 检查重名(不区分大小写)
|
||||||
if (areaNameExists(confirmName)) { cp.sendMessage("§c区域已存在(大小写不同也算重复)"); return true; }
|
if (areaNameExists(confirmName)) { cp.sendMessage("§c区域已存在(大小写不同也算重复)"); return true; }
|
||||||
|
// ★ 第57批续21 空间重叠智能识别 + 子领地身份闸门(修"任何人能在别人领地内建重叠领地"绕过漏洞)
|
||||||
|
int cnx1 = Math.min(cl1.getBlockX(), cl2.getBlockX());
|
||||||
|
int cnz1 = Math.min(cl1.getBlockZ(), cl2.getBlockZ());
|
||||||
|
int cnx2 = Math.max(cl1.getBlockX(), cl2.getBlockX());
|
||||||
|
int cnz2 = Math.max(cl1.getBlockZ(), cl2.getBlockZ());
|
||||||
|
String cnWorld = cl1.getWorld().getName();
|
||||||
|
AreaConfig cnMain = findContainingMainLand(cnWorld, cnx1, cnz1, cnx2, cnz2);
|
||||||
|
boolean cnIsSub = cnMain != null;
|
||||||
|
if (cnIsSub) {
|
||||||
|
if (!isQualifiedLandManager(cp, cnMain)) {
|
||||||
|
cp.sendMessage("§c§l[防护] §f拒绝创建: 当前选区已在领地 §e" + cnMain.name
|
||||||
|
+ " §f范围内,你需具备该领地的领主/管理员/授权管理员身份才能创建子领地。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 无完全包含的主领地 → 部分重叠(跨边界)一律拒绝
|
||||||
|
for (AreaConfig ot : areas.values()) {
|
||||||
|
if (ot == null || ot.parentId != 0) continue;
|
||||||
|
if (!ot.world.equalsIgnoreCase(cnWorld)) continue;
|
||||||
|
int omx = Math.min(ot.x1, ot.x2), omx2 = Math.max(ot.x1, ot.x2);
|
||||||
|
int omz = Math.min(ot.z1, ot.z2), omz2 = Math.max(ot.z1, ot.z2);
|
||||||
|
if (cnx1 <= omx2 && cnx2 >= omx && cnz1 <= omz2 && cnz2 >= omz) {
|
||||||
|
cp.sendMessage("§c§l[防护] §f拒绝创建: 选区与领地 §e" + ot.name
|
||||||
|
+ " §f部分重叠(跨边界),子领地必须完整位于某主领地内,请重选区域。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cnIsSub) {
|
||||||
|
// 子领地命名冲突:自动追加序号(父领地内子领地可多个)
|
||||||
|
String subName = confirmName;
|
||||||
|
if (areaNameExists(subName)) {
|
||||||
|
int s2 = 1;
|
||||||
|
while (areaNameExists(subName + s2)) s2++;
|
||||||
|
confirmName = subName + s2;
|
||||||
|
}
|
||||||
|
}
|
||||||
// ★ 检查上限(含DB兜底)
|
// ★ 检查上限(含DB兜底)
|
||||||
UserGroupManager cugm = plugin.getUserGroup();
|
UserGroupManager cugm = plugin.getUserGroup();
|
||||||
int cMaxLands = (cugm != null) ? cugm.getPlayerMaxLands(cp.getName(), globalMaxLandsPerPlayer) : globalMaxLandsPerPlayer;
|
int cMaxLands = (cugm != null) ? cugm.getPlayerMaxLands(cp.getName(), globalMaxLandsPerPlayer) : globalMaxLandsPerPlayer;
|
||||||
@@ -7800,12 +8057,7 @@ public class AreaProtection implements Listener {
|
|||||||
cr.close(); cs.close();
|
cr.close(); cs.close();
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
if (cLandCount >= cMaxLands) { cp.sendMessage("§c§l[防护] §f已达领地上限!"); return true; }
|
if (!cnIsSub && cLandCount >= cMaxLands) { cp.sendMessage("§c§l[防护] §f已达领地上限!"); return true; }
|
||||||
Location cl1 = pos1.get(cp.getUniqueId());
|
|
||||||
Location cl2 = pos2.get(cp.getUniqueId());
|
|
||||||
int cw = Math.abs(cl2.getBlockX() - cl1.getBlockX()) + 1;
|
|
||||||
int cl = Math.abs(cl2.getBlockZ() - cl1.getBlockZ()) + 1;
|
|
||||||
int cArea = cw * cl;
|
|
||||||
int cPrice = (cugm != null) ? cugm.getPlayerLandPricePerSqm(cp.getName(), globalCreatePricePerSqm) : globalCreatePricePerSqm;
|
int cPrice = (cugm != null) ? cugm.getPlayerLandPricePerSqm(cp.getName(), globalCreatePricePerSqm) : globalCreatePricePerSqm;
|
||||||
int cCost = cArea * cPrice;
|
int cCost = cArea * cPrice;
|
||||||
|
|
||||||
@@ -7832,13 +8084,27 @@ public class AreaProtection implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AreaConfig cac = new AreaConfig();
|
AreaConfig cac = new AreaConfig();
|
||||||
cac.name = confirmName; cac.owner = cp.getName(); cac.world = cl1.getWorld().getName();
|
cac.name = confirmName;
|
||||||
|
// ★ 第57批续21 子领地:owner 沿用主领地主;主领地:owner=创建者
|
||||||
|
// ★ 续21续2: 子领地 owner=创建者(付款人)——退款退给付款人。
|
||||||
|
// 权限继承靠 getPermissionLevel 父领地ADMIN继承(已实现),子领地权限行挂父领地land_id
|
||||||
|
cac.owner = cp.getName();
|
||||||
|
cac.world = cl1.getWorld().getName();
|
||||||
cac.x1 = cl1.getBlockX(); cac.z1 = cl1.getBlockZ(); cac.x2 = cl2.getBlockX(); cac.z2 = cl2.getBlockZ();
|
cac.x1 = cl1.getBlockX(); cac.z1 = cl1.getBlockZ(); cac.x2 = cl2.getBlockX(); cac.z2 = cl2.getBlockZ();
|
||||||
cac.yMin = 0; cac.yMax = 255;
|
cac.yMin = 0; cac.yMax = 255;
|
||||||
cac.createCost = chargedCost; // ★ 记录创建扣款(删除时按比例退费的基数)
|
cac.createCost = chargedCost; // ★ 记录创建扣款(删除时按比例退费的基数)
|
||||||
|
cac.parentId = cnIsSub ? getLandIdFromDb(cnMain.name) : 0; // ★ 第57批续21 子领地父ID
|
||||||
|
// ★ 第57批续22: 子领地创建时继承主领地权限一次(后续可单独调配)
|
||||||
|
if (cnIsSub) {
|
||||||
|
copyLandPermissions(cnMain, cac);
|
||||||
|
}
|
||||||
saveAreaToDb(cac);
|
saveAreaToDb(cac);
|
||||||
areas.put(confirmName, cac); // ★ 立即更新内存
|
areas.put(confirmName, cac); // ★ 立即更新内存
|
||||||
cp.sendMessage("§a§l[防护] §f区域 " + confirmName + " 已创建 (owner: " + cp.getName() + ")");
|
if (cnIsSub) {
|
||||||
|
cp.sendMessage("§a§l[防护] §f子领地 §e" + confirmName + " §f已创建(父领地: " + cnMain.name + ")");
|
||||||
|
} else {
|
||||||
|
cp.sendMessage("§a§l[防护] §f区域 " + confirmName + " 已创建 (owner: " + cac.owner + ")");
|
||||||
|
}
|
||||||
loadAllAreas();
|
loadAllAreas();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -10454,6 +10720,39 @@ public class AreaProtection implements Listener {
|
|||||||
adm.sendMessage("§c§l[审批] §f领地名 §e" + pe.landName + " §f已被占用,申请作废");
|
adm.sendMessage("§c§l[审批] §f领地名 §e" + pe.landName + " §f已被占用,申请作废");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// ★ 第57批续21 审批路径也套空间重叠闸门:申请人具备主领地管理身份(领地主/管理员/授权管理员)
|
||||||
|
// 才能在重叠区创建子领地;审批管理员本人申请时 isAreaAdmin=true 恒合格。
|
||||||
|
int aN1x = Math.min(pe.newX1, pe.newX2), aN2x = Math.max(pe.newX1, pe.newX2);
|
||||||
|
int aN1z = Math.min(pe.newZ1, pe.newZ2), aN2z = Math.max(pe.newZ1, pe.newZ2);
|
||||||
|
AreaConfig apMain = findContainingMainLand(pe.world, aN1x, aN1z, aN2x, aN2z);
|
||||||
|
boolean apIsSub = apMain != null;
|
||||||
|
Player apReqOnline = Bukkit.getPlayerExact(pe.requester);
|
||||||
|
if (apIsSub) {
|
||||||
|
if (apReqOnline == null || !isQualifiedLandManager(apReqOnline, apMain)) {
|
||||||
|
pendingExpands.remove(pe.landName.toLowerCase());
|
||||||
|
adm.sendMessage("§c§l[审批] §f申请区已在领地 §e" + apMain.name
|
||||||
|
+ " §f内,但申请人 §e" + pe.requester + " §f不具备该领地的管理身份,申请作废");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (AreaConfig aot : areas.values()) {
|
||||||
|
if (aot == null || aot.parentId != 0) continue;
|
||||||
|
if (!aot.world.equalsIgnoreCase(pe.world)) continue;
|
||||||
|
int ao1x = Math.min(aot.x1, aot.x2), ao2x = Math.max(aot.x1, aot.x2);
|
||||||
|
int ao1z = Math.min(aot.z1, aot.z2), ao2z = Math.max(aot.z1, aot.z2);
|
||||||
|
if (aN1x <= ao2x && aN2x >= ao1x && aN1z <= ao2z && aN2z >= ao1z) {
|
||||||
|
pendingExpands.remove(pe.landName.toLowerCase());
|
||||||
|
adm.sendMessage("§c§l[审批] §f申请区与领地 §e" + aot.name
|
||||||
|
+ " §f部分重叠(跨边界),子领地必须完整位于某主领地内,申请作废");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (apIsSub && areaNameExists(pe.landName)) {
|
||||||
|
int sa = 1;
|
||||||
|
while (areaNameExists(pe.landName + sa)) sa++;
|
||||||
|
pe.landName = pe.landName + sa;
|
||||||
|
}
|
||||||
UserGroupManager aPugm = plugin.getUserGroup();
|
UserGroupManager aPugm = plugin.getUserGroup();
|
||||||
int aMax = (aPugm != null) ? aPugm.getPlayerMaxLands(pe.requester, globalMaxLandsPerPlayer) : globalMaxLandsPerPlayer;
|
int aMax = (aPugm != null) ? aPugm.getPlayerMaxLands(pe.requester, globalMaxLandsPerPlayer) : globalMaxLandsPerPlayer;
|
||||||
long aCnt = areas.values().stream().filter(a -> samePlayer(pe.requester, a.owner)).count();
|
long aCnt = areas.values().stream().filter(a -> samePlayer(pe.requester, a.owner)).count();
|
||||||
@@ -10485,18 +10784,30 @@ public class AreaProtection implements Listener {
|
|||||||
}
|
}
|
||||||
AreaConfig nc = new AreaConfig();
|
AreaConfig nc = new AreaConfig();
|
||||||
nc.name = pe.landName;
|
nc.name = pe.landName;
|
||||||
|
// ★ 第57批续21 子领地:owner 沿用主领地主;主领地:owner=申请人
|
||||||
|
// ★ 续21续2: 子领地 owner=申请人(付款人)——退款退给付款人。权限继承靠父领地ADMIN继承
|
||||||
nc.owner = pe.requester;
|
nc.owner = pe.requester;
|
||||||
nc.world = pe.world;
|
nc.world = pe.world;
|
||||||
nc.x1 = pe.newX1; nc.z1 = pe.newZ1;
|
nc.x1 = pe.newX1; nc.z1 = pe.newZ1;
|
||||||
nc.x2 = pe.newX2; nc.z2 = pe.newZ2;
|
nc.x2 = pe.newX2; nc.z2 = pe.newZ2;
|
||||||
nc.yMin = 0; nc.yMax = 255;
|
nc.yMin = 0; nc.yMax = 255;
|
||||||
nc.createCost = charged;
|
nc.createCost = charged;
|
||||||
|
nc.parentId = apIsSub ? getLandIdFromDb(apMain.name) : 0; // ★ 第57批续21 子领地父ID
|
||||||
|
// ★ 第57批续22: 子领地创建时继承主领地权限一次(后续可单独调配)
|
||||||
|
if (apIsSub) {
|
||||||
|
copyLandPermissions(apMain, nc);
|
||||||
|
}
|
||||||
saveAreaToDb(nc);
|
saveAreaToDb(nc);
|
||||||
areas.put(pe.landName, nc);
|
areas.put(pe.landName, nc);
|
||||||
pendingExpands.remove(pe.landName.toLowerCase());
|
pendingExpands.remove(pe.landName.toLowerCase());
|
||||||
loadAllAreas();
|
loadAllAreas();
|
||||||
adm.sendMessage("§a§l[审批] §f已批准创建领地 §e" + pe.landName + " §f(§e"
|
if (apIsSub) {
|
||||||
+ pe.area + "㎡§f),向申请人扣除 §e" + charged + " §f债券");
|
adm.sendMessage("§a§l[审批] §f已批准创建子领地 §e" + pe.landName
|
||||||
|
+ " §f(父领地 " + apMain.name + ", §e" + pe.area + "㎡§f),向申请人扣除 §e" + charged + " §f债券");
|
||||||
|
} else {
|
||||||
|
adm.sendMessage("§a§l[审批] §f已批准创建领地 §e" + pe.landName + " §f(§e"
|
||||||
|
+ pe.area + "㎡§f),向申请人扣除 §e" + charged + " §f债券");
|
||||||
|
}
|
||||||
if (requester != null && requester.isOnline()) {
|
if (requester != null && requester.isOnline()) {
|
||||||
requester.sendMessage("§a§l[防护] §f你的领地 §e" + pe.landName
|
requester.sendMessage("§a§l[防护] §f你的领地 §e" + pe.landName
|
||||||
+ " §f已由管理员审批创建成功(" + pe.area + "㎡,扣除 " + charged + " 债券)");
|
+ " §f已由管理员审批创建成功(" + pe.area + "㎡,扣除 " + charged + " 债券)");
|
||||||
@@ -10608,8 +10919,11 @@ public class AreaProtection implements Listener {
|
|||||||
String reason = (String) o[1];
|
String reason = (String) o[1];
|
||||||
if (reason == null) {
|
if (reason == null) {
|
||||||
if (dbMgr == null) continue;
|
if (dbMgr == null) continue;
|
||||||
|
// ★ 第58批修复:SQL 异常时 userExists 返回 false,
|
||||||
|
// 会把 DB 抖动误判为"账户已注销"从而删领地。
|
||||||
|
// 改用 userExistsIgnoreCase(异常返回 true,宁可放过)。
|
||||||
try {
|
try {
|
||||||
if (!dbMgr.userExists(ac.owner)) {
|
if (!dbMgr.userExistsIgnoreCase(ac.owner)) {
|
||||||
reason = "账户已注销";
|
reason = "账户已注销";
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
@@ -10761,8 +11075,8 @@ public class AreaProtection implements Listener {
|
|||||||
+ "confiscate_msg, enable_announce, announce_template, txt_content, created_at, "
|
+ "confiscate_msg, enable_announce, announce_template, txt_content, created_at, "
|
||||||
+ "deny_thrown_projectiles, deny_glowing, deny_redstone_interaction, deny_door_interaction, "
|
+ "deny_thrown_projectiles, deny_glowing, deny_redstone_interaction, deny_door_interaction, "
|
||||||
+ "deny_noteblock_jukebox, deny_lead, deny_crop_harvest, deny_wool_shear, deny_animal_feeding, "
|
+ "deny_noteblock_jukebox, deny_lead, deny_crop_harvest, deny_wool_shear, deny_animal_feeding, "
|
||||||
+ "warp_x, warp_y, warp_z, warp_yaw, warp_pitch, warp_world, deny_container, deny_mob_attack, deny_sign_edit, is_public_building, allow_visitor_teleport, deny_farmland_trample, deny_ender_teleport, create_cost, deny_spawn_egg, deny_wax, bad_effects, deny_villager_trade, confiscate_count, return_on_leave) "
|
+ "warp_x, warp_y, warp_z, warp_yaw, warp_pitch, warp_world, deny_container, deny_mob_attack, deny_sign_edit, is_public_building, allow_visitor_teleport, deny_farmland_trample, deny_ender_teleport, create_cost, deny_spawn_egg, deny_wax, bad_effects, deny_villager_trade, confiscate_count, return_on_leave, parent_id) "
|
||||||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
+ "ON CONFLICT(name) DO UPDATE SET "
|
+ "ON CONFLICT(name) DO UPDATE SET "
|
||||||
+ "owner=excluded.owner, world=excluded.world, x1=excluded.x1, z1=excluded.z1, x2=excluded.x2, z2=excluded.z2, y_min=excluded.y_min, y_max=excluded.y_max, "
|
+ "owner=excluded.owner, world=excluded.world, x1=excluded.x1, z1=excluded.z1, x2=excluded.x2, z2=excluded.z2, y_min=excluded.y_min, y_max=excluded.y_max, "
|
||||||
+ "confiscate_items=excluded.confiscate_items, deny_use_items=excluded.deny_use_items, give_effects=excluded.give_effects, clear_effects=excluded.clear_effects, clear_all_bad=excluded.clear_all_bad, "
|
+ "confiscate_items=excluded.confiscate_items, deny_use_items=excluded.deny_use_items, give_effects=excluded.give_effects, clear_effects=excluded.clear_effects, clear_all_bad=excluded.clear_all_bad, "
|
||||||
@@ -10775,7 +11089,7 @@ public class AreaProtection implements Listener {
|
|||||||
+ "confiscate_msg=excluded.confiscate_msg, enable_announce=excluded.enable_announce, announce_template=excluded.announce_template, txt_content=excluded.txt_content, created_at=excluded.created_at, "
|
+ "confiscate_msg=excluded.confiscate_msg, enable_announce=excluded.enable_announce, announce_template=excluded.announce_template, txt_content=excluded.txt_content, created_at=excluded.created_at, "
|
||||||
+ "deny_thrown_projectiles=excluded.deny_thrown_projectiles, deny_glowing=excluded.deny_glowing, deny_redstone_interaction=excluded.deny_redstone_interaction, deny_door_interaction=excluded.deny_door_interaction, "
|
+ "deny_thrown_projectiles=excluded.deny_thrown_projectiles, deny_glowing=excluded.deny_glowing, deny_redstone_interaction=excluded.deny_redstone_interaction, deny_door_interaction=excluded.deny_door_interaction, "
|
||||||
+ "deny_noteblock_jukebox=excluded.deny_noteblock_jukebox, deny_lead=excluded.deny_lead, deny_crop_harvest=excluded.deny_crop_harvest, deny_wool_shear=excluded.deny_wool_shear, deny_animal_feeding=excluded.deny_animal_feeding, "
|
+ "deny_noteblock_jukebox=excluded.deny_noteblock_jukebox, deny_lead=excluded.deny_lead, deny_crop_harvest=excluded.deny_crop_harvest, deny_wool_shear=excluded.deny_wool_shear, deny_animal_feeding=excluded.deny_animal_feeding, "
|
||||||
+ "warp_x=excluded.warp_x, warp_y=excluded.warp_y, warp_z=excluded.warp_z, warp_yaw=excluded.warp_yaw, warp_pitch=excluded.warp_pitch, warp_world=excluded.warp_world, deny_container=excluded.deny_container, deny_mob_attack=excluded.deny_mob_attack, deny_sign_edit=excluded.deny_sign_edit, is_public_building=excluded.is_public_building, allow_visitor_teleport=excluded.allow_visitor_teleport, deny_farmland_trample=excluded.deny_farmland_trample, deny_ender_teleport=excluded.deny_ender_teleport, create_cost=excluded.create_cost, deny_spawn_egg=excluded.deny_spawn_egg, deny_wax=excluded.deny_wax, bad_effects=excluded.bad_effects, deny_villager_trade=excluded.deny_villager_trade, confiscate_count=excluded.confiscate_count, return_on_leave=excluded.return_on_leave");
|
+ "warp_x=excluded.warp_x, warp_y=excluded.warp_y, warp_z=excluded.warp_z, warp_yaw=excluded.warp_yaw, warp_pitch=excluded.warp_pitch, warp_world=excluded.warp_world, deny_container=excluded.deny_container, deny_mob_attack=excluded.deny_mob_attack, deny_sign_edit=excluded.deny_sign_edit, is_public_building=excluded.is_public_building, allow_visitor_teleport=excluded.allow_visitor_teleport, deny_farmland_trample=excluded.deny_farmland_trample, deny_ender_teleport=excluded.deny_ender_teleport, create_cost=excluded.create_cost, deny_spawn_egg=excluded.deny_spawn_egg, deny_wax=excluded.deny_wax, bad_effects=excluded.bad_effects, deny_villager_trade=excluded.deny_villager_trade, confiscate_count=excluded.confiscate_count, return_on_leave=excluded.return_on_leave, parent_id=excluded.parent_id");
|
||||||
|
|
||||||
stmt.setString(1, ac.name);
|
stmt.setString(1, ac.name);
|
||||||
stmt.setString(2, ac.owner != null ? ac.owner : "");
|
stmt.setString(2, ac.owner != null ? ac.owner : "");
|
||||||
@@ -10853,6 +11167,7 @@ public class AreaProtection implements Listener {
|
|||||||
stmt.setInt(74, ac.denyVillagerTrade ? 1 : 0);
|
stmt.setInt(74, ac.denyVillagerTrade ? 1 : 0);
|
||||||
stmt.setInt(75, ac.confiscateCount);
|
stmt.setInt(75, ac.confiscateCount);
|
||||||
stmt.setInt(76, ac.returnOnLeave ? 1 : 0);
|
stmt.setInt(76, ac.returnOnLeave ? 1 : 0);
|
||||||
|
stmt.setInt(77, ac.parentId); // ★ 第57批续21 子领地父ID(0=主领地)
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
// ★ 领地设置变更:立即触发PHP同步(防抖10秒)
|
// ★ 领地设置变更:立即触发PHP同步(防抖10秒)
|
||||||
@@ -10951,8 +11266,27 @@ public class AreaProtection implements Listener {
|
|||||||
/**
|
/**
|
||||||
* 从数据库获取领地ID
|
* 从数据库获取领地ID
|
||||||
*/
|
*/
|
||||||
|
/** ★ 第57批续21:按 area_lands.id 反查领地名(子领地继承判定用) */
|
||||||
|
public String findLandNameById(int id) {
|
||||||
|
if (dbConnection == null || id <= 0) return null;
|
||||||
|
try {
|
||||||
|
PreparedStatement stmt = dbConnection.prepareStatement("SELECT name FROM area_lands WHERE id = ?");
|
||||||
|
stmt.setInt(1, id);
|
||||||
|
ResultSet rs = stmt.executeQuery();
|
||||||
|
String n = rs.next() ? rs.getString("name") : null;
|
||||||
|
rs.close();
|
||||||
|
stmt.close();
|
||||||
|
return n;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getLandIdFromDb(String name) {
|
public int getLandIdFromDb(String name) {
|
||||||
if (dbConnection == null) return -1;
|
if (dbConnection == null) return -1;
|
||||||
|
// ★ 第65批修复(#345):先查内存缓存,命中直接返回
|
||||||
|
Integer cached = landIdCache.get(name);
|
||||||
|
if (cached != null) return cached;
|
||||||
try {
|
try {
|
||||||
PreparedStatement stmt = dbConnection.prepareStatement("SELECT id FROM area_lands WHERE name = ?");
|
PreparedStatement stmt = dbConnection.prepareStatement("SELECT id FROM area_lands WHERE name = ?");
|
||||||
stmt.setString(1, name);
|
stmt.setString(1, name);
|
||||||
@@ -10960,6 +11294,8 @@ public class AreaProtection implements Listener {
|
|||||||
int id = rs.next() ? rs.getInt("id") : -1;
|
int id = rs.next() ? rs.getInt("id") : -1;
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
// 缓存结果(-1 也缓存,避免频繁查不存在的领地)
|
||||||
|
landIdCache.put(name, id);
|
||||||
return id;
|
return id;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -11166,6 +11502,10 @@ public class AreaProtection implements Listener {
|
|||||||
areas.put(newName, ac);
|
areas.put(newName, ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第65批修复(#345):landId 缓存迁移(landId 不变,只是 key 换了)
|
||||||
|
Integer landId = landIdCache.remove(oldName);
|
||||||
|
if (landId != null) landIdCache.put(newName, landId);
|
||||||
|
|
||||||
// 4d. 更新内存中的成员权限缓存等(如果有以旧名字为key的缓存)
|
// 4d. 更新内存中的成员权限缓存等(如果有以旧名字为key的缓存)
|
||||||
// areaPlayerWhitelist 也以 landName 为 key,需同步
|
// areaPlayerWhitelist 也以 landName 为 key,需同步
|
||||||
java.util.Set<String> whitelist = areaPlayerWhitelist.remove(oldName);
|
java.util.Set<String> whitelist = areaPlayerWhitelist.remove(oldName);
|
||||||
@@ -13782,6 +14122,10 @@ public class AreaProtection implements Listener {
|
|||||||
public boolean allowVisitorTeleport = false;
|
public boolean allowVisitorTeleport = false;
|
||||||
// ★ 创建领地时实际扣款金额(删除领地按比例退费的基数;0=无扣款)
|
// ★ 创建领地时实际扣款金额(删除领地按比例退费的基数;0=无扣款)
|
||||||
public int createCost = 0;
|
public int createCost = 0;
|
||||||
|
// ★ 第57批续21 子领地:父领地(主领地)的 area_lands.id;0=主领地(无父)
|
||||||
|
// 子领地必须完整包含在某主领地内(1级,不可再嵌套),owner 沿用主领地主,
|
||||||
|
// 权限行挂在父领地 land_id 下(area_land_permissions),可单独收紧/放行。
|
||||||
|
public int parentId = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -13948,11 +14292,27 @@ public class AreaProtection implements Listener {
|
|||||||
int x2 = cx + 1, z2 = cz + 1;
|
int x2 = cx + 1, z2 = cz + 1;
|
||||||
int area = 9; // 3×3
|
int area = 9; // 3×3
|
||||||
|
|
||||||
// ★ 检查这个区域是否与其他领地重叠
|
// ★ 第57批续21 先查 3×3 是否完全包含于某主领地 → 领地主身份合格则自动转 confirm_create 建子领地
|
||||||
|
AreaConfig qMain = findContainingMainLand(p.getWorld().getName(), x1, z1, x2, z2);
|
||||||
|
if (qMain != null) {
|
||||||
|
if (isQualifiedLandManager(p, qMain)) {
|
||||||
|
p.sendMessage("§a§l[防护] §f检测到 3×3 区域在主领地 §e" + qMain.name
|
||||||
|
+ " §f内,已为你转为创建子领地");
|
||||||
|
p.performCommand("protect confirm_create " + p.getName());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§c§l[防护] §f该区域已在领地 §e" + qMain.name
|
||||||
|
+ " §f内,你需具备该领地的领主/管理员身份才能创建子领地");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ★ 部分重叠(跨边界)仍拒绝
|
||||||
for (AreaConfig other : areas.values()) {
|
for (AreaConfig other : areas.values()) {
|
||||||
|
if (other.parentId != 0) continue;
|
||||||
if (!other.world.equalsIgnoreCase(p.getWorld().getName())) continue;
|
if (!other.world.equalsIgnoreCase(p.getWorld().getName())) continue;
|
||||||
// AABB重叠检测
|
int omx = Math.min(other.x1, other.x2), omx2 = Math.max(other.x1, other.x2);
|
||||||
if (x1 <= other.x2 && x2 >= other.x1 && z1 <= other.z2 && z2 >= other.z1) {
|
int omz = Math.min(other.z1, other.z2), omz2 = Math.max(other.z1, other.z2);
|
||||||
|
if (x1 <= omx2 && x2 >= omx && z1 <= omz2 && z2 >= omz) {
|
||||||
p.sendMessage("§c§l[防护] §f该区域与领地 §e" + other.name + " §f重叠,请走远点再试");
|
p.sendMessage("§c§l[防护] §f该区域与领地 §e" + other.name + " §f重叠,请走远点再试");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ public class BanBroadcastManager implements Listener {
|
|||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
long cut0 = resolveStartCutoff();
|
long cut0 = resolveStartCutoff();
|
||||||
File bf0 = bannedPlayersFile();
|
File bf0 = bannedPlayersFile();
|
||||||
|
ensureTimestampFile();
|
||||||
plugin.getLogger().info("[封禁播报] 已启动,模式=" + modeName()
|
plugin.getLogger().info("[封禁播报] 已启动,模式=" + modeName()
|
||||||
+ " 间隔=" + minInterval + "~" + maxInterval + "s 每页" + pageSize + "条"
|
+ " 间隔=" + minInterval + "~" + maxInterval + "s 每页" + pageSize + "条"
|
||||||
+ " 起点=" + (cut0 > 0 ? new SimpleDateFormat("yyyy-MM-dd").format(new Date(cut0)) : "不限")
|
+ " 起点=" + (cut0 > 0 ? new SimpleDateFormat("yyyy-MM-dd").format(new Date(cut0)) : "不限")
|
||||||
@@ -497,37 +498,95 @@ public class BanBroadcastManager implements Listener {
|
|||||||
if (!startCutoffAuto) return startCutoffMs;
|
if (!startCutoffAuto) return startCutoffMs;
|
||||||
if (autoCutoffMs < 0) {
|
if (autoCutoffMs < 0) {
|
||||||
autoCutoffMs = 0;
|
autoCutoffMs = 0;
|
||||||
long folderCreated = 0;
|
long tsFile = readTimestampFile();
|
||||||
try {
|
if (tsFile > 0) {
|
||||||
File df = plugin.getDataFolder();
|
autoCutoffMs = tsFile;
|
||||||
if (df != null && df.exists()) {
|
} else {
|
||||||
long t = java.nio.file.Files.readAttributes(df.toPath(),
|
long folderCreated = 0;
|
||||||
java.nio.file.attribute.BasicFileAttributes.class)
|
try {
|
||||||
.creationTime().toMillis();
|
File df = plugin.getDataFolder();
|
||||||
if (t > 0) folderCreated = t;
|
if (df != null && df.exists()) {
|
||||||
|
long t = java.nio.file.Files.readAttributes(df.toPath(),
|
||||||
|
java.nio.file.attribute.BasicFileAttributes.class)
|
||||||
|
.creationTime().toMillis();
|
||||||
|
if (t > 0) folderCreated = t;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
warn("读取插件数据目录创建时间失败,本次不过滤历史封禁: "
|
||||||
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
if (folderCreated > 0) {
|
||||||
warn("读取插件数据目录创建时间失败,本次不过滤历史封禁: "
|
long cap = System.currentTimeMillis() - MAX_AUTO_CUTOFF_WINDOW_MS;
|
||||||
+ e.getMessage());
|
autoCutoffMs = Math.min(folderCreated, cap);
|
||||||
}
|
if (folderCreated > cap) {
|
||||||
if (folderCreated > 0) {
|
warn("插件数据目录创建时间 " + fmtCutoff(folderCreated)
|
||||||
long cap = System.currentTimeMillis() - MAX_AUTO_CUTOFF_WINDOW_MS;
|
+ " 晚于180天前(目录可能被重建/迁移),"
|
||||||
autoCutoffMs = Math.min(folderCreated, cap);
|
+ "自动起点回退为 " + fmtCutoff(cap)
|
||||||
if (folderCreated > cap) {
|
+ ",近半年内的生效封禁照常播报"
|
||||||
warn("插件数据目录创建时间 " + fmtCutoff(folderCreated)
|
+ "(可在 ban/规则配置.md 手动填「播报起点」精确控制)");
|
||||||
+ " 晚于180天前(目录可能被重建/迁移),"
|
}
|
||||||
+ "自动起点回退为 " + fmtCutoff(cap)
|
}
|
||||||
+ ",近半年内的生效封禁照常播报"
|
if (autoCutoffMs <= 0) {
|
||||||
+ "(可在 ban/规则配置.md 手动填「播报起点」精确控制)");
|
warn("取不到插件数据目录创建时间,历史封禁过滤已关闭"
|
||||||
|
+ "(可在 ban/规则配置.md 里手动填「播报起点」锁定时间)");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (autoCutoffMs <= 0) {
|
|
||||||
warn("取不到插件数据目录创建时间,历史封禁过滤已关闭"
|
|
||||||
+ "(可在 ban/规则配置.md 里手动填「播报起点」锁定时间)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return autoCutoffMs;
|
return autoCutoffMs;
|
||||||
}
|
}
|
||||||
|
/** ★ 第57批:读插件数据目录中的时间戳文件(10位数字无后缀)
|
||||||
|
* 优先级:用户配置 > 时间戳文件 > 插件数据目录创建时间
|
||||||
|
*/
|
||||||
|
private long readTimestampFile() {
|
||||||
|
try {
|
||||||
|
File df = plugin.getDataFolder();
|
||||||
|
if (df == null) return 0;
|
||||||
|
File[] files = df.listFiles();
|
||||||
|
if (files == null) return 0;
|
||||||
|
// ★ 第57批续:多份时间戳文件取最小值(用户手动放的固定值 < 插件启动创建的当前秒值)
|
||||||
|
long minTs = -1;
|
||||||
|
for (File f : files) {
|
||||||
|
String name = f.getName();
|
||||||
|
if (name.length() == 10 && name.chars().allMatch(Character::isDigit)) {
|
||||||
|
long ts = Long.parseLong(name);
|
||||||
|
if (ts > 0 && (minTs < 0 || ts < minTs)) minTs = ts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (minTs > 0) return minTs * 1000L;
|
||||||
|
} catch (Exception e) {
|
||||||
|
warn("读时间戳文件失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ★ 第57批:插件启动时创建时间戳文件(如果不存在)
|
||||||
|
* 文件名 = 当前时间戳(秒),内容为空
|
||||||
|
*/
|
||||||
|
private void ensureTimestampFile() {
|
||||||
|
try {
|
||||||
|
File df = plugin.getDataFolder();
|
||||||
|
if (df == null || !df.exists()) return;
|
||||||
|
// ★ 第57批续:目录里已有任意时间戳文件就跳过,不重复创建
|
||||||
|
File[] files = df.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File f : files) {
|
||||||
|
String name = f.getName();
|
||||||
|
if (name.length() == 10 && name.chars().allMatch(Character::isDigit)) {
|
||||||
|
return; // 已有时间戳文件,不创建
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long tsSec = System.currentTimeMillis() / 1000L;
|
||||||
|
File tsFile = new File(df, String.valueOf(tsSec));
|
||||||
|
if (!tsFile.exists()) {
|
||||||
|
java.nio.file.Files.createFile(tsFile.toPath());
|
||||||
|
plugin.getLogger().info("[封禁播报] 已创建时间戳文件: " + tsFile.getName());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
warn("创建时间戳文件失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 28批:自动播报起点最多回溯 180 天(约半年)——数据目录重建时起点不得过新 */
|
/** 28批:自动播报起点最多回溯 180 天(约半年)——数据目录重建时起点不得过新 */
|
||||||
private static final long MAX_AUTO_CUTOFF_WINDOW_MS = 180L * 24 * 3600 * 1000;
|
private static final long MAX_AUTO_CUTOFF_WINDOW_MS = 180L * 24 * 3600 * 1000;
|
||||||
|
|||||||
@@ -53,6 +53,55 @@ public class BondManager {
|
|||||||
initDB();
|
initDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 信誉积分债券交易限额(★ 第63批) =====
|
||||||
|
|
||||||
|
/** 交易型类型(买卖全算限额),非交易型(管理员/系统)不受限 */
|
||||||
|
private static boolean isTradeType(String type) {
|
||||||
|
return TX_TRANSFER_OUT.equals(type)
|
||||||
|
|| TX_TRANSFER_IN.equals(type)
|
||||||
|
|| TX_SHOP_BUY.equals(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询玩家本小时债券交易累计总额(买入+卖出全算)
|
||||||
|
*/
|
||||||
|
private int getHourlyBondTradeTotal(String player) {
|
||||||
|
try {
|
||||||
|
long oneHourAgo = System.currentTimeMillis() - 3600_000L;
|
||||||
|
PreparedStatement ps = db.prepareStatement(
|
||||||
|
"SELECT COALESCE(SUM(amount), 0) as total FROM bond_transaction "
|
||||||
|
+ "WHERE player_name=? AND time > ?");
|
||||||
|
ps.setString(1, player);
|
||||||
|
ps.setLong(2, oneHourAgo);
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
int total = 0;
|
||||||
|
if (rs.next()) total = rs.getInt("total");
|
||||||
|
rs.close(); ps.close();
|
||||||
|
return total;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:检查玩家债券交易是否超限
|
||||||
|
* @return true=允许交易,false=超限被拒
|
||||||
|
*/
|
||||||
|
private boolean checkBondTradeLimit(String player, int amount) {
|
||||||
|
// 管理员操作不受限
|
||||||
|
if (plugin.getCreditManager() == null) return true;
|
||||||
|
double limit = plugin.getCreditManager().getBondTradeLimit(player);
|
||||||
|
if (limit <= 0) return true; // 无限制
|
||||||
|
// 获取倍数(>80分 → 1.2倍)
|
||||||
|
double multiplier = plugin.getCreditManager().getBondTradeMultiplier(player);
|
||||||
|
double effectiveLimit = limit * multiplier;
|
||||||
|
int currentTotal = getHourlyBondTradeTotal(player);
|
||||||
|
if (currentTotal + amount > effectiveLimit) {
|
||||||
|
return false; // 超限
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ★ 第十批(2026-10-12):暴露 bond.db 连接。
|
* ★ 第十批(2026-10-12):暴露 bond.db 连接。
|
||||||
* bond_transaction 在 bond.db(财务债券/),不在 login.db——
|
* bond_transaction 在 bond.db(财务债券/),不在 login.db——
|
||||||
@@ -320,6 +369,14 @@ public class BondManager {
|
|||||||
String operator,
|
String operator,
|
||||||
String reason) {
|
String reason) {
|
||||||
if (isFrozen(player)) return -1;
|
if (isFrozen(player)) return -1;
|
||||||
|
// ★ 第63批:交易型操作检查债券限额
|
||||||
|
if (isTradeType(type) && !checkBondTradeLimit(player, Math.abs(amount))) {
|
||||||
|
Player p = org.bukkit.Bukkit.getPlayerExact(player);
|
||||||
|
if (p != null) {
|
||||||
|
p.sendMessage("§c§l[信誉积分] §c债券交易超限,本小时交易额已达上限");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return addBondsInternal(player, amount,
|
return addBondsInternal(player, amount,
|
||||||
type, targetPlayer, operator, reason);
|
type, targetPlayer, operator, reason);
|
||||||
}
|
}
|
||||||
@@ -475,13 +532,21 @@ public class BondManager {
|
|||||||
|
|
||||||
// ======================== 扣除债券 ========================
|
// ======================== 扣除债券 ========================
|
||||||
|
|
||||||
/** 完整版:含冻结检查 + 流水记录 */
|
/** 完整版:含冻结检查 + 信誉积分限额 + 流水记录 */
|
||||||
public boolean deductBonds(String player, int amount,
|
public boolean deductBonds(String player, int amount,
|
||||||
String type,
|
String type,
|
||||||
String targetPlayer,
|
String targetPlayer,
|
||||||
String operator,
|
String operator,
|
||||||
String reason) {
|
String reason) {
|
||||||
if (isFrozen(player)) return false;
|
if (isFrozen(player)) return false;
|
||||||
|
// ★ 第63批:交易型操作检查债券限额
|
||||||
|
if (isTradeType(type) && !checkBondTradeLimit(player, Math.abs(amount))) {
|
||||||
|
Player p = org.bukkit.Bukkit.getPlayerExact(player);
|
||||||
|
if (p != null) {
|
||||||
|
p.sendMessage("§c§l[信誉积分] §c债券交易超限,本小时交易额已达上限");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return deductBondsInternal(player, amount,
|
return deductBondsInternal(player, amount,
|
||||||
type, targetPlayer, operator, reason);
|
type, targetPlayer, operator, reason);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ public class CDKManager {
|
|||||||
&& plugin.getBlacklist().isBlacklisted(player))
|
&& plugin.getBlacklist().isBlacklisted(player))
|
||||||
return "fail:blacklisted";
|
return "fail:blacklisted";
|
||||||
|
|
||||||
|
// ★ 第63批:信誉积分低于-10分禁止使用CDK
|
||||||
|
if (plugin.getCreditManager() != null
|
||||||
|
&& plugin.getCreditManager().isRestricted(player, "block_cdk_and_bond"))
|
||||||
|
return "fail:credit_restricted";
|
||||||
|
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = db.prepareStatement(
|
||||||
"SELECT amount,type,used FROM cdk "
|
"SELECT amount,type,used FROM cdk "
|
||||||
+ "WHERE code=?");
|
+ "WHERE code=?");
|
||||||
|
|||||||
@@ -1864,16 +1864,51 @@ public class ChatFilterManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查消息是否包含敏感词
|
* 检查消息是否包含敏感词
|
||||||
|
* ★ 第64批修复(#333):归一化后匹配,防止 "s.b" / "s b" / "s*b" 绕过
|
||||||
|
* 归一化:去除空格、点号、连字符、星号、下划线、斜杠等分隔符
|
||||||
|
* "s.b" / "s b" / "s*b" / "s_b" 全部归一化为 "sb" 再匹配
|
||||||
|
* 短 ASCII 词(≤3 字符,如 "sb"/"cao")用词边界正则防误匹配
|
||||||
|
* ("is bad"→"isbad" 含 "sb" 子串,词边界可排除)
|
||||||
|
* 白名单URL不受影响(URL在 extractUrls/shouldBlockUrl 单独处理,不走这里)
|
||||||
* @return 匹配到的敏感词列表(空列表表示无匹配)
|
* @return 匹配到的敏感词列表(空列表表示无匹配)
|
||||||
*/
|
*/
|
||||||
public List<String> checkSensitiveWords(String msg) {
|
public List<String> checkSensitiveWords(String msg) {
|
||||||
if (msg == null || msg.isEmpty() || sensitiveWords.isEmpty())
|
if (msg == null || msg.isEmpty() || sensitiveWords.isEmpty())
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
String lower = msg.toLowerCase();
|
String lower = msg.toLowerCase();
|
||||||
|
// ★ 第65批修复(#339):归一化扩展 + 叠词压缩
|
||||||
|
// 分隔符:空格、点号、连字符、星号、下划线、斜杠、反斜杠、反引号、中点号、波浪线
|
||||||
|
// "c`n`m" → "cnm", "s·b" → "sb", "s~b" → "sb"
|
||||||
|
String normalized = lower.replaceAll("[\\s.\\-*_/\\\\`·~]", "");
|
||||||
|
// ★ 叠词压缩:连续重复字母 → 单字母
|
||||||
|
// "ssbb" → "sb", "ccnnmm" → "cm", "sssb" → "sb"
|
||||||
|
// 逐字符扫描:同字母连续出现则跳过
|
||||||
|
StringBuilder compressed = new StringBuilder();
|
||||||
|
for (int i = 0; i < normalized.length(); i++) {
|
||||||
|
char c = normalized.charAt(i);
|
||||||
|
if (i > 0 && c == normalized.charAt(i - 1)) continue; // 跳过重复字母
|
||||||
|
compressed.append(c);
|
||||||
|
}
|
||||||
|
String compact = compressed.toString();
|
||||||
List<String> matched = new ArrayList<>();
|
List<String> matched = new ArrayList<>();
|
||||||
for (String sw : sensitiveWords) {
|
for (String sw : sensitiveWords) {
|
||||||
if (lower.contains(sw)) {
|
if (sw.isEmpty()) continue;
|
||||||
matched.add(sw);
|
if (sw.length() <= 3 && sw.matches("[a-z]+")) {
|
||||||
|
// 短 ASCII 词:词边界正则,只在独立出现时匹配
|
||||||
|
// 归一化后 "sb你" → "sb" 后跟中文(非 a-z)→ 匹配;"isbad" → "sb" 前后都是 a-z → 不匹配
|
||||||
|
java.util.regex.Pattern p = java.util.regex.Pattern.compile(
|
||||||
|
"(?<![a-z])" + java.util.regex.Pattern.quote(sw) + "(?![a-z])");
|
||||||
|
if (p.matcher(normalized).find() || p.matcher(compact).find()) {
|
||||||
|
matched.add(sw);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 长词或中文词:原文、归一化文本、压缩文本各查一次
|
||||||
|
// 原文查:保持原有行为("fuck you" 直接含 "fuck")
|
||||||
|
// 归一化查:捕获 "s.h.i.t" → "shit" 等分隔符变体
|
||||||
|
// 压缩查:捕获 "shhhiitt" → "shit" 等叠词变体
|
||||||
|
if (lower.contains(sw) || normalized.contains(sw) || compact.contains(sw)) {
|
||||||
|
matched.add(sw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return matched;
|
return matched;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -133,6 +133,10 @@ public class DatabaseManager {
|
|||||||
"TEXT DEFAULT ''");
|
"TEXT DEFAULT ''");
|
||||||
safeAdd(st, "twofa_pending_at",
|
safeAdd(st, "twofa_pending_at",
|
||||||
"INTEGER DEFAULT 0");
|
"INTEGER DEFAULT 0");
|
||||||
|
// ★ 第47批:绑定时间(秒)——与网页端 web_account_2fa.bound_at 对齐,
|
||||||
|
// 双向同步冲突时"取时间新者"用
|
||||||
|
safeAdd(st, "twofa_bound_at",
|
||||||
|
"INTEGER DEFAULT 0");
|
||||||
// ===== 2FA 恢复代码(SHA-256 逗号连接存库,明文只发邮件,一次性有效)=====
|
// ===== 2FA 恢复代码(SHA-256 逗号连接存库,明文只发邮件,一次性有效)=====
|
||||||
safeAdd(st, "twofa_recovery_codes",
|
safeAdd(st, "twofa_recovery_codes",
|
||||||
"TEXT DEFAULT ''");
|
"TEXT DEFAULT ''");
|
||||||
@@ -146,6 +150,20 @@ public class DatabaseManager {
|
|||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第52批:存量脏凭证一次性清洗——PHP json_encode 把 base64 中的
|
||||||
|
// / 转义成 \/,历史解析层漏还原曾把反斜杠写进库(hash 脏 → 密码恒错)。
|
||||||
|
// base64 合法字符永不含反斜杠(char92),删除即还原正确值;WHERE 带
|
||||||
|
// instr 条件,无脏值时为近似 no-op,可每次启动安全重跑。
|
||||||
|
try {
|
||||||
|
st.executeUpdate("UPDATE users SET password_hash=REPLACE(password_hash, char(92), '') "
|
||||||
|
+ "WHERE instr(password_hash, char(92))>0");
|
||||||
|
st.executeUpdate("UPDATE users SET password_salt=REPLACE(password_salt, char(92), '') "
|
||||||
|
+ "WHERE instr(password_salt, char(92))>0");
|
||||||
|
st.executeUpdate("UPDATE users SET temp_password=REPLACE(temp_password, char(92), '') "
|
||||||
|
+ "WHERE instr(temp_password, char(92))>0");
|
||||||
|
} catch (SQLException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 背包备份表:安全迁移 =====
|
// ===== 背包备份表:安全迁移 =====
|
||||||
// 检查旧表是否存在(用 inventory_data 列判断)
|
// 检查旧表是否存在(用 inventory_data 列判断)
|
||||||
boolean hasOldTable = false;
|
boolean hasOldTable = false;
|
||||||
@@ -508,7 +526,24 @@ public class DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取数据库连接,连接已关闭时自动重连。★ 第58批修复:避免 SN/信誉同步等模块拿到已关闭连接报 "database connection closed"。 */
|
||||||
public Connection getConnection() {
|
public Connection getConnection() {
|
||||||
|
try {
|
||||||
|
if (db == null || db.isClosed()) {
|
||||||
|
File dbDir = new File(dataFolder, "登录凭证");
|
||||||
|
dbDir.mkdirs();
|
||||||
|
File dbFile = new File(dbDir, "login.db");
|
||||||
|
db = DriverManager.getConnection(
|
||||||
|
"jdbc:sqlite:" + dbFile.getAbsolutePath());
|
||||||
|
Statement st = db.createStatement();
|
||||||
|
st.execute("PRAGMA journal_mode=WAL");
|
||||||
|
st.execute("PRAGMA busy_timeout=5000");
|
||||||
|
st.close();
|
||||||
|
logger.warning("[Sdf1_login] 数据库连接已自动重建");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.severe("[Sdf1_login] 数据库自动重连失败: " + e.getMessage());
|
||||||
|
}
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,7 +721,7 @@ public class DatabaseManager {
|
|||||||
|
|
||||||
public boolean userExists(String name) {
|
public boolean userExists(String name) {
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = getConnection().prepareStatement(
|
||||||
"SELECT 1 FROM users "
|
"SELECT 1 FROM users "
|
||||||
+ "WHERE player_name=?");
|
+ "WHERE player_name=?");
|
||||||
ps.setString(1, name);
|
ps.setString(1, name);
|
||||||
@@ -706,7 +741,7 @@ public class DatabaseManager {
|
|||||||
public boolean userExistsIgnoreCase(String name) {
|
public boolean userExistsIgnoreCase(String name) {
|
||||||
if (name == null || name.isEmpty()) return false;
|
if (name == null || name.isEmpty()) return false;
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = getConnection().prepareStatement(
|
||||||
"SELECT 1 FROM users "
|
"SELECT 1 FROM users "
|
||||||
+ "WHERE player_name=? "
|
+ "WHERE player_name=? "
|
||||||
+ "COLLATE NOCASE");
|
+ "COLLATE NOCASE");
|
||||||
@@ -729,7 +764,7 @@ public class DatabaseManager {
|
|||||||
public boolean userExistsStrict(String name) {
|
public boolean userExistsStrict(String name) {
|
||||||
if (name == null || name.isEmpty()) return false;
|
if (name == null || name.isEmpty()) return false;
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = getConnection().prepareStatement(
|
||||||
"SELECT 1 FROM users "
|
"SELECT 1 FROM users "
|
||||||
+ "WHERE player_name=? "
|
+ "WHERE player_name=? "
|
||||||
+ "COLLATE NOCASE");
|
+ "COLLATE NOCASE");
|
||||||
@@ -744,8 +779,22 @@ public class DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第52批:base64 凭证白名单清洗。
|
||||||
|
* PHP json_encode 默认把 base64 中的 / 转义成 \/,历史解析层漏还原
|
||||||
|
* 会把反斜杠写进库(hash 脏值 → 游戏/网页两端密码恒错)。
|
||||||
|
* base64 合法字符永不含反斜杠,先还原 \/ 再按白名单清洗即得正确值;
|
||||||
|
* 写库与比对两侧同款清洗,保证对称。
|
||||||
|
*/
|
||||||
|
public static String b64Clean(String v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
return v.replace("\\/", "/").replaceAll("[^A-Za-z0-9+/=]", "");
|
||||||
|
}
|
||||||
|
|
||||||
public void createUser(String name, String hash,
|
public void createUser(String name, String hash,
|
||||||
String salt) {
|
String salt) {
|
||||||
|
hash = b64Clean(hash);
|
||||||
|
salt = b64Clean(salt);
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = db.prepareStatement(
|
||||||
"INSERT INTO users "
|
"INSERT INTO users "
|
||||||
@@ -770,6 +819,8 @@ public class DatabaseManager {
|
|||||||
* 更新玩家密码凭证(salt + hash),用于Web重新注册时同步
|
* 更新玩家密码凭证(salt + hash),用于Web重新注册时同步
|
||||||
*/
|
*/
|
||||||
public void updatePassword(String name, String hash, String salt) {
|
public void updatePassword(String name, String hash, String salt) {
|
||||||
|
hash = b64Clean(hash);
|
||||||
|
salt = b64Clean(salt);
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = db.prepareStatement(
|
PreparedStatement ps = db.prepareStatement(
|
||||||
"UPDATE users SET password_hash = ?, password_salt = ? WHERE player_name = ?");
|
"UPDATE users SET password_hash = ?, password_salt = ? WHERE player_name = ?");
|
||||||
@@ -831,7 +882,8 @@ public class DatabaseManager {
|
|||||||
rs.getString("password_hash");
|
rs.getString("password_hash");
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
return hash.equals(mainHash);
|
// ★ 第52批:比对前双侧清洗(存量脏 hash 容错,见 b64Clean)
|
||||||
|
return b64Clean(hash).equals(b64Clean(mainHash));
|
||||||
} else {
|
} else {
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -870,7 +922,7 @@ public class DatabaseManager {
|
|||||||
ps.close();
|
ps.close();
|
||||||
if (tempHash != null
|
if (tempHash != null
|
||||||
&& !tempHash.isEmpty()
|
&& !tempHash.isEmpty()
|
||||||
&& mainHash.equals(tempHash)
|
&& b64Clean(mainHash).equals(b64Clean(tempHash))
|
||||||
&& System.currentTimeMillis() < expire
|
&& System.currentTimeMillis() < expire
|
||||||
&& used != 1) {
|
&& used != 1) {
|
||||||
return "temp";
|
return "temp";
|
||||||
@@ -919,7 +971,7 @@ public class DatabaseManager {
|
|||||||
ps.close();
|
ps.close();
|
||||||
if (tempHash != null
|
if (tempHash != null
|
||||||
&& !tempHash.isEmpty()
|
&& !tempHash.isEmpty()
|
||||||
&& hash.equals(tempHash)
|
&& b64Clean(hash).equals(b64Clean(tempHash))
|
||||||
&& used != 1) {
|
&& used != 1) {
|
||||||
return "temp";
|
return "temp";
|
||||||
}
|
}
|
||||||
@@ -3031,17 +3083,20 @@ public class DatabaseManager {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 清理超过 cutoff(毫秒时间戳)的领地记录,返回删除行数 */
|
/** 清理超过 cutoff(毫秒时间戳)的领地记录,返回删除行数
|
||||||
|
* ★ 第58批续27修复:改用 getConnection() 而非直接用 db 字段,
|
||||||
|
* 避免 db 在 worker 线程被重建后,scheduler 线程持有旧引用报 "database connection closed" */
|
||||||
public int pruneLandRecordsOlderThan(long cutoff) {
|
public int pruneLandRecordsOlderThan(long cutoff) {
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps1 = db.prepareStatement(
|
Connection conn = getConnection();
|
||||||
|
PreparedStatement ps1 = conn.prepareStatement(
|
||||||
"DELETE FROM land_block_log WHERE time < ?");
|
"DELETE FROM land_block_log WHERE time < ?");
|
||||||
ps1.setLong(1, cutoff);
|
ps1.setLong(1, cutoff);
|
||||||
deleted += ps1.executeUpdate();
|
deleted += ps1.executeUpdate();
|
||||||
ps1.close();
|
ps1.close();
|
||||||
|
|
||||||
PreparedStatement ps2 = db.prepareStatement(
|
PreparedStatement ps2 = conn.prepareStatement(
|
||||||
"DELETE FROM land_container_log WHERE time < ?");
|
"DELETE FROM land_container_log WHERE time < ?");
|
||||||
ps2.setLong(1, cutoff);
|
ps2.setLong(1, cutoff);
|
||||||
deleted += ps2.executeUpdate();
|
deleted += ps2.executeUpdate();
|
||||||
|
|||||||
@@ -225,6 +225,12 @@ public class GUIManager implements Listener {
|
|||||||
? "§e点击打开GUI"
|
? "§e点击打开GUI"
|
||||||
: "§e点击打开CLI"));
|
: "§e点击打开CLI"));
|
||||||
|
|
||||||
|
// ★ 信誉积分 - 40号位(领地系统旁边)
|
||||||
|
g.setItem(40, mkItem(Material.GOLD_INGOT,
|
||||||
|
"§d§l信誉积分",
|
||||||
|
"§7上报好人好事/举报违规",
|
||||||
|
"§7查看我的积分与明细"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ===== Row0(0-8): 自定义菜单项 =====
|
// ===== Row0(0-8): 自定义菜单项 =====
|
||||||
@@ -710,6 +716,12 @@ public class GUIManager implements Listener {
|
|||||||
|
|
||||||
public void teleportToBiome(
|
public void teleportToBiome(
|
||||||
Player p, String category) {
|
Player p, String category) {
|
||||||
|
// ★ 第63批:信誉积分低于20分禁止使用群系传送(群戏传送)
|
||||||
|
if (plugin.getCreditManager() != null
|
||||||
|
&& plugin.getCreditManager().isRestricted(p.getName(), "block_biome_tp")) {
|
||||||
|
p.sendMessage("§c§l[信誉积分] §c你的积分过低,禁止使用群系传送");
|
||||||
|
return;
|
||||||
|
}
|
||||||
p.sendMessage("§e正在搜索 "
|
p.sendMessage("§e正在搜索 "
|
||||||
+ category + " 群系...");
|
+ category + " 群系...");
|
||||||
|
|
||||||
|
|||||||
@@ -646,14 +646,21 @@ public class GarbageManager implements Listener {
|
|||||||
// r == n 即「本轮结束时倾倒垃圾」(下一轮才真正倒)。
|
// r == n 即「本轮结束时倾倒垃圾」(下一轮才真正倒)。
|
||||||
final int nextRound = roundNow + 1; // 清理后开启的新一轮
|
final int nextRound = roundNow + 1; // 清理后开启的新一轮
|
||||||
final int r = ((nextRound - 1) % n) + 1;
|
final int r = ((nextRound - 1) % n) + 1;
|
||||||
if (r < n) {
|
// ★ 第45批:保留只有1轮(n==1)时
|
||||||
broadcast("§7[垃圾站] §f当前是第 §e" + r
|
// 每一轮都是倒垃圾轮,「本轮结束时
|
||||||
+ " §f轮,第 §e" + n
|
// 倾倒垃圾」无增量信息 → 不播报;
|
||||||
+ " §f轮倒垃圾,还剩 §e" + (n - r)
|
// 仅保留>1才提示轮次进度(用户
|
||||||
+ " §f轮倾倒垃圾");
|
// 2026-10-22 截图反馈)。
|
||||||
} else {
|
if (n > 1) {
|
||||||
broadcast("§7[垃圾站] §f当前是第 §e" + n
|
if (r < n) {
|
||||||
+ " §f轮,本轮结束时倾倒垃圾");
|
broadcast("§7[垃圾站] §f当前是第 §e" + r
|
||||||
|
+ " §f轮,第 §e" + n
|
||||||
|
+ " §f轮倒垃圾,还剩 §e" + (n - r)
|
||||||
|
+ " §f轮倾倒垃圾");
|
||||||
|
} else {
|
||||||
|
broadcast("§7[垃圾站] §f当前是第 §e" + n
|
||||||
|
+ " §f轮,本轮结束时倾倒垃圾");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印下次清理时间
|
// 打印下次清理时间
|
||||||
|
|||||||
@@ -12,6 +12,13 @@ public class LoginManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** ★第48批#244:/login 失败自动对账重试的每人限流(值=上次对账触发时刻) */
|
||||||
|
private final java.util.Map<String, Long> pwSyncRetryAt =
|
||||||
|
new java.util.concurrent.ConcurrentHashMap<>();
|
||||||
|
/** ★第48批#244:正在对账重试中的玩家(防递归) */
|
||||||
|
private final java.util.Set<String> pwSyncRetrying =
|
||||||
|
java.util.concurrent.ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
public boolean handleRegister(Player p,
|
public boolean handleRegister(Player p,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
@@ -69,6 +76,10 @@ public class LoginManager {
|
|||||||
// ★ 记录Java手动登录:5分钟内重连可直接放行(检查点1)
|
// ★ 记录Java手动登录:5分钟内重连可直接放行(检查点1)
|
||||||
if (plugin.webManager != null) {
|
if (plugin.webManager != null) {
|
||||||
plugin.webManager.recordJavaLogin(name, plugin.getPlayerIP(p));
|
plugin.webManager.recordJavaLogin(name, plugin.getPlayerIP(p));
|
||||||
|
// ★ 第57批:/login 成功后推送 login_verified=1 给 PHP
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
plugin.webManager.pushLoginVerified(name);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
p.setAllowFlight(false);
|
p.setAllowFlight(false);
|
||||||
p.setFlying(false);
|
p.setFlying(false);
|
||||||
@@ -191,6 +202,8 @@ public class LoginManager {
|
|||||||
if (matchMain) {
|
if (matchMain) {
|
||||||
// ★ IP风控双验证第一步:只认密码,不解冻、不恢复背包
|
// ★ IP风控双验证第一步:只认密码,不解冻、不恢复背包
|
||||||
if (markDualStep1(p, false)) return true;
|
if (markDualStep1(p, false)) return true;
|
||||||
|
// ★第48批#249:已绑定2FA → 密码过后强制第二关 /2fa code
|
||||||
|
if (requireTwoFaIfEnabled(p, false)) return true;
|
||||||
finishPasswordLogin(p, false);
|
finishPasswordLogin(p, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -202,11 +215,17 @@ public class LoginManager {
|
|||||||
if (pwdResult != null) {
|
if (pwdResult != null) {
|
||||||
// ★ IP风控双验证第一步:只认密码,不解冻、不恢复背包
|
// ★ IP风控双验证第一步:只认密码,不解冻、不恢复背包
|
||||||
if (markDualStep1(p, true)) return true;
|
if (markDualStep1(p, true)) return true;
|
||||||
|
// ★第48批#249:已绑定2FA → 密码过后强制第二关 /2fa code
|
||||||
|
if (requireTwoFaIfEnabled(p, true)) return true;
|
||||||
finishPasswordLogin(p, true);
|
finishPasswordLogin(p, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ★第54批:密码不匹配 → 先同步账号数据(拉回PHP侧凭证入库为主密码),
|
||||||
|
// 15秒/人限流;同步完成后主线程自动重校验(以Java本地login.db为准),仍未过才计失败次数
|
||||||
|
if (maybeRetryAfterWebSync(p, pwd)) return true;
|
||||||
|
|
||||||
// ★ 密码错误,记录风控
|
// ★ 密码错误,记录风控
|
||||||
int remaining = plugin.getRiskControl()
|
int remaining = plugin.getRiskControl()
|
||||||
.recordFailAttempt(p);
|
.recordFailAttempt(p);
|
||||||
@@ -251,6 +270,67 @@ public class LoginManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★第48批#249:已绑定 2FA(twofa_enabled=1)的玩家,密码通过后不直接放行,
|
||||||
|
* 转入「密码 + 2FA」双验证第二步(等 /2fa code)。
|
||||||
|
* 仅在该玩家当前不在双验证流程时生效(IP风控已 mark 的走 markDualStep1)。
|
||||||
|
*
|
||||||
|
* @return true = 已进入双验证流程,本轮 /login 到此为止
|
||||||
|
*/
|
||||||
|
private boolean requireTwoFaIfEnabled(Player p, boolean tempPassword) {
|
||||||
|
TwoFactorManager twofa = plugin.getTwofa();
|
||||||
|
String name = p.getName();
|
||||||
|
if (twofa == null) return false;
|
||||||
|
if (twofa.isDualVerify(p)) return false; // IP风控路径已处理
|
||||||
|
if (!plugin.getDb().userExists(name)) return false;
|
||||||
|
if (!twofa.isEnabled(name)) return false; // 未绑定2FA:维持原单步登录
|
||||||
|
// 密码这一步确实对了 → 建立双验证状态并记录进度(不解冻、不恢复背包)
|
||||||
|
twofa.markDualVerify(p, plugin.getPlayerIP(p));
|
||||||
|
twofa.onDualPasswordPassed(p, tempPassword);
|
||||||
|
// 重置「密码错误次数」风控(密码对了,但仍未完成登录)
|
||||||
|
plugin.getRiskControl().onLoginSuccess(name);
|
||||||
|
p.sendMessage("§a§l[双重验证] §a第一步密码验证通过(尚未解冻)");
|
||||||
|
p.sendMessage("§7第二步: 执行 §f/2fa code <动态码|恢复代码>");
|
||||||
|
p.sendMessage("§c两步全部通过后才会解冻并恢复背包");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★第54批:密码校验失败时先同步账号数据(拉回PHP侧凭证入库)再自动重试一次。
|
||||||
|
* 15秒/人限流;重试仍失败走正常风控计数。
|
||||||
|
*
|
||||||
|
* @return true = 本轮 /login 已交给异步对账流程处理(调用方直接 return)
|
||||||
|
*/
|
||||||
|
private boolean maybeRetryAfterWebSync(Player p, String pwd) {
|
||||||
|
if (plugin.webManager == null) return false;
|
||||||
|
String name = p.getName();
|
||||||
|
if (pwSyncRetrying.contains(name)) return false; // 重试轮失败:不再触发
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
Long last = pwSyncRetryAt.get(name);
|
||||||
|
if (last != null && now - last < 15000L) return false; // 15秒/人限流
|
||||||
|
pwSyncRetryAt.put(name, now);
|
||||||
|
pwSyncRetrying.add(name);
|
||||||
|
p.sendMessage("§e§l[登录] §e正在同步账号数据…");
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
try {
|
||||||
|
plugin.webManager.pushWebLoginCredentials(); // 含 alignGate 拉回
|
||||||
|
} catch (Throwable t) {
|
||||||
|
plugin.getLogger().warning("[登录] 对账重试同步异常: " + t.getMessage());
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
try {
|
||||||
|
Player online = Bukkit.getPlayerExact(name);
|
||||||
|
if (online == null || !online.isOnline()) return;
|
||||||
|
// 主线程重新走一次完整登录校验(含2FA/风控前置)
|
||||||
|
handleLogin(online, new String[]{pwd});
|
||||||
|
} finally {
|
||||||
|
pwSyncRetrying.remove(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码登录成功的统一收口:解冻 + 恢复背包 + 记录登录信息。
|
* 密码登录成功的统一收口:解冻 + 恢复背包 + 记录登录信息。
|
||||||
* 调用点:/login 主密码、/login 临时密码、IP风控双验证第二步通过后。
|
* 调用点:/login 主密码、/login 临时密码、IP风控双验证第二步通过后。
|
||||||
@@ -263,6 +343,10 @@ public class LoginManager {
|
|||||||
// ★ 记录Java手动登录:5分钟内重连可直接放行(检查点1)
|
// ★ 记录Java手动登录:5分钟内重连可直接放行(检查点1)
|
||||||
if (plugin.webManager != null) {
|
if (plugin.webManager != null) {
|
||||||
plugin.webManager.recordJavaLogin(name, plugin.getPlayerIP(p));
|
plugin.webManager.recordJavaLogin(name, plugin.getPlayerIP(p));
|
||||||
|
// ★ 第57批续3:/login 成功后推送 login_verified=1 给 PHP(统一收口)
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
plugin.webManager.pushLoginVerified(name);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
plugin.getDb().setLoggedIn(name, true);
|
plugin.getDb().setLoggedIn(name, true);
|
||||||
if (!tempPassword) {
|
if (!tempPassword) {
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public class Main extends JavaPlugin
|
|||||||
private CheckInManager checkIn;
|
private CheckInManager checkIn;
|
||||||
private InviteManager invite;
|
private InviteManager invite;
|
||||||
private PointsManager points;
|
private PointsManager points;
|
||||||
|
private CreditManager creditManager;
|
||||||
|
private AIChatManager aiChatManager;
|
||||||
public GUIManager gui;
|
public GUIManager gui;
|
||||||
private ChatInputManager chatInput;
|
private ChatInputManager chatInput;
|
||||||
private VerificationManager verification;
|
private VerificationManager verification;
|
||||||
@@ -141,6 +143,9 @@ public class Main extends JavaPlugin
|
|||||||
private final Map<String, Long> ipAutoLogin =
|
private final Map<String, Long> ipAutoLogin =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
private static final long IP_SKIP_MS = 300000L;
|
private static final long IP_SKIP_MS = 300000L;
|
||||||
|
// ★ 第56批:/webbind 批准密码验证失败计数(玩家名 -> 失败次数)
|
||||||
|
// ★ 第57批续5: /webbind approve 改聊天框输入密码(玩家名 -> 请求ID)
|
||||||
|
private final ConcurrentHashMap<String, String> pendingWebbindApprove = new ConcurrentHashMap<>();
|
||||||
private SalesStatsManager salesStats;
|
private SalesStatsManager salesStats;
|
||||||
|
|
||||||
private final Map<UUID, Long> lastActivity =
|
private final Map<UUID, Long> lastActivity =
|
||||||
@@ -316,6 +321,10 @@ public class Main extends JavaPlugin
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CreditManager getCreditManager() {
|
||||||
|
return creditManager;
|
||||||
|
}
|
||||||
|
|
||||||
public GUIManager getGui() {
|
public GUIManager getGui() {
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
@@ -397,6 +406,21 @@ public class Main extends JavaPlugin
|
|||||||
areaProtection.onPlayerQuit(p.getName());
|
areaProtection.onPlayerQuit(p.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第58批-问题4:玩家下线时触发一次在线玩家同步
|
||||||
|
// Bukkit.getOnlinePlayers() 已不含下线玩家 → 对账检出差异 → 推送更新名单
|
||||||
|
// → PHP 端移除下线玩家。定时心跳保持不动。
|
||||||
|
if (webManager != null) {
|
||||||
|
final String quitName = e.getPlayer().getName();
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
|
try {
|
||||||
|
getLogger().info("[Web通信] 玩家下线触发在线玩家同步: " + quitName);
|
||||||
|
webManager.syncOnlinePlayers();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
getLogger().warning("[Web通信] 下线同步syncOnlinePlayers异常: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -479,6 +503,9 @@ public class Main extends JavaPlugin
|
|||||||
checkIn = new CheckInManager(this);
|
checkIn = new CheckInManager(this);
|
||||||
invite = new InviteManager(this);
|
invite = new InviteManager(this);
|
||||||
points = new PointsManager(this);
|
points = new PointsManager(this);
|
||||||
|
creditManager = new CreditManager(this);
|
||||||
|
aiChatManager = new AIChatManager(this);
|
||||||
|
aiChatManager.onEnable();
|
||||||
chatInput = new ChatInputManager();
|
chatInput = new ChatInputManager();
|
||||||
verification = new VerificationManager(this);
|
verification = new VerificationManager(this);
|
||||||
riskControl = new RiskControlManager(this);
|
riskControl = new RiskControlManager(this);
|
||||||
@@ -1050,6 +1077,7 @@ public class Main extends JavaPlugin
|
|||||||
}
|
}
|
||||||
if (db != null) db.close();
|
if (db != null) db.close();
|
||||||
if (garbage != null) garbage.close();
|
if (garbage != null) garbage.close();
|
||||||
|
if (aiChatManager != null) aiChatManager.onDisable();
|
||||||
if (chatTransPool != null) {
|
if (chatTransPool != null) {
|
||||||
chatTransPool.shutdownNow();
|
chatTransPool.shutdownNow();
|
||||||
}
|
}
|
||||||
@@ -1550,7 +1578,7 @@ public class Main extends JavaPlugin
|
|||||||
emailBindTasks.put(uid, holder);
|
emailBindTasks.put(uid, holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAdmin(CommandSender sender) {
|
public boolean isAdmin(CommandSender sender) {
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
return ((Player) sender)
|
return ((Player) sender)
|
||||||
.getScoreboardTags()
|
.getScoreboardTags()
|
||||||
@@ -2577,6 +2605,11 @@ public class Main extends JavaPlugin
|
|||||||
areaProt.onPlayerJoin(p);
|
areaProt.onPlayerJoin(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第64批:每日登录自动恢复信誉积分
|
||||||
|
if (creditManager != null) {
|
||||||
|
creditManager.tryDailyLoginRestore(p);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2983,6 +3016,25 @@ public class Main extends JavaPlugin
|
|||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
String ip = getPlayerIP(p);
|
String ip = getPlayerIP(p);
|
||||||
|
// ★ 第57批:插件管理员登录 → CLI 通知待确认的封禁缺口
|
||||||
|
if (webManager != null && webManager.hasBanPending() && isAdmin(p)) {
|
||||||
|
p.sendMessage(net.kyori.adventure.text.Component.text()
|
||||||
|
.append(net.kyori.adventure.text.Component.text("§c§l[封禁-缺口] §f检测到 "))
|
||||||
|
.append(net.kyori.adventure.text.Component.text(String.valueOf(webManager.getBanPendingCount()))
|
||||||
|
.color(net.kyori.adventure.text.format.NamedTextColor.RED))
|
||||||
|
.append(net.kyori.adventure.text.Component.text(" 条封禁数据缺口待确认"))
|
||||||
|
.build());
|
||||||
|
p.sendMessage(net.kyori.adventure.text.Component.text()
|
||||||
|
.append(net.kyori.adventure.text.Component.text("§a[点击拉回封禁] §7").clickEvent(
|
||||||
|
net.kyori.adventure.text.event.ClickEvent.runCommand("/sdf1_login confirm ban")))
|
||||||
|
.append(net.kyori.adventure.text.Component.text("§7= /sdf1_login confirm ban"))
|
||||||
|
.build());
|
||||||
|
p.sendMessage(net.kyori.adventure.text.Component.text()
|
||||||
|
.append(net.kyori.adventure.text.Component.text("§c[点击确认解封] §7").clickEvent(
|
||||||
|
net.kyori.adventure.text.event.ClickEvent.runCommand("/sdf1_login cancel ban")))
|
||||||
|
.append(net.kyori.adventure.text.Component.text("§7= /sdf1_login cancel ban"))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 公告计分板(第35批)=====
|
// ===== 公告计分板(第35批)=====
|
||||||
// 延后 1 秒:避免与登录/权限流程抢计分板
|
// 延后 1 秒:避免与登录/权限流程抢计分板
|
||||||
@@ -2997,6 +3049,22 @@ public class Main extends JavaPlugin
|
|||||||
}, 20L);
|
}, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== ★ 第64批修复(#334):每日登录恢复信誉积分 =====
|
||||||
|
// tryDailyLoginRestore 只在 autoLogin() 里调用,但以下路径会绕过它:
|
||||||
|
// 1. 双验证(IP风控两关)早退:autoLogin 第2513行 return,永不到第2610行
|
||||||
|
// 2. 手动 /login 登录:不经过 autoLogin
|
||||||
|
// 修复:在 onJoin 入口就排一个延迟任务,所有路径都覆盖
|
||||||
|
// 幂等保护:tryDailyLoginRestore 内部有 lastRestoreDate 当日去重
|
||||||
|
if (creditManager != null) {
|
||||||
|
final Player restorePlayer = p;
|
||||||
|
getServer().getScheduler()
|
||||||
|
.runTaskLater(this, () -> {
|
||||||
|
if (restorePlayer.isOnline()) {
|
||||||
|
creditManager.tryDailyLoginRestore(restorePlayer);
|
||||||
|
}
|
||||||
|
}, 100L); // 100 tick = 5秒,等登录流程稳定后触发
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 风控封禁检查:密码错误阈值封禁期间拒绝加入 =====
|
// ===== 风控封禁检查:密码错误阈值封禁期间拒绝加入 =====
|
||||||
if (riskControl != null && riskControl.isBanned(name)) {
|
if (riskControl != null && riskControl.isBanned(name)) {
|
||||||
int remaining = riskControl.getBanRemainingSeconds(name);
|
int remaining = riskControl.getBanRemainingSeconds(name);
|
||||||
@@ -3181,6 +3249,10 @@ public class Main extends JavaPlugin
|
|||||||
if (!db.userExists(name)) {
|
if (!db.userExists(name)) {
|
||||||
webManager.syncUserOnJoin(name);
|
webManager.syncUserOnJoin(name);
|
||||||
}
|
}
|
||||||
|
// 第47批:进服静默同步网页端 2FA 绑定状态(登录风控 isEnabled 读到同步后结果)
|
||||||
|
if (twofa != null) {
|
||||||
|
twofa.syncOnJoin(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ★ 同IP判断:只作为开启自动登录验证的钥匙,不作为自动登录依据
|
// ★ 同IP判断:只作为开启自动登录验证的钥匙,不作为自动登录依据
|
||||||
@@ -3831,7 +3903,7 @@ public class Main extends JavaPlugin
|
|||||||
雪球菜单:
|
雪球菜单:
|
||||||
同时检测左右手
|
同时检测左右手
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onInteract(PlayerInteractEvent e) {
|
public void onInteract(PlayerInteractEvent e) {
|
||||||
// ★ 过滤物理交互(压力板、绊线等),防止GUI被反复打开
|
// ★ 过滤物理交互(压力板、绊线等),防止GUI被反复打开
|
||||||
if (e.getAction() == org.bukkit.event.block.Action.PHYSICAL) return;
|
if (e.getAction() == org.bukkit.event.block.Action.PHYSICAL) return;
|
||||||
@@ -3850,6 +3922,49 @@ public class Main extends JavaPlugin
|
|||||||
// ★ 屏蔽Sdf1_game宝箱自定义物品
|
// ★ 屏蔽Sdf1_game宝箱自定义物品
|
||||||
if (isTreasureItem(hand) || isTreasureItem(offhand)) return;
|
if (isTreasureItem(hand) || isTreasureItem(offhand)) return;
|
||||||
|
|
||||||
|
// ★ 第65批修复:持盾锄地/去皮
|
||||||
|
// MC 原版bug:副手盾牌右击方块时,盾牌格挡优先于主手工具交互
|
||||||
|
// 正确场景:主手锄头/斧头 + 副手盾 → 右击方块
|
||||||
|
if (e.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
org.bukkit.block.Block clicked = e.getClickedBlock();
|
||||||
|
if (clicked != null) {
|
||||||
|
// 场景:主手锄头 + 副手盾
|
||||||
|
String handName = hand.getType().name();
|
||||||
|
String offhandName = offhand.getType().name();
|
||||||
|
boolean handIsHoe = handName.endsWith("_HOE");
|
||||||
|
boolean handIsAxe = handName.endsWith("_AXE");
|
||||||
|
boolean offhandIsShield = offhand.getType() == Material.SHIELD;
|
||||||
|
|
||||||
|
if (offhandIsShield) {
|
||||||
|
// 主手锄头 + 副手盾 → 耕地
|
||||||
|
if (handIsHoe) {
|
||||||
|
Material bt = clicked.getType();
|
||||||
|
if (bt == Material.GRASS_BLOCK || bt == Material.PODZOL) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
clicked.setType(Material.FARMLAND);
|
||||||
|
clicked.getWorld().playSound(clicked.getLocation(), Sound.BLOCK_GRASS_HIT, 1, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 主手斧头 + 副手盾 → 去皮
|
||||||
|
if (handIsAxe) {
|
||||||
|
Material bt = clicked.getType();
|
||||||
|
String btName = bt.name();
|
||||||
|
if (btName.endsWith("_LOG") || btName.endsWith("_STEM")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
String strippedName = "STRIPPED_" + btName;
|
||||||
|
Material strippedMat = Material.getMaterial(strippedName);
|
||||||
|
if (strippedMat != null) {
|
||||||
|
clicked.setType(strippedMat);
|
||||||
|
clicked.getWorld().playSound(clicked.getLocation(), Sound.BLOCK_WOOD_HIT, 1, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isMenuSnowball(hand)
|
if (isMenuSnowball(hand)
|
||||||
|| isMenuSnowball(offhand)) {
|
|| isMenuSnowball(offhand)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@@ -3891,6 +4006,166 @@ public class Main extends JavaPlugin
|
|||||||
questTracker.onBlockMined(p.getName(),
|
questTracker.onBlockMined(p.getName(),
|
||||||
e.getBlock().getType().name());
|
e.getBlock().getType().name());
|
||||||
|
|
||||||
|
// ★ 第65批:连锁采集 — 按住Shift+斧头/稿子触发范围采集
|
||||||
|
tryChainBreak(p, e.getBlock());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第65批:连锁采集功能
|
||||||
|
* 按住Shift+斧头/稿子采矿/砍树时,自动将9×9范围内的同种类方块变成掉落物
|
||||||
|
* 仅按住Shift时生效,未按住Shift交还原版逻辑
|
||||||
|
*/
|
||||||
|
private void tryChainBreak(Player p, org.bukkit.block.Block centerBlock) {
|
||||||
|
// 检查是否按住Shift
|
||||||
|
if (!p.isSneaking()) return;
|
||||||
|
|
||||||
|
// 检查主手工具
|
||||||
|
ItemStack hand = p.getInventory().getItemInMainHand();
|
||||||
|
if (hand == null || hand.getType() == org.bukkit.Material.AIR) return;
|
||||||
|
|
||||||
|
String toolName = hand.getType().name();
|
||||||
|
boolean isPickaxe = toolName.endsWith("_PICKAXE");
|
||||||
|
boolean isAxe = toolName.endsWith("_AXE");
|
||||||
|
if (!isPickaxe && !isAxe) return;
|
||||||
|
|
||||||
|
// 检查当前方块是否为矿物或树木
|
||||||
|
Material targetType = centerBlock.getType();
|
||||||
|
boolean isOre = isOreBlock(targetType);
|
||||||
|
boolean isLog = isLogBlock(targetType);
|
||||||
|
if (!isOre && !isLog) return;
|
||||||
|
|
||||||
|
// 工具匹配检查:矿物需要稿子,树木需要斧头
|
||||||
|
if (isOre && !isPickaxe) return;
|
||||||
|
if (isLog && !isAxe) return;
|
||||||
|
|
||||||
|
// 连锁采集:树木垂直上下搜索,矿物3D 9×9×9搜索
|
||||||
|
org.bukkit.Location center = centerBlock.getLocation();
|
||||||
|
int range = 4; // 9×9×9 = 中心±4
|
||||||
|
|
||||||
|
List<org.bukkit.block.Block> sameTypeBlocks = new ArrayList<>();
|
||||||
|
org.bukkit.World world = center.getWorld();
|
||||||
|
int cx = center.getBlockX();
|
||||||
|
int cy = center.getBlockY();
|
||||||
|
int cz = center.getBlockZ();
|
||||||
|
|
||||||
|
if (isLog) {
|
||||||
|
// 树木:以被破坏方块为中心,垂直上下搜索整棵树干
|
||||||
|
// 树干天然上下连通,水平方向不需要辐射
|
||||||
|
for (int y = cy + 1; y <= 255; y++) {
|
||||||
|
org.bukkit.block.Block block = world.getBlockAt(cx, y, cz);
|
||||||
|
if (block.getType() == targetType && block.getType().isSolid()) {
|
||||||
|
sameTypeBlocks.add(block);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y = cy - 1; y >= 0; y--) {
|
||||||
|
org.bukkit.block.Block block = world.getBlockAt(cx, y, cz);
|
||||||
|
if (block.getType() == targetType && block.getType().isSolid()) {
|
||||||
|
sameTypeBlocks.add(block);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 矿物:以被破坏方块为中心,3D 9×9×9 搜索
|
||||||
|
// 不管是否连在一起,高处的、卡墙里的都能采到
|
||||||
|
for (int x = -range; x <= range; x++) {
|
||||||
|
for (int y = -range; y <= range; y++) {
|
||||||
|
for (int z = -range; z <= range; z++) {
|
||||||
|
if (x == 0 && y == 0 && z == 0) continue;
|
||||||
|
org.bukkit.block.Block block = world.getBlockAt(cx + x, cy + y, cz + z);
|
||||||
|
if (block.getType() == targetType && block.getType().isSolid()) {
|
||||||
|
sameTypeBlocks.add(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sameTypeBlocks.isEmpty()) return;
|
||||||
|
|
||||||
|
// 掉落物汇总位置:第一个被破坏的方块上方
|
||||||
|
org.bukkit.Location dropCenter = centerBlock.getLocation().add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
// 延迟1tick执行,避免主线程卡顿
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||||
|
int broken = 0;
|
||||||
|
for (org.bukkit.block.Block block : sameTypeBlocks) {
|
||||||
|
if (block.getType() != targetType) continue;
|
||||||
|
|
||||||
|
// 用 block.getDrops(hand) 获取正确掉落物
|
||||||
|
// 矿物需要镐子 → 掉落矿石物品(COPPER_ORE→COPPER_RAW_ORE)
|
||||||
|
// 树木需要斧头 → 掉落原木
|
||||||
|
java.util.Collection<org.bukkit.inventory.ItemStack> drops = block.getDrops(hand);
|
||||||
|
for (org.bukkit.inventory.ItemStack drop : drops) {
|
||||||
|
org.bukkit.entity.Item item = (org.bukkit.entity.Item)
|
||||||
|
world.dropItemNaturally(dropCenter, drop);
|
||||||
|
item.setPickupDelay(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(org.bukkit.Material.AIR);
|
||||||
|
broken++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (broken > 0) {
|
||||||
|
p.sendMessage("§a§l[连锁采集] §f采集了 §e" + broken + " §f个" + (isLog ? "方块" : "矿物"));
|
||||||
|
}
|
||||||
|
}, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取方块的掉落物类型(矿物掉落矿石物品,原木掉落原木) */
|
||||||
|
private Material getDropMaterial(Material blockType, boolean isOre) {
|
||||||
|
if (isOre) {
|
||||||
|
// 矿物→矿石物品映射(用字符串查找,避免Paper 26.x enum缺失)
|
||||||
|
String name = blockType.name();
|
||||||
|
if (name.endsWith("_RAW_ORE")) return blockType; // 已经是矿石物品
|
||||||
|
// 深板岩矿石先去掉 DEEPSLATE_ 前缀匹配
|
||||||
|
String stripped = name.startsWith("DEEPSLATE_") ? name.substring(10) : name;
|
||||||
|
// 映射到矿石物品名
|
||||||
|
String dropName = null;
|
||||||
|
if (stripped.equals("COPPER_ORE")) dropName = "COPPER_RAW_ORE";
|
||||||
|
else if (stripped.equals("IRON_ORE")) dropName = "IRON_RAW_ORE";
|
||||||
|
else if (stripped.equals("GOLD_ORE")) dropName = "GOLD_RAW_ORE";
|
||||||
|
else if (stripped.equals("DIAMOND_ORE")) dropName = "DIAMOND";
|
||||||
|
else if (stripped.equals("COAL_ORE")) dropName = "COAL";
|
||||||
|
else if (stripped.equals("EMERALD_ORE")) dropName = "EMERALD";
|
||||||
|
else if (stripped.equals("LAPIS_LAZULI_ORE")) dropName = "LAPIS_LAZULI";
|
||||||
|
else if (stripped.equals("LAPIS_ORE")) dropName = "LAPIS_LAZULI";
|
||||||
|
else if (stripped.equals("NETHER_QUARTZ_ORE")) dropName = "QUARTZ";
|
||||||
|
else if (stripped.equals("ANCIENT_DEBRIS")) dropName = "ANCIENT_DEBRIS";
|
||||||
|
if (dropName != null) {
|
||||||
|
Material m = Material.getMaterial(dropName);
|
||||||
|
if (m != null) return m;
|
||||||
|
}
|
||||||
|
return blockType; // 找不到就返回原方块
|
||||||
|
} else {
|
||||||
|
return blockType; // 树木直接返回原木
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 检查是否为矿物方块 */
|
||||||
|
private boolean isOreBlock(org.bukkit.Material type) {
|
||||||
|
String name = type.name();
|
||||||
|
return name.endsWith("_ORE")
|
||||||
|
|| name.contains("_ORE")
|
||||||
|
|| name.equals("COAL_BLOCK")
|
||||||
|
|| name.equals("IRON_BLOCK")
|
||||||
|
|| name.equals("GOLD_BLOCK")
|
||||||
|
|| name.equals("DIAMOND_BLOCK")
|
||||||
|
|| name.equals("EMERALD_BLOCK")
|
||||||
|
|| name.equals("LAPIS_BLOCK")
|
||||||
|
|| name.equals("QUARTZ_BLOCK")
|
||||||
|
|| name.equals("ANCIENT_DEBRIS");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 检查是否为树木方块 */
|
||||||
|
private boolean isLogBlock(org.bukkit.Material type) {
|
||||||
|
String name = type.name();
|
||||||
|
return name.endsWith("_LOG")
|
||||||
|
|| name.endsWith("_STEM")
|
||||||
|
|| name.endsWith("_WOOD");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -6154,12 +6429,29 @@ public class Main extends JavaPlugin
|
|||||||
chatFilter.markPlayerActive(p.getName());
|
chatFilter.markPlayerActive(p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第58批:AI聊天介入 — @//模型名/ 前缀触发直接提问
|
||||||
|
if (aiChatManager != null) {
|
||||||
|
aiChatManager.handlePlayerChat(p, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ★ 第58批:信誉积分聊天引导 — 上报/加分/扣分分步输入
|
||||||
|
if (creditManager != null && creditManager.isInChatFlow(p)) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
creditManager.handleChatInput(p, msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ★ 先探一次禁言状态:若刚好到期,isMuted() 内部会立即解禁并打上
|
// ★ 先探一次禁言状态:若刚好到期,isMuted() 内部会立即解禁并打上
|
||||||
// 「需重新人机验证」标记(2026-10-08:解禁≠解除人机验证)
|
// 「需重新人机验证」标记(2026-10-08:解禁≠解除人机验证)
|
||||||
if (chatFilter != null) {
|
if (chatFilter != null) {
|
||||||
chatFilter.isMuted(p.getName());
|
chatFilter.isMuted(p.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第64批:信誉积分聊天违规检测 — 脏话/违规链接扣分(不阻止聊天)
|
||||||
|
if (creditManager != null) {
|
||||||
|
creditManager.checkChatViolation(p, msg);
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 新玩家验证码检查(N+1机制) =====
|
// ===== 新玩家验证码检查(N+1机制) =====
|
||||||
if (chatFilter != null && chatFilter.isEnabled()) {
|
if (chatFilter != null && chatFilter.isEnabled()) {
|
||||||
ChatFilterManager.VerificationResult vr = chatFilter.checkNewPlayerVerification(p);
|
ChatFilterManager.VerificationResult vr = chatFilter.checkNewPlayerVerification(p);
|
||||||
@@ -6231,6 +6523,57 @@ public class Main extends JavaPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第57批续5: /webbind approve 密码输入拦截
|
||||||
|
String pendingBindReq = pendingWebbindApprove.get(p.getName());
|
||||||
|
if (pendingBindReq != null) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
String input = msg.trim();
|
||||||
|
// 拒绝选项
|
||||||
|
if (input.equalsIgnoreCase("拒绝") || input.equalsIgnoreCase("reject")) {
|
||||||
|
pendingWebbindApprove.remove(p.getName());
|
||||||
|
p.sendMessage("§e已拒绝,网页端直接返回");
|
||||||
|
webManager.submitWebEmailBindResult(pendingBindReq, p.getName(),
|
||||||
|
"reject", "", status -> {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ★ 第57批续10:接入统一风控(RiskControlManager),与 /login 完全一致
|
||||||
|
// 密码错5次 → Bukkit真实封禁5分钟 + 踢出 + 报警邮件(不再仅提示)
|
||||||
|
if (riskControl != null && riskControl.isBanned(p.getName())) {
|
||||||
|
int rem2 = riskControl.getBanRemainingSeconds(p.getName());
|
||||||
|
pendingWebbindApprove.remove(p.getName());
|
||||||
|
p.sendMessage("§c§l[风控] §f密码错误次数过多,账号已被临时封禁 §e"
|
||||||
|
+ rem2 + " §f秒");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String pwdSalt2 = (String) db.getField(p.getName(), "password_salt");
|
||||||
|
String pwdHash2 = PasswordUtils.hash(input, pwdSalt2);
|
||||||
|
String pwdResult2 = db.checkPasswordWithFallback(p.getName(), pwdHash2);
|
||||||
|
if (pwdResult2 == null) {
|
||||||
|
int remaining2 = riskControl != null
|
||||||
|
? riskControl.recordFailAttempt(p) : 4;
|
||||||
|
if (remaining2 < 0) {
|
||||||
|
// 已达阈值:triggerBan 已真实封禁并踢出
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.sendMessage("§c密码错误");
|
||||||
|
if (remaining2 > 0) {
|
||||||
|
p.sendMessage("§c§l[风控] §f剩余 §e" + remaining2 + " §f次尝试机会");
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§c§l[风控] §f连续5次失败,已被临时封禁");
|
||||||
|
pendingWebbindApprove.remove(p.getName());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 验证通过,重置风控计数
|
||||||
|
if (riskControl != null) riskControl.onLoginSuccess(p.getName());
|
||||||
|
String reqId2 = pendingBindReq;
|
||||||
|
pendingWebbindApprove.remove(p.getName());
|
||||||
|
p.sendMessage("§e正在提交批准…");
|
||||||
|
webManager.submitWebEmailBindResult(reqId2, p.getName(),
|
||||||
|
"approve", "", true, status -> {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ★ 2FA 解绑确认输入拦截(30秒 confirm 窗口,
|
// ★ 2FA 解绑确认输入拦截(30秒 confirm 窗口,
|
||||||
// 输入 confirm=解绑,其它任意内容/超时=取消)
|
// 输入 confirm=解绑,其它任意内容/超时=取消)
|
||||||
if (twofa != null && twofa.isRemoveConfirming(p)) {
|
if (twofa != null && twofa.isRemoveConfirming(p)) {
|
||||||
@@ -6394,17 +6737,10 @@ public class Main extends JavaPlugin
|
|||||||
}
|
}
|
||||||
chatFilter.incrementViolation(p.getName());
|
chatFilter.incrementViolation(p.getName());
|
||||||
int sc = chatFilter.getViolationCount(p.getName());
|
int sc = chatFilter.getViolationCount(p.getName());
|
||||||
// ★ 2026-10-08:命中必须给发送者明确反馈——此前 warn 档完全静默、
|
// ★ 第65批修复(#338):最小信息泄露——不告诉玩家命中的敏感词、
|
||||||
// 自回显又与正常聊天一模一样 →观感「中文敏感词没过滤」
|
// 累计次数、处罚档位。只告知消息被拦截,避免被用作绕过探测工具。
|
||||||
getLogger().info("[Sdf1_chat] " + p.getName() + " 命中敏感词("
|
getLogger().info("[Sdf1_chat] " + p.getName() + " 命中敏感词,累计违规 " + sc + " 次,消息已拦截");
|
||||||
+ ms.get(0) + "),累计违规 " + sc + " 次,消息已拦截");
|
p.sendMessage("§c§l[聊天过滤] §7你的消息包含违规内容,已被拦截");
|
||||||
p.sendMessage("§c§l[聊天过滤] §7消息包含违规词 §f" + ms.get(0)
|
|
||||||
+ " §7已被拦截,§8本次为第 " + sc + " 次违规");
|
|
||||||
String punishHint = chatFilter.nextPunishHint(sc);
|
|
||||||
if (punishHint != null) {
|
|
||||||
// ★ 只报处罚档位,不报「第N次」——与上一行的次数并列易被读成跳号
|
|
||||||
p.sendMessage("§8再次违规将处罚: §e" + punishHint);
|
|
||||||
}
|
|
||||||
String swReason = "说出敏感词("
|
String swReason = "说出敏感词("
|
||||||
+ ms.get(0) + ")";
|
+ ms.get(0) + ")";
|
||||||
String ptype = chatFilter.applyPunishment(
|
String ptype = chatFilter.applyPunishment(
|
||||||
@@ -7085,6 +7421,19 @@ public class Main extends JavaPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 信誉积分 GUI 点击处理 =====
|
||||||
|
if (title != null && title.contains("信誉积分")) {
|
||||||
|
if (creditManager != null) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
if (e.isRightClick()) {
|
||||||
|
creditManager.handleRightClick(p, slot, title);
|
||||||
|
} else {
|
||||||
|
creditManager.handleClick(p, slot, title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ===== 垃圾箱 =====
|
// ===== 垃圾箱 =====
|
||||||
// ===== 垃圾回收站 =====
|
// ===== 垃圾回收站 =====
|
||||||
if (title.equals("§6§l垃圾回收站")) {
|
if (title.equals("§6§l垃圾回收站")) {
|
||||||
@@ -7777,6 +8126,14 @@ public class Main extends JavaPlugin
|
|||||||
// CLI模式
|
// CLI模式
|
||||||
Bukkit.dispatchCommand(p, "protect menu");
|
Bukkit.dispatchCommand(p, "protect menu");
|
||||||
}
|
}
|
||||||
|
} else if (slot == 40) {
|
||||||
|
// ★ 信誉积分入口
|
||||||
|
p.closeInventory();
|
||||||
|
if (creditManager != null) {
|
||||||
|
p.openInventory(creditManager.createMainGUI(p));
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§c信誉积分模块未初始化");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -9357,6 +9714,15 @@ public class Main extends JavaPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== /credits:信誉积分管理 =====
|
||||||
|
if (cmdName.equals("credits")) {
|
||||||
|
if (creditManager == null) {
|
||||||
|
sender.sendMessage("§c信誉积分模块未初始化");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return creditManager.handleCommand(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ★ 第30批:/addblack <玩家> [时长] [理由] —— 拉黑
|
// ★ 第30批:/addblack <玩家> [时长] [理由] —— 拉黑
|
||||||
if (cmdName.equals("addblack")) {
|
if (cmdName.equals("addblack")) {
|
||||||
@@ -9549,6 +9915,10 @@ public class Main extends JavaPlugin
|
|||||||
// ★ 未绑定邮箱:登录成功后提示
|
// ★ 未绑定邮箱:登录成功后提示
|
||||||
if (loggedIn.contains(p.getName())) {
|
if (loggedIn.contains(p.getName())) {
|
||||||
remindEmailBindIfNeeded(p);
|
remindEmailBindIfNeeded(p);
|
||||||
|
// ★ 第57批续6:/login成功后重新推送weblogin token(onJoin时推送的token login_verified=0,Web端不认)
|
||||||
|
if (webManager != null) {
|
||||||
|
webManager.autoGenerateWebLoginToken(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -9606,6 +9976,65 @@ public class Main extends JavaPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第53批:网页端绑邮箱 · 游戏内批准/拒绝(/webbind approve|reject <id>)
|
||||||
|
if (cmdName.equals("webbind")) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("§c仅玩家可用");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final Player wp = (Player) sender;
|
||||||
|
if (isFrozen(wp)) {
|
||||||
|
wp.sendMessage("§c§l[登录] §f你还未登录,无法使用该命令。请先使用 §e/l <密码> §f登录");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length < 2
|
||||||
|
|| (!args[0].equalsIgnoreCase("approve")
|
||||||
|
&& !args[0].equalsIgnoreCase("reject"))) {
|
||||||
|
wp.sendMessage("§c用法: /webbind approve|reject <id> [密码]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final String bindReqId = args[1];
|
||||||
|
if (!bindReqId.matches("[0-9]+")) {
|
||||||
|
wp.sendMessage("§c无效的请求ID");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (webManager == null) {
|
||||||
|
wp.sendMessage("§cWeb通信未启用,无法处理");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final boolean bindApprove = args[0].equalsIgnoreCase("approve");
|
||||||
|
// ★ 第56批:approve 时需要密码(Java端直接验证,不再依赖PHP复核)
|
||||||
|
if (bindApprove) {
|
||||||
|
// ★ 第57批续5: 改聊天框输入密码(不再要求命令行参数密码)
|
||||||
|
// ★ 第57批续10:接入统一风控,封禁期内直接拒绝
|
||||||
|
if (riskControl != null && riskControl.isBanned(wp.getName())) {
|
||||||
|
int rem = riskControl.getBanRemainingSeconds(wp.getName());
|
||||||
|
wp.sendMessage("§c§l[风控] §f密码错误次数过多,账号已被临时封禁 §e"
|
||||||
|
+ rem + " §f秒,请稍后再试");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pendingWebbindApprove.put(wp.getName(), bindReqId);
|
||||||
|
wp.sendMessage("§e请在聊天框输入密码完成验证");
|
||||||
|
wp.sendMessage("§7还是输入「拒绝」拒绝本次绑定");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// reject 不需要密码
|
||||||
|
wp.sendMessage("§e正在提交拒绝…");
|
||||||
|
webManager.submitWebEmailBindResult(bindReqId, wp.getName(),
|
||||||
|
"reject", "", status -> {
|
||||||
|
if (status == null) {
|
||||||
|
wp.sendMessage("§c提交失败,请稍后重试");
|
||||||
|
} else if ("rejected".equals(status)) {
|
||||||
|
wp.sendMessage("§e已拒绝,网页端将直接返回,不做任何处置");
|
||||||
|
} else if ("expired".equals(status)) {
|
||||||
|
wp.sendMessage("§c请求已超时,未做任何处置");
|
||||||
|
} else {
|
||||||
|
wp.sendMessage("§7请求当前状态: §f" + status + " §7(重复操作已忽略)");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 绑定邮箱
|
// 绑定邮箱
|
||||||
if (cmdName.equals("绑定邮箱")) {
|
if (cmdName.equals("绑定邮箱")) {
|
||||||
// ★ 3.0 安全修复:邮箱绑定必须登录后才能执行(未登录越权绑邮箱 + 任意收件人 SMTP 滥发)
|
// ★ 3.0 安全修复:邮箱绑定必须登录后才能执行(未登录越权绑邮箱 + 任意收件人 SMTP 滥发)
|
||||||
@@ -9852,6 +10281,13 @@ public class Main extends JavaPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String target = args[1];
|
String target = args[1];
|
||||||
|
// ★ 第57批续3:/del ban 拦截(ban 不作为待删除玩家账号的名字)
|
||||||
|
if (target.equalsIgnoreCase("ban")) {
|
||||||
|
sender.sendMessage("§cban 是封禁缺口确认命令,不是玩家账号名");
|
||||||
|
sender.sendMessage("§7确认拉回封禁:§a/sdf1_login confirm ban");
|
||||||
|
sender.sendMessage("§7确认解封:§a/sdf1_login cancel ban");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!db.userExists(target)) {
|
if (!db.userExists(target)) {
|
||||||
String twin = db.findSimilarUserNameIgnoreCase(target);
|
String twin = db.findSimilarUserNameIgnoreCase(target);
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
@@ -9910,6 +10346,23 @@ public class Main extends JavaPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第57批:confirm ban 确认封禁缺口拉回
|
||||||
|
if (sub.equals("confirm") && args.length >= 2 && args[1].equalsIgnoreCase("ban")) {
|
||||||
|
if (!isAdmin(sender)) { sender.sendMessage("\u00a7c权限不足"); return true; }
|
||||||
|
if (webManager == null) { sender.sendMessage("\u00a7cWeb通信未初始化"); return true; }
|
||||||
|
if (!webManager.hasBanPending()) { sender.sendMessage("§c当前没有待确认的封禁缺口"); return true; }
|
||||||
|
webManager.confirmBanGap(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ★ 第57批:cancel ban 确认解封(清空PHP封禁数据,不写回banned-players.json)
|
||||||
|
if (sub.equals("cancel") && args.length >= 2 && args[1].equalsIgnoreCase("ban")) {
|
||||||
|
if (!isAdmin(sender)) { sender.sendMessage("\u00a7c权限不足"); return true; }
|
||||||
|
if (webManager == null) { sender.sendMessage("\u00a7cWeb通信未初始化"); return true; }
|
||||||
|
if (!webManager.hasBanPending()) { sender.sendMessage("§c当前没有待确认的封禁缺口"); return true; }
|
||||||
|
webManager.cancelBanGap(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (sub.equals("confirm")) {
|
if (sub.equals("confirm")) {
|
||||||
if (!isAdmin(sender)) {
|
if (!isAdmin(sender)) {
|
||||||
sender.sendMessage("§c权限不足");
|
sender.sendMessage("§c权限不足");
|
||||||
|
|||||||
@@ -550,8 +550,8 @@ public class PVPArenaManager implements Listener {
|
|||||||
w.setPVP(true);
|
w.setPVP(true);
|
||||||
// ★ 和平模式:排除敌对生物干扰PVP
|
// ★ 和平模式:排除敌对生物干扰PVP
|
||||||
w.setDifficulty(Difficulty.PEACEFUL);
|
w.setDifficulty(Difficulty.PEACEFUL);
|
||||||
w.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
w.setGameRule(GameRules.ADVANCE_TIME, false);
|
||||||
w.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
w.setGameRule(GameRules.ADVANCE_WEATHER, false);
|
||||||
w.setTime(6000);
|
w.setTime(6000);
|
||||||
// ★ 不常驻出生点区块(与 WorldCreator.keepSpawnInMemory(false) 一致),避免同步加载区块卡主线程
|
// ★ 不常驻出生点区块(与 WorldCreator.keepSpawnInMemory(false) 一致),避免同步加载区块卡主线程
|
||||||
w.setKeepSpawnInMemory(false);
|
w.setKeepSpawnInMemory(false);
|
||||||
|
|||||||
@@ -182,10 +182,10 @@ public class PVPTestManager implements Listener {
|
|||||||
// 世界规则:常昼 / 无天气 / 关闭自然刷怪(只有我们生成的练习生物)/ PVP 开启
|
// 世界规则:常昼 / 无天气 / 关闭自然刷怪(只有我们生成的练习生物)/ PVP 开启
|
||||||
// ★ KEEP_INVENTORY=false:死亡掉落由事件处理器清空掉落物+复活时还原,避免gamerule与事件冲突
|
// ★ KEEP_INVENTORY=false:死亡掉落由事件处理器清空掉落物+复活时还原,避免gamerule与事件冲突
|
||||||
w.setPVP(true);
|
w.setPVP(true);
|
||||||
w.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
w.setGameRule(GameRules.ADVANCE_TIME, false);
|
||||||
w.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
w.setGameRule(GameRules.ADVANCE_WEATHER, false);
|
||||||
w.setGameRule(GameRule.DO_MOB_SPAWNING, false);
|
w.setGameRule(GameRules.SPAWN_MONSTERS, false);
|
||||||
w.setGameRule(GameRule.KEEP_INVENTORY, false);
|
w.setGameRule(GameRules.KEEP_INVENTORY, false);
|
||||||
w.setTime(6000);
|
w.setTime(6000);
|
||||||
w.setKeepSpawnInMemory(false);
|
w.setKeepSpawnInMemory(false);
|
||||||
|
|
||||||
@@ -895,7 +895,7 @@ public class PVPTestManager implements Listener {
|
|||||||
// 抵消皮革帽自带的1点护甲,使其不增加玩家对练习生物的伤害减免(纯用于挡太阳)
|
// 抵消皮革帽自带的1点护甲,使其不增加玩家对练习生物的伤害减免(纯用于挡太阳)
|
||||||
hm.addAttributeModifier(Attribute.ARMOR,
|
hm.addAttributeModifier(Attribute.ARMOR,
|
||||||
new AttributeModifier(
|
new AttributeModifier(
|
||||||
"pvp_test_no_armor", -1.0,
|
new NamespacedKey(plugin, "pvp_test_no_armor"), -1.0,
|
||||||
AttributeModifier.Operation.ADD_NUMBER));
|
AttributeModifier.Operation.ADD_NUMBER));
|
||||||
hat.setItemMeta(hm);
|
hat.setItemMeta(hm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,23 +88,18 @@ public class RiskControlManager {
|
|||||||
public int recordFailAttempt(Player player) {
|
public int recordFailAttempt(Player player) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
int maxAttempts = getMaxFailAttempts();
|
int maxAttempts = getMaxFailAttempts();
|
||||||
|
|
||||||
// 已被封禁,直接返回
|
// 已被封禁,直接返回
|
||||||
if (isBanned(name)) {
|
if (isBanned(name)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int current = failAttempts
|
int current = failAttempts
|
||||||
.getOrDefault(name, 0) + 1;
|
.getOrDefault(name, 0) + 1;
|
||||||
failAttempts.put(name, current);
|
failAttempts.put(name, current);
|
||||||
|
|
||||||
int remaining = Math.max(0, maxAttempts - current);
|
int remaining = Math.max(0, maxAttempts - current);
|
||||||
|
|
||||||
// 达到阈值 → 触发封禁
|
// 达到阈值 → 触发封禁
|
||||||
if (current >= maxAttempts) {
|
if (current >= maxAttempts) {
|
||||||
triggerBan(player);
|
triggerBan(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return remaining;
|
return remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,16 +112,13 @@ public class RiskControlManager {
|
|||||||
long durationMs = getBanDurationMs();
|
long durationMs = getBanDurationMs();
|
||||||
long until = System.currentTimeMillis() + durationMs;
|
long until = System.currentTimeMillis() + durationMs;
|
||||||
banUntil.put(name, until);
|
banUntil.put(name, until);
|
||||||
|
|
||||||
String ip = plugin.getPlayerIP(player);
|
String ip = plugin.getPlayerIP(player);
|
||||||
int banMinutes = (int) (durationMs / 60000);
|
int banMinutes = (int) (durationMs / 60000);
|
||||||
|
|
||||||
plugin.getLogger().warning(
|
plugin.getLogger().warning(
|
||||||
"[风控] 玩家 " + name
|
"[风控] 玩家 " + name
|
||||||
+ " 密码错误达到阈值("
|
+ " 密码错误达到阈值("
|
||||||
+ getMaxFailAttempts() + "次)"
|
+ getMaxFailAttempts() + "次)"
|
||||||
+ ",封禁 " + banMinutes + " 分钟");
|
+ ",封禁 " + banMinutes + " 分钟");
|
||||||
|
|
||||||
// ★ 真实封禁:调用Bukkit BanList API阻止玩家重新加入服务器
|
// ★ 真实封禁:调用Bukkit BanList API阻止玩家重新加入服务器
|
||||||
String banReason = "§c§l[安全风控] 密码连续错误"
|
String banReason = "§c§l[安全风控] 密码连续错误"
|
||||||
+ getMaxFailAttempts() + "次,"
|
+ getMaxFailAttempts() + "次,"
|
||||||
@@ -145,7 +137,6 @@ public class RiskControlManager {
|
|||||||
}
|
}
|
||||||
// 踢出玩家(无论BanList是否成功,立即踢出)
|
// 踢出玩家(无论BanList是否成功,立即踢出)
|
||||||
player.kickPlayer(banReason);
|
player.kickPlayer(banReason);
|
||||||
|
|
||||||
// 异步发送报警邮件
|
// 异步发送报警邮件
|
||||||
sendBanAlertEmail(name, ip, banMinutes);
|
sendBanAlertEmail(name, ip, banMinutes);
|
||||||
}
|
}
|
||||||
@@ -164,7 +155,6 @@ public class RiskControlManager {
|
|||||||
+ " 未绑定邮箱,跳过报警邮件");
|
+ " 未绑定邮箱,跳过报警邮件");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String subject =
|
String subject =
|
||||||
"[安全警告] 您的账号已被临时封禁";
|
"[安全警告] 您的账号已被临时封禁";
|
||||||
String body = "尊敬的玩家 " + playerName + ":\n\n"
|
String body = "尊敬的玩家 " + playerName + ":\n\n"
|
||||||
@@ -187,7 +177,6 @@ public class RiskControlManager {
|
|||||||
+ "如果非本人操作,建议您立即修改密码"
|
+ "如果非本人操作,建议您立即修改密码"
|
||||||
+ "(使用 /sdf1_login pw)。\n\n"
|
+ "(使用 /sdf1_login pw)。\n\n"
|
||||||
+ "--Sdf1_login 安全系统";
|
+ "--Sdf1_login 安全系统";
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
try {
|
try {
|
||||||
plugin.getEmail().sendBody(
|
plugin.getEmail().sendBody(
|
||||||
|
|||||||
@@ -4274,6 +4274,14 @@ public class ShopManager implements Listener {
|
|||||||
? "§7手续费: §6" + shsp[0] + " §7(奸商模式)§7你需支付 §6" + shsp[1]
|
? "§7手续费: §6" + shsp[0] + " §7(奸商模式)§7你需支付 §6" + shsp[1]
|
||||||
: "§7无手续费");
|
: "§7无手续费");
|
||||||
}
|
}
|
||||||
|
// ★ 第63批:信誉积分标记(卖家)
|
||||||
|
if (plugin.getCreditManager() != null) {
|
||||||
|
if (plugin.getCreditManager().isShopLowWarning(l.seller)) {
|
||||||
|
lore.add("§c§l⚠ §c卖家信誉分很低,请谨慎购买");
|
||||||
|
} else if (plugin.getCreditManager().isShopHighRecommend(l.seller)) {
|
||||||
|
lore.add("§a§l✓ §a卖家信誉分极好,可以放心购买");
|
||||||
|
}
|
||||||
|
}
|
||||||
lore.add("§7上架时间: §f" + new SimpleDateFormat("MM-dd HH:mm")
|
lore.add("§7上架时间: §f" + new SimpleDateFormat("MM-dd HH:mm")
|
||||||
.format(new Date(l.createdAt)));
|
.format(new Date(l.createdAt)));
|
||||||
lore.add("");
|
lore.add("");
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ public class TwoFactorManager {
|
|||||||
|
|
||||||
/** /2fa 命令分发,恒返回 true */
|
/** /2fa 命令分发,恒返回 true */
|
||||||
public boolean handleCommand(Player p, String[] args) {
|
public boolean handleCommand(Player p, String[] args) {
|
||||||
|
// 第47批:先异步同步网页端绑定状态再分发(网页已绑定 → 游戏内立即显示/生效,
|
||||||
|
// add 也不会对着网页绑定重复申请);网络失败静默按本地状态走
|
||||||
|
syncWithWebThen(p, pl -> dispatchSub(pl, args));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchSub(Player p, String[] args) {
|
||||||
String sub = args.length >= 1 ? args[0].toLowerCase() : "";
|
String sub = args.length >= 1 ? args[0].toLowerCase() : "";
|
||||||
switch (sub) {
|
switch (sub) {
|
||||||
case "add":
|
case "add":
|
||||||
@@ -113,7 +120,6 @@ public class TwoFactorManager {
|
|||||||
sendHelp(p);
|
sendHelp(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHelp(Player p) {
|
public void sendHelp(Player p) {
|
||||||
@@ -271,6 +277,10 @@ public class TwoFactorManager {
|
|||||||
plugin.getDb().setField(name, "twofa_enabled", 1);
|
plugin.getDb().setField(name, "twofa_enabled", 1);
|
||||||
plugin.getDb().setField(name, "twofa_pending_secret", "");
|
plugin.getDb().setField(name, "twofa_pending_secret", "");
|
||||||
plugin.getDb().setField(name, "twofa_pending_at", 0L);
|
plugin.getDb().setField(name, "twofa_pending_at", 0L);
|
||||||
|
markBoundNow(name);
|
||||||
|
// 第47批:绑定结果同步到网页端(网页安全卡随之显示已绑定)
|
||||||
|
pushStateAsync(name, true, pending,
|
||||||
|
System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
p.sendMessage("§a§l[2FA] §a二次验证绑定成功!");
|
p.sendMessage("§a§l[2FA] §a二次验证绑定成功!");
|
||||||
p.sendMessage("§7 此后敏感操作需提供认证器动态码");
|
p.sendMessage("§7 此后敏感操作需提供认证器动态码");
|
||||||
@@ -370,6 +380,9 @@ public class TwoFactorManager {
|
|||||||
plugin.getDb().setField(name, "twofa_secret", "");
|
plugin.getDb().setField(name, "twofa_secret", "");
|
||||||
plugin.getDb().setField(name, "twofa_enabled", 0);
|
plugin.getDb().setField(name, "twofa_enabled", 0);
|
||||||
plugin.getDb().setField(name, "twofa_recovery_codes", "");
|
plugin.getDb().setField(name, "twofa_recovery_codes", "");
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", 0L);
|
||||||
|
// 第47批:解绑结果同步到网页端
|
||||||
|
pushStateAsync(name, false, "", System.currentTimeMillis() / 1000L);
|
||||||
plugin.getLogger().info("[2FA] 玩家 " + name
|
plugin.getLogger().info("[2FA] 玩家 " + name
|
||||||
+ " 使用恢复代码通过验证,已自动解绑二次验证");
|
+ " 使用恢复代码通过验证,已自动解绑二次验证");
|
||||||
sendUnbindAlarm(name, "恢复代码解绑", "玩家本人(恢复代码)",
|
sendUnbindAlarm(name, "恢复代码解绑", "玩家本人(恢复代码)",
|
||||||
@@ -653,6 +666,9 @@ public class TwoFactorManager {
|
|||||||
plugin.getDb().setField(name, "twofa_enabled", 0);
|
plugin.getDb().setField(name, "twofa_enabled", 0);
|
||||||
// 解绑要彻底:恢复代码一并作废,避免残留可再次触发解绑/验证
|
// 解绑要彻底:恢复代码一并作废,避免残留可再次触发解绑/验证
|
||||||
plugin.getDb().setField(name, "twofa_recovery_codes", "");
|
plugin.getDb().setField(name, "twofa_recovery_codes", "");
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", 0L);
|
||||||
|
// 第47批:解绑结果同步到网页端
|
||||||
|
pushStateAsync(name, false, "", System.currentTimeMillis() / 1000L);
|
||||||
Player pl = Bukkit.getPlayer(uuid);
|
Player pl = Bukkit.getPlayer(uuid);
|
||||||
String srcIp = "";
|
String srcIp = "";
|
||||||
if (pl != null && pl.isOnline()) {
|
if (pl != null && pl.isOnline()) {
|
||||||
@@ -810,6 +826,9 @@ public class TwoFactorManager {
|
|||||||
plugin.getDb().setField(target, "twofa_recovery_codes", "");
|
plugin.getDb().setField(target, "twofa_recovery_codes", "");
|
||||||
plugin.getDb().setField(target, "twofa_pending_secret", "");
|
plugin.getDb().setField(target, "twofa_pending_secret", "");
|
||||||
plugin.getDb().setField(target, "twofa_pending_at", 0L);
|
plugin.getDb().setField(target, "twofa_pending_at", 0L);
|
||||||
|
plugin.getDb().setField(target, "twofa_bound_at", 0L);
|
||||||
|
// 第47批:解绑结果同步到网页端
|
||||||
|
pushStateAsync(target, false, "", System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
out.sendMessage("§a[2FA] 强制解绑成功:玩家 " + target);
|
out.sendMessage("§a[2FA] 强制解绑成功:玩家 " + target);
|
||||||
out.sendMessage("§7 已清空 twofa_secret / twofa_enabled / "
|
out.sendMessage("§7 已清空 twofa_secret / twofa_enabled / "
|
||||||
@@ -896,6 +915,153 @@ public class TwoFactorManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 网页端绑定状态双向同步(第47批) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步拉取网页端 2FA 状态并合并到本地,回主线程后执行后续动作。
|
||||||
|
* 网络失败/未启用:静默按本地状态直接继续,绝不阻塞命令。
|
||||||
|
*/
|
||||||
|
private void syncWithWebThen(Player p, java.util.function.Consumer<Player> next) {
|
||||||
|
if (plugin.webManager == null) {
|
||||||
|
next.accept(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final UUID uuid = p.getUniqueId();
|
||||||
|
final String name = p.getName();
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
WebManager.TwoFaWebState web = null;
|
||||||
|
try {
|
||||||
|
web = plugin.webManager.pullTwoFactorState(name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[2FA] 网页状态拉取异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
final WebManager.TwoFaWebState st = web;
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
Player pl = Bukkit.getPlayer(uuid);
|
||||||
|
if (pl == null || !pl.isOnline()) return;
|
||||||
|
try {
|
||||||
|
applyWebState(pl, st);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[2FA] 网页状态合并异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
next.accept(pl);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并网页端状态到本地(主线程)。
|
||||||
|
* 规则:网页绑定而本地未绑定 → 导入;两端都绑定但密钥不同 → bound_at 新者胜;
|
||||||
|
* 网页已解绑且比本地绑定更新 → 本地解绑;本地新 → 反向推送覆盖网页。
|
||||||
|
* 恢复代码不做跨端同步(网页 16 位明文 vs 游戏 6 位 SHA-256,格式不兼容,各自维护)。
|
||||||
|
*/
|
||||||
|
private void applyWebState(Player p, WebManager.TwoFaWebState web) {
|
||||||
|
if (web == null) return; // 拉取失败:保持本地状态
|
||||||
|
String name = p.getName();
|
||||||
|
boolean localBound = isEnabled(name);
|
||||||
|
String localSecret = str(plugin.getDb().getField(name, "twofa_secret"));
|
||||||
|
long localBoundAt = longOf(plugin.getDb().getField(name, "twofa_bound_at"));
|
||||||
|
|
||||||
|
if (web.bound && !web.secret.isEmpty()) {
|
||||||
|
if (!localBound) {
|
||||||
|
// 网页已绑定、本地未绑定 → 导入(修复截图场景)
|
||||||
|
plugin.getDb().setField(name, "twofa_secret", web.secret);
|
||||||
|
plugin.getDb().setField(name, "twofa_enabled", 1);
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", web.boundAt);
|
||||||
|
plugin.getDb().setField(name, "twofa_pending_secret", "");
|
||||||
|
plugin.getDb().setField(name, "twofa_pending_at", 0L);
|
||||||
|
p.sendMessage("§a§l[2FA] §a已同步网页端的二次验证绑定");
|
||||||
|
p.sendMessage("§7 此后敏感操作需提供认证器动态码;网页端恢复代码在游戏内不可用");
|
||||||
|
plugin.getLogger().info("[2FA] 已导入网页端绑定: " + name
|
||||||
|
+ " (bound_at=" + web.boundAt + ")");
|
||||||
|
} else if (!localSecret.equals(web.secret)) {
|
||||||
|
if (web.boundAt > localBoundAt) {
|
||||||
|
// 网页端换绑更新 → 覆盖本地
|
||||||
|
plugin.getDb().setField(name, "twofa_secret", web.secret);
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", web.boundAt);
|
||||||
|
p.sendMessage("§e§l[2FA] §e检测到网页端更新的绑定,已切换为新密钥");
|
||||||
|
plugin.getLogger().info("[2FA] 密钥冲突取网页端(更新): " + name);
|
||||||
|
} else {
|
||||||
|
// 本地更新 → 反向推送覆盖网页
|
||||||
|
plugin.getLogger().info("[2FA] 密钥冲突取本地(更新): " + name);
|
||||||
|
pushStateAsync(name, true, localSecret, localBoundAt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网页端未绑定/无记录
|
||||||
|
if (localBound) {
|
||||||
|
if (web.exists && web.updatedAt > localBoundAt) {
|
||||||
|
// 网页端主动解绑且更晚 → 本地跟随解绑
|
||||||
|
plugin.getDb().setField(name, "twofa_secret", "");
|
||||||
|
plugin.getDb().setField(name, "twofa_enabled", 0);
|
||||||
|
plugin.getDb().setField(name, "twofa_recovery_codes", "");
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", 0L);
|
||||||
|
p.sendMessage("§e§l[2FA] §e网页端已解除二次验证,游戏内同步解绑");
|
||||||
|
plugin.getLogger().info("[2FA] 网页端解绑传播到本地: " + name);
|
||||||
|
} else if (!web.exists) {
|
||||||
|
// 网页端无记录(本地绑定未推送过)→ 推送本地绑定到网页
|
||||||
|
pushStateAsync(name, true, localSecret, localBoundAt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 两端都未绑定:无需动作(网页端 pending 待确认态不导入)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 异步推送本地绑定状态到网页端(解绑/绑定收口统一走这里) */
|
||||||
|
private void pushStateAsync(String name, boolean bound, String secret, long boundAt) {
|
||||||
|
if (plugin.webManager == null) return;
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
try {
|
||||||
|
plugin.webManager.pushTwoFactorState(name, bound, secret, boundAt);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[2FA] 推送绑定状态异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家进服时静默同步(第47批,Main.PlayerJoinEvent 调用):
|
||||||
|
* 网页端绑定在进服即落本地,登录 IP 风控的 isEnabled() 读到的就是同步后状态。
|
||||||
|
* 无回调、无提示(除非真的导入了网页绑定);网络失败静默跳过。
|
||||||
|
*/
|
||||||
|
public void syncOnJoin(String playerName) {
|
||||||
|
if (plugin.webManager == null || playerName == null || playerName.isEmpty()) return;
|
||||||
|
final String name = playerName;
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
WebManager.TwoFaWebState web = null;
|
||||||
|
try {
|
||||||
|
web = plugin.webManager.pullTwoFactorState(name);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[2FA] 进服同步拉取异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
final WebManager.TwoFaWebState st = web;
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
try {
|
||||||
|
Player pl = Bukkit.getPlayerExact(name);
|
||||||
|
if (pl == null || !pl.isOnline()) return; // 已下线:跳过(无处提示,/2fa 时还会再同步)
|
||||||
|
applyWebState(pl, st);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[2FA] 进服同步合并异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 本地绑定时刻(秒)—— 绑定完成时写入,供与网页端 bound_at 比新旧 */
|
||||||
|
private void markBoundNow(String name) {
|
||||||
|
plugin.getDb().setField(name, "twofa_bound_at", System.currentTimeMillis() / 1000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long longOf(Object v) {
|
||||||
|
if (v instanceof Number) return ((Number) v).longValue();
|
||||||
|
try {
|
||||||
|
return Long.parseLong(String.valueOf(v).trim());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 状态读取 ====================
|
// ==================== 状态读取 ====================
|
||||||
|
|
||||||
private boolean isEnabled(Player p) {
|
private boolean isEnabled(Player p) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class WelcomeManager {
|
public class WelcomeManager {
|
||||||
|
//
|
||||||
private final Main plugin;
|
private final Main plugin;
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
private final List<String> registerMsgs =
|
private final List<String> registerMsgs =
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"对话留档":{
|
||||||
|
"怎么写":"键是提问,值是回答",
|
||||||
|
"谁来写":"每次提问/控场自动写",
|
||||||
|
"请求失败":"响应原文落盘"
|
||||||
|
},
|
||||||
|
"问":"答",
|
||||||
|
"自动":"答"
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
{
|
||||||
|
"人设部分": {
|
||||||
|
"服务器名字": "",
|
||||||
|
"助理名字": "",
|
||||||
|
"写法": "1行1个"
|
||||||
|
},
|
||||||
|
"配置部分": {
|
||||||
|
"1": {
|
||||||
|
"模型配置": {
|
||||||
|
"内置供应商": {
|
||||||
|
"供应商名字": "",
|
||||||
|
"apikey": "",
|
||||||
|
"max_token": "",
|
||||||
|
"可用模型": [],
|
||||||
|
"默认使用": ""
|
||||||
|
},
|
||||||
|
"自定义供应商": {
|
||||||
|
"baseurl": "",
|
||||||
|
"apikey": "",
|
||||||
|
"max_token": "",
|
||||||
|
"可用模型": [],
|
||||||
|
"默认使用": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"默认上下文长度": "200000",
|
||||||
|
"发言间隔": {
|
||||||
|
"最短": "",
|
||||||
|
"最长": "",
|
||||||
|
"注释": "单位分钟",
|
||||||
|
"自动发言": true
|
||||||
|
},
|
||||||
|
"自动补齐": {
|
||||||
|
"开关": true,
|
||||||
|
"备注": "如果你的厂商"
|
||||||
|
},
|
||||||
|
"互动指标": {
|
||||||
|
"指标": 1,
|
||||||
|
"说明": "指标为在线玩家数量,当在线玩家大于等于指标才会触发自动互动。手动不受此影响。此字段为强制值,若你填写的值≤1,则代码仍按1执行。≥1时以此字段配置值为基准"
|
||||||
|
},
|
||||||
|
"黑名单": [
|
||||||
|
"说明: 一行一个,用双引号包裹。每行末尾加英文逗号,最后一行不加",
|
||||||
|
"命中黑名单时AI直接返回「我无法就此问题,展开讨论和回答」,不告知玩家命中,掐断API请求"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"填写规范": {
|
||||||
|
"自定义": {
|
||||||
|
"baseurl": "填写厂家给你的地址,比如https://example.com/v1",
|
||||||
|
"apikey": "填厂家开放平台的key,比如sk-example",
|
||||||
|
"可用模型": "填厂家给的模型名字,比如example",
|
||||||
|
"max_token": "上下文长度,不填则使用默认20万上下文长度",
|
||||||
|
"默认使用": "默认使用哪个模型,此配置仅影响自动模式下,默认发起请求的模型。手动@不受此影响"
|
||||||
|
},
|
||||||
|
"内置供应商": {
|
||||||
|
"供应商名字": "一层一层填,比如mimo/按量计费,deepseek等",
|
||||||
|
"apikey": "填厂家开放平台的key,比如sk-example",
|
||||||
|
"可用模型": "填厂家给的模型名字,比如example",
|
||||||
|
"max_token": "上下文长度,不填则使用默认20万上下文长度",
|
||||||
|
"默认使用": "默认使用哪个模型,此配置仅影响自动模式下,默认发起请求的模型。手动@不受此影响"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"配置填写示例": {
|
||||||
|
"自定义供应商": {
|
||||||
|
"baseurl": "https://example.com/v1",
|
||||||
|
"apikey": "sk-example",
|
||||||
|
"max_token": "1000000",
|
||||||
|
"可用模型": [
|
||||||
|
"example"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"内置供应商": {
|
||||||
|
"供应商名字": "mimo/token-plan",
|
||||||
|
"apikey": "sk-example",
|
||||||
|
"可用模型": [
|
||||||
|
"mimo-v2.6-flash",
|
||||||
|
"mimo-v2.6-pro"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"内置供应商1": {
|
||||||
|
"供应商名字": "deepseek",
|
||||||
|
"apikey": "sk-example",
|
||||||
|
"可用模型": [
|
||||||
|
"deepseek-flash",
|
||||||
|
"deepseek-v4-pro"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"内置供应商3": {
|
||||||
|
"供应商名字": "讯飞/讯飞星辰maas/标准",
|
||||||
|
"apikey": "sk-example",
|
||||||
|
"可用模型": [
|
||||||
|
"spakr-x2.6",
|
||||||
|
"xopglm5"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"openai协议": "内置供应商",
|
||||||
|
"添加方法": [
|
||||||
|
"键值对格式,键是供应商名字,值是请求地址",
|
||||||
|
"如果供应商有区分按量计费、token-plan则用一堆花括号即可。可参考mimo的写法",
|
||||||
|
"如果要备注,就用花括号展开,比如向Agnes、opencode一样",
|
||||||
|
"额外说明:本文件默认会从插件内置的服务器定期拉取更新。"
|
||||||
|
],
|
||||||
|
"国产": {
|
||||||
|
"mimo": {
|
||||||
|
"按量计费": "https://api.xiaomimimo.com/v1",
|
||||||
|
"token-plan": "https://token-plan-cn.xiaomimimo.com/v1",
|
||||||
|
"批量推理": "https://batch-api-cn.xiaomimimo.com/v1"
|
||||||
|
},
|
||||||
|
"deepseek": "https://api.deepseek.com",
|
||||||
|
"kimi": "https://api.moonshot.cn/v1",
|
||||||
|
"智谱GLM": "https://open.bigmodel.cn/api/paas/v4",
|
||||||
|
"通义千问": "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||||
|
"百度AIStudio": "https://aistudio.baidu.com/llm/lmapi/v3",
|
||||||
|
"MiniMax": "https://api.minimax.cn/v1",
|
||||||
|
"阶跃星辰": {
|
||||||
|
"标准": "https://api.stepfun.com/v1",
|
||||||
|
"step-plan": "https://api.stepfun.com/step_plan/v1"
|
||||||
|
},
|
||||||
|
"零一万物": "https://api.lingyiwanwu.com/v1",
|
||||||
|
"百川": "https://api.baichuan-ai.com/v1",
|
||||||
|
"美团": "https://api.longcat.chat/openai",
|
||||||
|
"抖音云(豆包/火山)": "https://ark.cn-beijing.volces.com/api/v3",
|
||||||
|
"讯飞": {
|
||||||
|
"讯飞星火": "https://spark-api-open.xf-yun.com/v1",
|
||||||
|
"讯飞星辰MaaS": {
|
||||||
|
"标准": "https://maas-api.cn-huabei-1.xf-yun.com/v2",
|
||||||
|
"Coding Plan": "https://maas-coding-api.cn-huabei-1.xf-yun.com/v2",
|
||||||
|
"Token Plan": "https://maas-token-api.cn-huabei-1.xf-yun.com/v2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"腾讯云": {
|
||||||
|
"Token Plan": "https://api.lkeap.cloud.tencent.com/plan/v3",
|
||||||
|
"Coding Plan": "https://api.lkeap.cloud.tencent.com/coding/v3",
|
||||||
|
"TokenHub(广州)": "https://tokenhub.tencentmaas.com",
|
||||||
|
"TokenHub(新加坡)": "https://tokenhub-intl.tencentmaas.com"
|
||||||
|
},
|
||||||
|
"硅基流动": "https://api.siliconflow.cn/v1",
|
||||||
|
"书生端砚": "https://discovery-api.intern-ai.org.cn/v1"
|
||||||
|
},
|
||||||
|
"非国产": {
|
||||||
|
"OpenAI": "https://api.openai.com/v1",
|
||||||
|
"Claude(Anthropic)": "https://api.anthropic.com/v1/",
|
||||||
|
"推特(xAI Grok)": "https://api.x.ai/v1",
|
||||||
|
"Gemini": "https://generativelanguage.googleapis.com/v1beta/openai/",
|
||||||
|
"英伟达": "https://integrate.api.nvidia.com/v1",
|
||||||
|
"agnes": {
|
||||||
|
"国际版": "https://apihub.agnes-ai.com/v1",
|
||||||
|
"中国版": "https://apihub.agnes-ai.cn/v1",
|
||||||
|
"说明": "中国版和国际版互通key,但账号、token-plan不互通"
|
||||||
|
},
|
||||||
|
"opencode": {
|
||||||
|
"zen": "https://opencode.ai/zen/v1",
|
||||||
|
"go": "https://opencode.ai/zen/go/v1",
|
||||||
|
"说明": "opencode zen可以通过9router或其它工具反代opencode cli终端免费使用。但不推荐,额度特别低。作者实测:反代出来跑了50万~100万左右就429限流。"
|
||||||
|
},
|
||||||
|
"OpenRouter": "https://openrouter.ai/api/v1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# 此文件填写的模型将被正是运用请求
|
||||||
|
# 以#开头的表示注释,会被忽略
|
||||||
|
# models=name,这个=就是模型的简称,比如你可以配置deepseek=大肥鱼,后续用户@大肥鱼 xx,就会自动向deepseek的模型发起请求。可以是一个厂家,也可以是单独的模型
|
||||||
|
# 以下是示例配置
|
||||||
|
# 大肥鱼=deepseek-flash
|
||||||
|
# 这里大肥鱼=deepseek-flash,意思是@大肥鱼时,向deepseek-flash模型发起请求,而deepseek-v4-pro不受影响,因为没命中这条规则
|
||||||
|
# 噶啦吗=GLM
|
||||||
|
# 这里噶啦吗=glm,意思是@噶啦吗时,向配置的GLM系列模型发起请求。所有glm系列厂家都会影响,不管是glm5.3、glm5.2等
|
||||||
|
# 不区分大小写
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: Sdf1_login
|
name: Sdf1_login
|
||||||
version: 3.1
|
version: 3.30
|
||||||
main: Sdf1_login.Main
|
main: Sdf1_login.Main
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
commands:
|
commands:
|
||||||
@@ -72,6 +72,9 @@ commands:
|
|||||||
绑定邮箱:
|
绑定邮箱:
|
||||||
description: 绑定邮箱
|
description: 绑定邮箱
|
||||||
usage: /绑定邮箱
|
usage: /绑定邮箱
|
||||||
|
webbind:
|
||||||
|
description: 网页邮箱绑定批准/拒绝
|
||||||
|
usage: /webbind <approve|reject> <id>
|
||||||
chat:
|
chat:
|
||||||
description: 聊天过滤管理
|
description: 聊天过滤管理
|
||||||
usage: /chat
|
usage: /chat
|
||||||
@@ -208,3 +211,6 @@ commands:
|
|||||||
json:
|
json:
|
||||||
description: JSON消息构造器(tellraw/大标题/小标题/actionbar+颜色,需OP以上权限)
|
description: JSON消息构造器(tellraw/大标题/小标题/actionbar+颜色,需OP以上权限)
|
||||||
usage: /json
|
usage: /json
|
||||||
|
credits:
|
||||||
|
description: 信誉积分管理(上报/审批/记录/规则)
|
||||||
|
usage: /credits [上报|审批|记录|规则] [参数]
|
||||||
|
|||||||
Reference in New Issue
Block a user