修复protect命令参数问题、修复文档链接、添加用户UI偏好列(ui_mode)、txt迁移领地自动分配给管理员
This commit is contained in:
@@ -420,7 +420,7 @@ public class AreaGUIManager implements Listener {
|
||||
p.sendMessage("§7权限模板功能开发中...");
|
||||
} else if (raw == 40) {
|
||||
p.closeInventory();
|
||||
p.sendMessage("§a文档链接: https://docs.sdf1.com/area-protection");
|
||||
p.sendMessage("§a文档链接: https://wiki.ypshidifu.cn");
|
||||
} else if (raw == 49) {
|
||||
plugin.getGui().openMain(p);
|
||||
}
|
||||
|
||||
@@ -1151,6 +1151,9 @@ public class AreaProtection implements Listener {
|
||||
// 创建迁移完成标记文件,防止重复迁移
|
||||
File marker = new File(rootDir, ".db_migrated");
|
||||
marker.createNewFile();
|
||||
// 创建owner待分配标记文件
|
||||
File ownerMarker = new File(rootDir, ".need_owner_assign");
|
||||
ownerMarker.createNewFile();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("[防护] 迁移过程异常: " + e.getMessage());
|
||||
@@ -2105,6 +2108,33 @@ public class AreaProtection implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动将无owner的txt迁移领地分配给第一个操作的管理员
|
||||
*/
|
||||
private void assignUnownedLandsToAdmin(Player admin) {
|
||||
File ownerMarker = new File(rootDir, ".need_owner_assign");
|
||||
if (!ownerMarker.exists()) return;
|
||||
|
||||
String adminName = admin.getName();
|
||||
int assigned = 0;
|
||||
|
||||
for (AreaConfig ac : areas.values()) {
|
||||
if (ac.owner == null || ac.owner.isEmpty()) {
|
||||
ac.owner = adminName;
|
||||
saveAreaToDb(ac);
|
||||
assigned++;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除标记文件
|
||||
ownerMarker.delete();
|
||||
|
||||
if (assigned > 0) {
|
||||
admin.sendMessage("§a§l[防护] 已将 " + assigned + " 个无主领地分配给你");
|
||||
plugin.getLogger().info("[防护] txt迁移领地已分配给管理员: " + adminName + " 共" + assigned + "个");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isItemBlacklisted(String itemId,
|
||||
AreaConfig ac) {
|
||||
if (globalItemBlacklist.contains(
|
||||
@@ -3951,11 +3981,12 @@ public class AreaProtection implements Listener {
|
||||
"add", "remove", "additem", "removeitem",
|
||||
"addname", "removename", "listname",
|
||||
"addwhite", "removewhite", "listwhite",
|
||||
"list", "listitem", "创建", "删除", "重载",
|
||||
"工具", "expand", "contraction",
|
||||
"list", "listitem", "创建", "create", "删除", "delete", "重载", "reload",
|
||||
"工具", "wand", "expand", "contraction",
|
||||
"on", "off", "tempon", "modeexempt",
|
||||
"info", "setowner", "addvisitor", "removevisitor",
|
||||
"listvisitors", "transfer", "shop"
|
||||
"listvisitors", "transfer", "shop",
|
||||
"menu", "菜单", "sdf1debug", "testclear"
|
||||
));
|
||||
|
||||
String first = original[0].toLowerCase();
|
||||
@@ -3996,6 +4027,11 @@ public class AreaProtection implements Listener {
|
||||
return true;
|
||||
}
|
||||
String sub = args[0].toLowerCase();
|
||||
|
||||
// ★ 管理员操作时,自动分配无owner的领地
|
||||
if (sender instanceof Player && isAreaAdmin(sender)) {
|
||||
assignUnownedLandsToAdmin((Player) sender);
|
||||
}
|
||||
// ===== 诊断命令 =====
|
||||
if (sub.equals("sdf1debug")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
|
||||
@@ -88,6 +88,9 @@ public class DatabaseManager {
|
||||
"TEXT DEFAULT ''");
|
||||
safeAdd(st, "last_login_ip",
|
||||
"TEXT DEFAULT ''");
|
||||
// UI偏好:1=CLI(默认), 0=GUI
|
||||
safeAdd(st, "ui_mode",
|
||||
"INTEGER DEFAULT 1");
|
||||
|
||||
// ===== 背包备份表:安全迁移 =====
|
||||
// 检查旧表是否存在(用 inventory_data 列判断)
|
||||
@@ -281,6 +284,47 @@ public class DatabaseManager {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== UI偏好 ====================
|
||||
|
||||
/**
|
||||
* 获取玩家UI偏好
|
||||
* @return 1=CLI(默认), 0=GUI
|
||||
*/
|
||||
public int getUiMode(String playerName) {
|
||||
try {
|
||||
PreparedStatement ps = db.prepareStatement(
|
||||
"SELECT ui_mode FROM users WHERE player_name=?");
|
||||
ps.setString(1, playerName);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
int mode = 1; // 默认CLI
|
||||
if (rs.next()) {
|
||||
mode = rs.getInt("ui_mode");
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
return mode;
|
||||
} catch (SQLException e) {
|
||||
return 1; // 默认CLI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置玩家UI偏好
|
||||
* @param mode 1=CLI, 0=GUI
|
||||
*/
|
||||
public void setUiMode(String playerName, int mode) {
|
||||
try {
|
||||
PreparedStatement ps = db.prepareStatement(
|
||||
"UPDATE users SET ui_mode=? WHERE player_name=?");
|
||||
ps.setInt(1, mode);
|
||||
ps.setString(2, playerName);
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
} catch (SQLException e) {
|
||||
// 静默
|
||||
}
|
||||
}
|
||||
// ==================== 菜单图标 ====================
|
||||
|
||||
public void saveMenuIcon(String name,
|
||||
|
||||
Reference in New Issue
Block a user