第63批:信仰积分系统完善
- credit_rules 表扩展 limit_amount/multiplier 两列 - 6条内置规则默认全禁用: * <60分:债券每小时交易限额5000元 * <20分:禁止使用群戏传送 * <0分:二手商店低信誉警示 * <-10分:禁止CDK+债券限额1000元 * >80分:债券交易额1.2倍 * >100分:二手商店高信誉推荐 - isRestricted 改为双向阈值判定(支持负数 min_score) - 新增 getBondTradeLimit/getBondTradeMultiplier/isShopLowWarning/isShopHighRecommend - BondManager deductBonds/addBonds 接入交易限额(买入+卖出全算) - TeleportManager tpaall 接入禁止规则 - CDKManager redeem 接入禁止规则 - ShopManager 二手商店商品lore接入信誉标记 - CreditManager 管理员GUI新增规则配置入口 - PHP credit.php 同步表结构+6条规则 - PHP admin.php 规则展示更新为新类型
This commit is contained in:
@@ -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=?");
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public class CreditManager {
|
|||||||
+ ")");
|
+ ")");
|
||||||
|
|
||||||
// 信誉限制规则表
|
// 信誉限制规则表
|
||||||
|
// ★ 第63批:新增 limit_amount(限额) 和 multiplier(倍数) 两列
|
||||||
st.execute("CREATE TABLE IF NOT EXISTS credit_rules ("
|
st.execute("CREATE TABLE IF NOT EXISTS credit_rules ("
|
||||||
+ "id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
+ "id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||||
+ "rule_name TEXT NOT NULL UNIQUE,"
|
+ "rule_name TEXT NOT NULL UNIQUE,"
|
||||||
@@ -139,10 +140,16 @@ public class CreditManager {
|
|||||||
+ "max_score INTEGER DEFAULT 0,"
|
+ "max_score INTEGER DEFAULT 0,"
|
||||||
+ "restriction_type TEXT DEFAULT '',"
|
+ "restriction_type TEXT DEFAULT '',"
|
||||||
+ "restriction_duration INTEGER DEFAULT 0,"
|
+ "restriction_duration INTEGER DEFAULT 0,"
|
||||||
+ "enabled INTEGER DEFAULT 1,"
|
+ "enabled INTEGER DEFAULT 0,"
|
||||||
+ "description TEXT DEFAULT ''"
|
+ "description TEXT DEFAULT '',"
|
||||||
|
+ "limit_amount REAL DEFAULT 0,"
|
||||||
|
+ "multiplier REAL DEFAULT 0"
|
||||||
+ ")");
|
+ ")");
|
||||||
|
|
||||||
|
// ★ 第63批:已有表扩展新列(列已存在时报错,忽略)
|
||||||
|
try { st.executeUpdate("ALTER TABLE credit_rules ADD COLUMN limit_amount REAL DEFAULT 0"); } catch (Exception ignored) {}
|
||||||
|
try { st.executeUpdate("ALTER TABLE credit_rules ADD COLUMN multiplier REAL DEFAULT 0"); } catch (Exception ignored) {}
|
||||||
|
|
||||||
// 默认规则初始化
|
// 默认规则初始化
|
||||||
initDefaultRules();
|
initDefaultRules();
|
||||||
|
|
||||||
@@ -157,15 +164,43 @@ public class CreditManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:6条内置规则,默认全部禁用(enabled=0)
|
||||||
|
* 每条规则启用后,满足分数阈值时对目标玩家做对应限制/加成
|
||||||
|
*/
|
||||||
private void initDefaultRules() {
|
private void initDefaultRules() {
|
||||||
try {
|
try {
|
||||||
Statement st = db.getConnection().createStatement();
|
Statement st = db.getConnection().createStatement();
|
||||||
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, description) "
|
|
||||||
+ "VALUES ('禁止交易', 60, 0, 'trade', 0, '低于60分时禁止与NPC交易')");
|
// 规则1: <60分 → 债券每小时交易限额5000元(卖出/买入全算)
|
||||||
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, description) "
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
+ "VALUES ('禁止PVP', 40, 0, 'pvp', 0, '低于40分时禁止进入PVP竞技场')");
|
+ "VALUES ('债券交易限额5000', 60, 0, 'bond_trade_limit', 0, 0, '低于60分时债券每小时交易限额5000元(买入/卖出全算)', 5000, 0)");
|
||||||
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, description) "
|
|
||||||
+ "VALUES ('禁止传送', 20, 0, 'teleport', 0, '低于20分时禁止使用传送功能')");
|
// 规则2: <20分 → 禁止使用群戏传送
|
||||||
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
|
+ "VALUES ('禁止群戏传送', 20, 0, 'block_tpaall', 0, 0, '低于20分时禁止使用群戏传送(/tpaall)', 0, 0)");
|
||||||
|
|
||||||
|
// 规则3: <0分 → 二手商店内商品标记,提示买家谨慎购买
|
||||||
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
|
+ "VALUES ('二手商店低信誉警示', 0, 0, 'shop_low_warning', 0, 0, '低于0分时二手商店商品标记为低信誉卖家,提示买家谨慎购买', 0, 0)");
|
||||||
|
|
||||||
|
// 规则4: <-10分 → 禁止使用CDK + 债券每小时交易限额1000元
|
||||||
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
|
+ "VALUES ('禁止CDK+债券限额1000', -10, 0, 'block_cdk_and_bond', 0, 0, '低于-10分时禁止使用CDK兑换码,债券每小时交易限额1000元(买入/卖出全算)', 1000, 0)");
|
||||||
|
|
||||||
|
// 规则5: >80分 → 债券每小时交易额1.2倍(接入债券出售限额)
|
||||||
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
|
+ "VALUES ('债券交易额1.2倍', 0, 80, 'bond_trade_bonus', 0, 0, '高于80分时债券每小时交易额1.2倍(接入债券出售限额)', 0, 1.2)");
|
||||||
|
|
||||||
|
// 规则6: >100分 → 二手商店内商品标记为信誉极好,放心购买
|
||||||
|
st.execute("INSERT OR IGNORE INTO credit_rules (rule_name, min_score, max_score, restriction_type, restriction_duration, enabled, description, limit_amount, multiplier) "
|
||||||
|
+ "VALUES ('二手商店高信誉推荐', 0, 100, 'shop_high_recommend', 0, 0, '高于100分时二手商店商品标记为信誉极好卖家,可以放心购买', 0, 0)");
|
||||||
|
|
||||||
|
// ★ 清理旧规则(禁止交易/禁止PVP/禁止传送)
|
||||||
|
// 第63批替换了内置规则,旧的3条规则不再使用,删除它们
|
||||||
|
// 保留管理员手动添加的自定义规则(这些不在内置规则列表中)
|
||||||
|
st.execute("DELETE FROM credit_rules WHERE rule_name IN ('禁止交易', '禁止PVP', '禁止传送')");
|
||||||
|
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,6 +519,9 @@ public class CreditManager {
|
|||||||
row.put("restriction_type", rs.getString("restriction_type"));
|
row.put("restriction_type", rs.getString("restriction_type"));
|
||||||
row.put("restriction_duration", rs.getInt("restriction_duration"));
|
row.put("restriction_duration", rs.getInt("restriction_duration"));
|
||||||
row.put("description", rs.getString("description"));
|
row.put("description", rs.getString("description"));
|
||||||
|
// ★ 第63批:新增列
|
||||||
|
try { row.put("limit_amount", rs.getDouble("limit_amount")); } catch (Exception ignored) {}
|
||||||
|
try { row.put("multiplier", rs.getDouble("multiplier")); } catch (Exception ignored) {}
|
||||||
list.add(row);
|
list.add(row);
|
||||||
}
|
}
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -493,15 +531,151 @@ public class CreditManager {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:获取所有规则(含禁用)供管理员GUI展示
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> getAllRules() {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
PreparedStatement ps = db.getConnection().prepareStatement(
|
||||||
|
"SELECT * FROM credit_rules ORDER BY min_score DESC, rule_name");
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
Map<String, Object> row = new LinkedHashMap<>();
|
||||||
|
row.put("id", rs.getInt("id"));
|
||||||
|
row.put("rule_name", rs.getString("rule_name"));
|
||||||
|
row.put("min_score", rs.getInt("min_score"));
|
||||||
|
row.put("max_score", rs.getInt("max_score"));
|
||||||
|
row.put("restriction_type", rs.getString("restriction_type"));
|
||||||
|
row.put("restriction_duration", rs.getInt("restriction_duration"));
|
||||||
|
row.put("enabled", rs.getInt("enabled"));
|
||||||
|
row.put("description", rs.getString("description"));
|
||||||
|
try { row.put("limit_amount", rs.getDouble("limit_amount")); } catch (Exception ignored) {}
|
||||||
|
try { row.put("multiplier", rs.getDouble("multiplier")); } catch (Exception ignored) {}
|
||||||
|
list.add(row);
|
||||||
|
}
|
||||||
|
ps.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[信誉积分] 查询所有规则失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:切换规则启用/禁用状态
|
||||||
|
*/
|
||||||
|
public boolean toggleRule(int ruleId) {
|
||||||
|
try {
|
||||||
|
PreparedStatement ps = db.getConnection().prepareStatement(
|
||||||
|
"UPDATE credit_rules SET enabled = CASE enabled WHEN 1 THEN 0 ELSE 1 END WHERE id = ?");
|
||||||
|
ps.setInt(1, ruleId);
|
||||||
|
ps.executeUpdate();
|
||||||
|
ps.close();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[信誉积分] 切换规则失败: " + e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:检查玩家是否受某类型限制
|
||||||
|
* - score < min_score → 触发(低于阈值,min_score 可为正/零/负)
|
||||||
|
* - score > max_score → 触发(高于阈值,bonus类规则)
|
||||||
|
*/
|
||||||
public boolean isRestricted(String playerName, String restrictionType) {
|
public boolean isRestricted(String playerName, String restrictionType) {
|
||||||
double score = getScore(playerName);
|
double score = getScore(playerName);
|
||||||
for (Map<String, Object> rule : getEnabledRules()) {
|
for (Map<String, Object> rule : getEnabledRules()) {
|
||||||
double minScore = ((Number) rule.get("min_score")).doubleValue();
|
|
||||||
String type = (String) rule.get("restriction_type");
|
String type = (String) rule.get("restriction_type");
|
||||||
if (score < minScore && type.equals(restrictionType)) {
|
if (!type.equals(restrictionType)) continue;
|
||||||
return true;
|
double minScore = ((Number) rule.get("min_score")).doubleValue();
|
||||||
|
double maxScore = ((Number) rule.get("max_score")).doubleValue();
|
||||||
|
// 低于阈值触发(覆盖所有 min_score 情况:正/零/负)
|
||||||
|
if (score < minScore) return true;
|
||||||
|
// 高于阈值触发(bonus类规则)
|
||||||
|
if (maxScore > 0 && score > maxScore) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:获取玩家债券每小时交易限额
|
||||||
|
* 规则1: <60分 → 5000元
|
||||||
|
* 规则4: <-10分 → 1000元(更严格,覆盖规则1)
|
||||||
|
* 返回 0 表示无限制
|
||||||
|
*/
|
||||||
|
public double getBondTradeLimit(String playerName) {
|
||||||
|
double score = getScore(playerName);
|
||||||
|
double limit = 0;
|
||||||
|
for (Map<String, Object> rule : getEnabledRules()) {
|
||||||
|
String type = (String) rule.get("restriction_type");
|
||||||
|
if (!type.equals("bond_trade_limit") && !type.equals("block_cdk_and_bond")) continue;
|
||||||
|
double ruleLimit = ((Number) rule.getOrDefault("limit_amount", 0)).doubleValue();
|
||||||
|
if (ruleLimit <= 0) continue;
|
||||||
|
double minScore = ((Number) rule.get("min_score")).doubleValue();
|
||||||
|
// 分数低于阈值 → 适用此限额
|
||||||
|
if (score < minScore) {
|
||||||
|
// 取最严格的限额(最小的值)
|
||||||
|
if (limit == 0 || ruleLimit < limit) {
|
||||||
|
limit = ruleLimit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:获取玩家债券交易倍数
|
||||||
|
* 规则5: >80分 → 1.2倍
|
||||||
|
* 返回 1.0 表示无加成
|
||||||
|
*/
|
||||||
|
public double getBondTradeMultiplier(String playerName) {
|
||||||
|
double score = getScore(playerName);
|
||||||
|
double multiplier = 1.0;
|
||||||
|
for (Map<String, Object> rule : getEnabledRules()) {
|
||||||
|
String type = (String) rule.get("restriction_type");
|
||||||
|
if (!type.equals("bond_trade_bonus")) continue;
|
||||||
|
double ruleMultiplier = ((Number) rule.getOrDefault("multiplier", 0)).doubleValue();
|
||||||
|
if (ruleMultiplier <= 0) continue;
|
||||||
|
double maxScore = ((Number) rule.get("max_score")).doubleValue();
|
||||||
|
// 分数高于阈值 → 适用此倍数
|
||||||
|
if (score > maxScore) {
|
||||||
|
// 取最高的倍数
|
||||||
|
if (ruleMultiplier > multiplier) {
|
||||||
|
multiplier = ruleMultiplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:二手商店低信誉警示(规则3)
|
||||||
|
* 分数 < 0 时返回 true,商品标记为低信誉卖家
|
||||||
|
*/
|
||||||
|
public boolean isShopLowWarning(String playerName) {
|
||||||
|
double score = getScore(playerName);
|
||||||
|
for (Map<String, Object> rule : getEnabledRules()) {
|
||||||
|
String type = (String) rule.get("restriction_type");
|
||||||
|
if (!type.equals("shop_low_warning")) continue;
|
||||||
|
double minScore = ((Number) rule.get("min_score")).doubleValue();
|
||||||
|
if (score < minScore) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:二手商店高信誉推荐(规则6)
|
||||||
|
* 分数 > 100 时返回 true,商品标记为信誉极好
|
||||||
|
*/
|
||||||
|
public boolean isShopHighRecommend(String playerName) {
|
||||||
|
double score = getScore(playerName);
|
||||||
|
for (Map<String, Object> rule : getEnabledRules()) {
|
||||||
|
String type = (String) rule.get("restriction_type");
|
||||||
|
if (!type.equals("shop_high_recommend")) continue;
|
||||||
|
double maxScore = ((Number) rule.get("max_score")).doubleValue();
|
||||||
|
if (score > maxScore) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,9 +689,17 @@ public class CreditManager {
|
|||||||
Player p = Bukkit.getPlayerExact(playerName);
|
Player p = Bukkit.getPlayerExact(playerName);
|
||||||
if (p == null || !p.isOnline()) continue;
|
if (p == null || !p.isOnline()) continue;
|
||||||
|
|
||||||
if (score < minScore && (maxScore == 0 || score <= maxScore)) {
|
// 低于阈值触发(限制类规则)
|
||||||
p.sendMessage("§c§l[信誉积分] §f你的积分 " + formatScore(score) + " 低于阈值 " + formatScore(minScore) + ","
|
boolean belowThreshold = score < minScore;
|
||||||
+ "已触发限制: " + desc);
|
// 高于阈值触发(加成类规则,如债券1.2倍)
|
||||||
|
boolean aboveThreshold = maxScore > 0 && score > maxScore;
|
||||||
|
|
||||||
|
if (belowThreshold || aboveThreshold) {
|
||||||
|
String direction = belowThreshold ? "低于阈值" : "高于阈值";
|
||||||
|
double threshold = belowThreshold ? minScore : maxScore;
|
||||||
|
p.sendMessage("§c§l[信誉积分] §f你的积分 " + formatScore(score) + " " + direction
|
||||||
|
+ " " + formatScore(threshold) + ","
|
||||||
|
+ (aboveThreshold ? "§a已触发加成: " : "已触发限制: ") + desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,19 +773,22 @@ public class CreditManager {
|
|||||||
"§7查看历史审批记录",
|
"§7查看历史审批记录",
|
||||||
"§7点击查看"));
|
"§7点击查看"));
|
||||||
|
|
||||||
// Slot 9: 规则说明
|
// Slot 9: 规则配置(管理员)
|
||||||
inv.setItem(9, mkItem(Material.IRON_INGOT,
|
inv.setItem(9, mkItem(Material.COMMAND_BLOCK,
|
||||||
"§7§l规则说明",
|
"§6§l规则配置",
|
||||||
"§7低于60分: 禁止交易",
|
"§7管理信誉积分限制规则",
|
||||||
"§7低于40分: 禁止PVP",
|
"§7启用/禁用内置规则",
|
||||||
"§7低于20分: 禁止传送"));
|
"§7点击查看"));
|
||||||
} else {
|
} else {
|
||||||
// ═══════════════ 非管理员:规则说明放在 Slot 5 ═══════════════
|
// ═══════════════ 非管理员:规则说明放在 Slot 5 ═══════════════
|
||||||
inv.setItem(5, mkItem(Material.IRON_INGOT,
|
inv.setItem(5, mkItem(Material.IRON_INGOT,
|
||||||
"§7§l规则说明",
|
"§7§l规则说明",
|
||||||
"§7低于60分: 禁止交易",
|
"§7信誉积分低于60分: 债券交易限额5000元",
|
||||||
"§7低于40分: 禁止PVP",
|
"§7信誉积分低于20分: 禁止使用群戏传送",
|
||||||
"§7低于20分: 禁止传送"));
|
"§7信誉积分低于0分: 二手商店警示买家",
|
||||||
|
"§7信誉积分低于-10分: 禁止CDK+债券限额1000元",
|
||||||
|
"§7信誉积分高于80分: 债券交易额1.2倍",
|
||||||
|
"§7信誉积分高于100分: 二手商店信誉极好"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return inv;
|
return inv;
|
||||||
@@ -832,6 +1017,102 @@ public class CreditManager {
|
|||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ★ 第63批:规则配置GUI(27格,每页显示5条规则)
|
||||||
|
* 布局:
|
||||||
|
* Slot 0-4: 5条规则(点击启用/禁用)
|
||||||
|
* Slot 21: 返回
|
||||||
|
* Slot 22: 上一页
|
||||||
|
* Slot 23: 下一页
|
||||||
|
* Slot 24: 页码信息
|
||||||
|
*/
|
||||||
|
private static final int RULES_MENU_SIZE = 27;
|
||||||
|
private static final int RULES_PER_PAGE = 5;
|
||||||
|
|
||||||
|
private final Map<String, Integer> rulesPage = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public Inventory createRulesGUI(Player p, int page) {
|
||||||
|
Inventory inv = Bukkit.createInventory(null, RULES_MENU_SIZE, GUI_TITLE + " - 规则配置");
|
||||||
|
fillBg(inv);
|
||||||
|
|
||||||
|
List<Map<String, Object>> rules = getAllRules();
|
||||||
|
int totalCount = rules.size();
|
||||||
|
int totalPages = Math.max(1, (totalCount + RULES_PER_PAGE - 1) / RULES_PER_PAGE);
|
||||||
|
if (page < 1) page = 1;
|
||||||
|
if (page > totalPages) page = totalPages;
|
||||||
|
int offset = (page - 1) * RULES_PER_PAGE;
|
||||||
|
|
||||||
|
for (int i = 0; i < RULES_PER_PAGE; i++) {
|
||||||
|
int idx = offset + i;
|
||||||
|
if (idx >= rules.size()) break;
|
||||||
|
Map<String, Object> r = rules.get(idx);
|
||||||
|
int ruleId = ((Number) r.get("id")).intValue();
|
||||||
|
int enabled = ((Number) r.get("enabled")).intValue();
|
||||||
|
String ruleName = (String) r.get("rule_name");
|
||||||
|
String description = (String) r.get("description");
|
||||||
|
double minScore = ((Number) r.get("min_score")).doubleValue();
|
||||||
|
double maxScore = ((Number) r.get("max_score")).doubleValue();
|
||||||
|
double limitAmount = ((Number) r.getOrDefault("limit_amount", 0)).doubleValue();
|
||||||
|
double multiplier = ((Number) r.getOrDefault("multiplier", 0)).doubleValue();
|
||||||
|
|
||||||
|
// 启用状态决定颜色和材质
|
||||||
|
Material mat = enabled == 1 ? Material.GREEN_WOOL : Material.RED_WOOL;
|
||||||
|
String statusText = enabled == 1 ? "§a§l已启用" : "§c§l已禁用";
|
||||||
|
|
||||||
|
// 构建lore
|
||||||
|
String thresholdText;
|
||||||
|
if (minScore > 0 && maxScore > 0) {
|
||||||
|
thresholdText = "§7阈值: " + minScore + " < 积分 < " + maxScore;
|
||||||
|
} else if (minScore > 0) {
|
||||||
|
thresholdText = "§7低于 " + minScore + " 分时触发";
|
||||||
|
} else if (maxScore > 0) {
|
||||||
|
thresholdText = "§7高于 " + maxScore + " 分时触发";
|
||||||
|
} else {
|
||||||
|
thresholdText = "§7无限阈值";
|
||||||
|
}
|
||||||
|
|
||||||
|
String detailText = "§7" + description;
|
||||||
|
if (limitAmount > 0) {
|
||||||
|
detailText += "\n§7限额: " + formatScore(limitAmount) + " 元/小时";
|
||||||
|
}
|
||||||
|
if (multiplier > 0) {
|
||||||
|
detailText += "\n§7倍数: " + multiplier + " 倍";
|
||||||
|
}
|
||||||
|
|
||||||
|
inv.setItem(i, mkItem(mat,
|
||||||
|
"§e§l" + ruleName + " " + statusText,
|
||||||
|
thresholdText,
|
||||||
|
detailText,
|
||||||
|
"",
|
||||||
|
"§7点击切换启用状态"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slot 21: 返回
|
||||||
|
inv.setItem(21, mkItem(Material.ARROW, "§7返回"));
|
||||||
|
|
||||||
|
// Slot 22: 上一页
|
||||||
|
if (page > 1) {
|
||||||
|
inv.setItem(22, mkItem(Material.PLAYER_HEAD,
|
||||||
|
"§e§l上一页",
|
||||||
|
"§7当前第 " + page + "/" + totalPages + " 页"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slot 23: 下一页
|
||||||
|
if (page < totalPages) {
|
||||||
|
inv.setItem(23, mkItem(Material.PLAYER_HEAD,
|
||||||
|
"§e§l下一页",
|
||||||
|
"§7当前第 " + page + "/" + totalPages + " 页"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slot 24: 页码信息
|
||||||
|
inv.setItem(24, mkItem(Material.PAPER,
|
||||||
|
"§7第 " + page + "/" + totalPages + " 页",
|
||||||
|
"§7共 " + totalCount + " 条规则",
|
||||||
|
"§7点击规则可切换启用/禁用"));
|
||||||
|
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 命令入口 ====================
|
// ==================== 命令入口 ====================
|
||||||
|
|
||||||
public boolean handleCommand(CommandSender sender, String[] args) {
|
public boolean handleCommand(CommandSender sender, String[] args) {
|
||||||
@@ -1187,11 +1468,14 @@ public class CreditManager {
|
|||||||
p.closeInventory(); // 静默关闭,不报错
|
p.closeInventory(); // 静默关闭,不报错
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 9: // 管理员: 规则说明(18格GUI才有slot9)
|
case 9: // 管理员: 规则配置(18格GUI才有slot9)
|
||||||
p.closeInventory();
|
if (plugin.isAdmin(p)) {
|
||||||
p.sendMessage("§d§l[信誉积分] §f规则说明:");
|
rulesPage.put(p.getName(), 1);
|
||||||
for (Map<String, Object> r : getEnabledRules()) {
|
p.closeInventory();
|
||||||
p.sendMessage("§7" + r.get("rule_name") + ": " + r.get("description"));
|
p.openInventory(createRulesGUI(p, 1));
|
||||||
|
} else {
|
||||||
|
// 非管理员不应进入slot9,静默关闭
|
||||||
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1205,6 +1489,64 @@ public class CreditManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ★ 第63批:规则配置GUI
|
||||||
|
if (title != null && title.contains("规则配置")) {
|
||||||
|
int currentPage = rulesPage.getOrDefault(p.getName(), 1);
|
||||||
|
|
||||||
|
// 返回按钮
|
||||||
|
if (slot == 21) {
|
||||||
|
rulesPage.remove(p.getName());
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(createMainGUI(p));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 翻页
|
||||||
|
if (slot == 22) {
|
||||||
|
currentPage = Math.max(1, currentPage - 1);
|
||||||
|
rulesPage.put(p.getName(), currentPage);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(createRulesGUI(p, currentPage));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (slot == 23) {
|
||||||
|
currentPage++;
|
||||||
|
rulesPage.put(p.getName(), currentPage);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(createRulesGUI(p, currentPage));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击规则槽位(0-4):切换启用/禁用
|
||||||
|
if (slot >= 0 && slot < RULES_PER_PAGE) {
|
||||||
|
int offset = (currentPage - 1) * RULES_PER_PAGE;
|
||||||
|
List<Map<String, Object>> rules = getAllRules();
|
||||||
|
if (slot < rules.size()) {
|
||||||
|
// 实际上需要按offset索引
|
||||||
|
int idx = offset + slot;
|
||||||
|
if (idx < rules.size()) {
|
||||||
|
Map<String, Object> r = rules.get(idx);
|
||||||
|
int ruleId = ((Number) r.get("id")).intValue();
|
||||||
|
String ruleName = (String) r.get("rule_name");
|
||||||
|
int enabled = ((Number) r.get("enabled")).intValue();
|
||||||
|
boolean ok = toggleRule(ruleId);
|
||||||
|
if (ok) {
|
||||||
|
p.sendMessage("§a§l[信誉积分] §f规则 §e" + ruleName + " §f已"
|
||||||
|
+ (enabled == 1 ? "§c禁用" : "§a启用"));
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§c§l[信誉积分] §c切换规则失败");
|
||||||
|
}
|
||||||
|
// 重新打开规则GUI刷新显示
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(createRulesGUI(p, currentPage));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.closeInventory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ★ 第59批-问题5:我的上报27格二级菜单
|
// ★ 第59批-问题5:我的上报27格二级菜单
|
||||||
if (title != null && title.contains("我的上报")) {
|
if (title != null && title.contains("我的上报")) {
|
||||||
int currentPage = myReportsPage.getOrDefault(p.getName(), 1);
|
int currentPage = myReportsPage.getOrDefault(p.getName(), 1);
|
||||||
|
|||||||
@@ -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("");
|
||||||
|
|||||||
@@ -1117,7 +1117,13 @@ public class TeleportManager implements Listener {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
String sender = player.getName();
|
String sender = player.getName();
|
||||||
long now = nowUptime();
|
long now = nowUptime();
|
||||||
|
|
||||||
|
// ★ 第63批:信誉积分低于20分禁止使用群戏传送
|
||||||
|
if (plugin.getCreditManager() != null && plugin.getCreditManager().isRestricted(sender, "block_tpaall")) {
|
||||||
|
player.sendMessage("§c§l[信誉积分] §c你的积分过低,禁止使用群戏传送");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查冷却
|
// 检查冷却
|
||||||
Long lastTime = teleportCooldown.get(sender);
|
Long lastTime = teleportCooldown.get(sender);
|
||||||
if (lastTime != null && now - lastTime < teleportCooldownMs) {
|
if (lastTime != null && now - lastTime < teleportCooldownMs) {
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
# 此文件填写的模型将被正是运用请求
|
# 此文件填写的模型将被正是运用请求
|
||||||
# 以#开头的表示注释,会被忽略
|
# 以#开头的表示注释,会被忽略
|
||||||
# models=name,这个=就是模型的简称,比如你可以配置deepseek=大肥鱼,后续用户@大肥鱼 xx,就会自动向deepseek的模型发起请求
|
# models=name,这个=就是模型的简称,比如你可以配置deepseek=大肥鱼,后续用户@大肥鱼 xx,就会自动向deepseek的模型发起请求。可以是一个厂家,也可以是单独的模型
|
||||||
|
# 以下是示例配置
|
||||||
|
# 大肥鱼=deepseek-flash
|
||||||
|
# 这里大肥鱼=deepseek-flash,意思是@大肥鱼时,向deepseek-flash模型发起请求,而deepseek-v4-pro不受影响,因为没命中这条规则
|
||||||
|
# 噶啦吗=GLM
|
||||||
|
# 这里噶啦吗=glm,意思是@噶啦吗时,向配置的GLM系列模型发起请求。所有glm系列厂家都会影响,不管是glm5.3、glm5.2等
|
||||||
|
# 不区分大小写
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user