修复:垃圾箱物品存入立即吞噬的问题和服务器没启用飞行功能被踢出的问题
This commit is contained in:
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
|
*.md text=auto encoding=UTF-8
|
||||||
*.png binary
|
*.png binary
|
||||||
*.jpg binary
|
*.jpg binary
|
||||||
*.jpeg binary
|
*.jpeg binary
|
||||||
*.gif binary
|
*.gif binary
|
||||||
*.ico binary
|
|
||||||
*.bmp binary
|
|
||||||
@@ -1,451 +1,462 @@
|
|||||||
package Sdf1_login;
|
package Sdf1_login;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static java.lang.Double.parseDouble;
|
import static java.lang.Double.parseDouble;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
private final Map<String, String> messages = new LinkedHashMap<>();
|
private final Map<String, String> messages = new LinkedHashMap<>();
|
||||||
private final Map<String, String> smtpSettings = new LinkedHashMap<>();
|
private final Map<String, String> smtpSettings = new LinkedHashMap<>();
|
||||||
|
|
||||||
public String adminTag = "admin";
|
public String adminTag = "admin";
|
||||||
public String adminPassword = "qweasd";
|
public String adminPassword = "qweasd";
|
||||||
public int maxAccountsPerIP = 3;
|
public int maxAccountsPerIP = 3;
|
||||||
public String approvalMode = "manual";
|
public String approvalMode = "manual";
|
||||||
public int autoApproveDelayMinutes = 30;
|
public int autoApproveDelayMinutes = 30;
|
||||||
public int loginTimeout = 60;
|
public int loginTimeout = 60;
|
||||||
public boolean afkEnabled = false;
|
public boolean afkEnabled = false;
|
||||||
public int afkTimeout = 300;
|
public int afkTimeout = 300;
|
||||||
public boolean smtpSsl = true;
|
public boolean smtpSsl = true;
|
||||||
public String smtpVerifyCode = "";
|
public String smtpVerifyCode = "";
|
||||||
public long smtpVerifyExpire = 0;
|
public long smtpVerifyExpire = 0;
|
||||||
public long smtpLastSendTime = 0;
|
public long smtpLastSendTime = 0;
|
||||||
public String smtpConfiguringPlayer = "";
|
public String smtpConfiguringPlayer = "";
|
||||||
|
|
||||||
|
|
||||||
public ConfigManager(File dataFolder) {
|
public ConfigManager(File dataFolder) {
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 消息 ====================
|
// ==================== 消息 ====================
|
||||||
|
|
||||||
public void loadMessages() {
|
public void loadMessages() {
|
||||||
messages.clear();
|
messages.clear();
|
||||||
File file = new File(dataFolder, "消息.txt");
|
File file = new File(dataFolder, "消息.txt");
|
||||||
if (!file.exists()) createDefaultMessages(file);
|
if (!file.exists()) createDefaultMessages(file);
|
||||||
loadMap(file, messages);
|
loadMap(file, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String msg(String key) {
|
public String msg(String key) {
|
||||||
String val = messages.getOrDefault(key, key);
|
String val = messages.getOrDefault(key, key);
|
||||||
val = val.replace("<b>", "&l");
|
val = val.replace("<b>", "&l");
|
||||||
val = val.replace("</b>", "&r");
|
val = val.replace("</b>", "&r");
|
||||||
val = val.replace("<br>", "\n");
|
val = val.replace("<br>", "\n");
|
||||||
val = val.replace("\\n", "\n");
|
val = val.replace("\\n", "\n");
|
||||||
// &颜色码 转换为 §颜色码
|
// &颜色码 转换为 §颜色码
|
||||||
val = val.replaceAll(
|
val = val.replaceAll(
|
||||||
"&([0-9a-fk-orA-FK-OR])", "§$1");
|
"&([0-9a-fk-orA-FK-OR])", "§$1");
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createDefaultMessages(File f) {
|
private void createDefaultMessages(File f) {
|
||||||
List<String> L = new ArrayList<>();
|
List<String> L = new ArrayList<>();
|
||||||
L.add("# ==========================================");
|
L.add("# ==========================================");
|
||||||
L.add("# Sdf1_login 消息配置文件");
|
L.add("# Sdf1_login 消息配置文件");
|
||||||
L.add("# ==========================================");
|
L.add("# ==========================================");
|
||||||
L.add("# 颜色代码使用 § 符号");
|
L.add("# 颜色代码使用 § 符号");
|
||||||
L.add("# §0黑色 §1深蓝 §2深绿 §3深青");
|
L.add("# §0黑色 §1深蓝 §2深绿 §3深青");
|
||||||
L.add("# §4深红 §5深紫 §6金色 §7灰色");
|
L.add("# §4深红 §5深紫 §6金色 §7灰色");
|
||||||
L.add("# §8深灰 §9蓝色 §a绿色 §b浅蓝");
|
L.add("# §8深灰 §9蓝色 §a绿色 §b浅蓝");
|
||||||
L.add("# §c红色 §d粉色 §e黄色 §f白色");
|
L.add("# §c红色 §d粉色 §e黄色 §f白色");
|
||||||
L.add("# §l粗体 §n下划线 §o斜体 §r重置");
|
L.add("# §l粗体 §n下划线 §o斜体 §r重置");
|
||||||
L.add("#");
|
L.add("#");
|
||||||
L.add("# 占位符用 {xxx} 表示,运行时自动替换");
|
L.add("# 占位符用 {xxx} 表示,运行时自动替换");
|
||||||
L.add("# 支持 <b>粗体</b> 标签");
|
L.add("# 支持 <b>粗体</b> 标签");
|
||||||
L.add("# 支持 \\n 或 <br> 换行");
|
L.add("# 支持 \\n 或 <br> 换行");
|
||||||
L.add("# 修改后执行 /sdf1_login reload 重载");
|
L.add("# 修改后执行 /sdf1_login reload 重载");
|
||||||
L.add("# ==========================================");
|
L.add("# ==========================================");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 登录/注册 ---
|
// --- 登录/注册 ---
|
||||||
L.add("# ---- 登录注册相关 ----");
|
L.add("# ---- 登录注册相关 ----");
|
||||||
L.add("# login_timeout: 登录超时被踢出时的提示");
|
L.add("# login_timeout: 登录超时被踢出时的提示");
|
||||||
L.add("login_timeout=§c登录超时,请重新登录");
|
L.add("login_timeout=§c登录超时,请重新登录");
|
||||||
L.add("# not_registered: 未注册玩家收到的提示");
|
L.add("# not_registered: 未注册玩家收到的提示");
|
||||||
L.add("not_registered=§e您尚未注册,请使用 /reg <密码>");
|
L.add("not_registered=§e您尚未注册,请使用 /reg <密码>");
|
||||||
L.add("# not_logged_in: 已注册但未登录的提示");
|
L.add("# not_logged_in: 已注册但未登录的提示");
|
||||||
L.add("not_logged_in=§e您尚未登录,请使用 /login <密码>");
|
L.add("not_logged_in=§e您尚未登录,请使用 /login <密码>");
|
||||||
L.add("# already_registered: 已注册玩家再次注册时的提示");
|
L.add("# already_registered: 已注册玩家再次注册时的提示");
|
||||||
L.add("already_registered=§c您已注册过账号");
|
L.add("already_registered=§c您已注册过账号");
|
||||||
L.add("# already_logged_in: 已登录玩家再次登录时的提示");
|
L.add("# already_logged_in: 已登录玩家再次登录时的提示");
|
||||||
L.add("already_logged_in=§c您已登录");
|
L.add("already_logged_in=§c您已登录");
|
||||||
L.add("# reg_success: 注册成功提示");
|
L.add("# reg_success: 注册成功提示");
|
||||||
L.add("reg_success=§a注册成功!欢迎来到服务器");
|
L.add("reg_success=§a注册成功!欢迎来到服务器");
|
||||||
L.add("# login_success: 登录成功提示");
|
L.add("# login_success: 登录成功提示");
|
||||||
L.add("login_success=§a登录成功!");
|
L.add("login_success=§a登录成功!");
|
||||||
L.add("# login_failed: 密码错误提示");
|
L.add("# login_failed: 密码错误提示");
|
||||||
L.add("login_failed=§c密码错误,请重试");
|
L.add("login_failed=§c密码错误,请重试");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 密码 ---
|
// --- 密码 ---
|
||||||
L.add("# ---- 密码相关 ----");
|
L.add("# ---- 密码相关 ----");
|
||||||
L.add("# password_wrong: 旧密码验证失败");
|
L.add("# password_wrong: 旧密码验证失败");
|
||||||
L.add("password_wrong=§c密码错误");
|
L.add("password_wrong=§c密码错误");
|
||||||
L.add("# password_changed: 密码修改成功");
|
L.add("# password_changed: 密码修改成功");
|
||||||
L.add("password_changed=§a密码修改成功!");
|
L.add("password_changed=§a密码修改成功!");
|
||||||
L.add("# password_format_error: 密码格式不符合要求");
|
L.add("# password_format_error: 密码格式不符合要求");
|
||||||
L.add("password_format_error=§c密码需6位以上,含大小写字母和数字");
|
L.add("password_format_error=§c密码需6位以上,含大小写字母和数字");
|
||||||
L.add("# password_same: 新密码与旧密码相同");
|
L.add("# password_same: 新密码与旧密码相同");
|
||||||
L.add("password_same=§c新密码不能与旧密码相同");
|
L.add("password_same=§c新密码不能与旧密码相同");
|
||||||
L.add("# reset_no_email: 找回密码时未绑定邮箱");
|
L.add("# reset_no_email: 找回密码时未绑定邮箱");
|
||||||
L.add("reset_no_email=§c您未绑定邮箱,无法找回密码");
|
L.add("reset_no_email=§c您未绑定邮箱,无法找回密码");
|
||||||
L.add("# reset_sent: 临时密码已发送到邮箱");
|
L.add("# reset_sent: 临时密码已发送到邮箱");
|
||||||
L.add("reset_sent=§a临时密码已发送到您的邮箱,请查收");
|
L.add("reset_sent=§a临时密码已发送到您的邮箱,请查收");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 签到积分 ---
|
// --- 签到积分 ---
|
||||||
L.add("# ---- 签到积分相关 ----");
|
L.add("# ---- 签到积分相关 ----");
|
||||||
L.add("# checkin_already: 今日已签到");
|
L.add("# checkin_already: 今日已签到");
|
||||||
L.add("checkin_already=§c您今日已签到");
|
L.add("checkin_already=§c您今日已签到");
|
||||||
L.add("# checkin_success: 签到成功,{points}=获得积分 {streak}=连续天数 {multi}=倍率");
|
L.add("# checkin_success: 签到成功,{points}=获得积分 {streak}=连续天数 {multi}=倍率");
|
||||||
L.add("checkin_success=§a签到成功!获得 {points} 积分,连续 {streak} 天,倍率 x{multi}");
|
L.add("checkin_success=§a签到成功!获得 {points} 积分,连续 {streak} 天,倍率 x{multi}");
|
||||||
L.add("# points_insufficient: 积分不足");
|
L.add("# points_insufficient: 积分不足");
|
||||||
L.add("points_insufficient=§c积分不足,当前: {points}");
|
L.add("points_insufficient=§c积分不足,当前: {points}");
|
||||||
L.add("# points_purchase_success: 积分购买成功");
|
L.add("# points_purchase_success: 积分购买成功");
|
||||||
L.add("points_purchase_success=§a购买成功!消耗 {count} 积分");
|
L.add("points_purchase_success=§a购买成功!消耗 {count} 积分");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 挂机 ---
|
// --- 挂机 ---
|
||||||
L.add("# ---- 挂机检测相关 ----");
|
L.add("# ---- 挂机检测相关 ----");
|
||||||
L.add("# afk_set_enabled: 挂机检测开启");
|
L.add("# afk_set_enabled: 挂机检测开启");
|
||||||
L.add("afk_set_enabled=§a挂机检测已开启");
|
L.add("afk_set_enabled=§a挂机检测已开启");
|
||||||
L.add("# afk_set_disabled: 挂机检测关闭");
|
L.add("# afk_set_disabled: 挂机检测关闭");
|
||||||
L.add("afk_set_disabled=§c挂机检测已关闭");
|
L.add("afk_set_disabled=§c挂机检测已关闭");
|
||||||
L.add("# afk_kick: 因挂机被踢出");
|
L.add("# afk_kick: 因挂机被踢出");
|
||||||
L.add("afk_kick=§c因挂机过久被踢出");
|
L.add("afk_kick=§c因挂机过久被踢出");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 邮箱 ---
|
// --- 邮箱 ---
|
||||||
L.add("# ---- 邮箱相关 ----");
|
L.add("# ---- 邮箱相关 ----");
|
||||||
L.add("# email_set: 邮箱设置成功");
|
L.add("# email_set: 邮箱设置成功");
|
||||||
L.add("email_set=§a邮箱设置成功:{email}");
|
L.add("email_set=§a邮箱设置成功:{email}");
|
||||||
L.add("# email_format_error: 邮箱格式错误");
|
L.add("# email_format_error: 邮箱格式错误");
|
||||||
L.add("email_format_error=§c邮箱格式不正确");
|
L.add("email_format_error=§c邮箱格式不正确");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 邀请 ---
|
// --- 邀请 ---
|
||||||
L.add("# ---- 邀请相关 ----");
|
L.add("# ---- 邀请相关 ----");
|
||||||
L.add("# invite_code_generated: 邀请码生成");
|
L.add("# invite_code_generated: 邀请码生成");
|
||||||
L.add("invite_code_generated=§a邀请码:{code}");
|
L.add("invite_code_generated=§a邀请码:{code}");
|
||||||
L.add("# invite_used: 使用邀请码成功");
|
L.add("# invite_used: 使用邀请码成功");
|
||||||
L.add("invite_used=§a邀请成功,邀请人:{player}");
|
L.add("invite_used=§a邀请成功,邀请人:{player}");
|
||||||
L.add("# invite_self: 使用自己的邀请码");
|
L.add("# invite_self: 使用自己的邀请码");
|
||||||
L.add("invite_self=§c不能使用自己的邀请码");
|
L.add("invite_self=§c不能使用自己的邀请码");
|
||||||
L.add("# invite_not_found: 邀请码不存在");
|
L.add("# invite_not_found: 邀请码不存在");
|
||||||
L.add("invite_not_found=§c邀请码不存在");
|
L.add("invite_not_found=§c邀请码不存在");
|
||||||
L.add("# invite_referral_bonus: 被邀请人签到后邀请人获得奖励");
|
L.add("# invite_referral_bonus: 被邀请人签到后邀请人获得奖励");
|
||||||
L.add("invite_referral_bonus=§a邀请奖励!获得 {points} 积分");
|
L.add("invite_referral_bonus=§a邀请奖励!获得 {points} 积分");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 礼包 ---
|
// --- 礼包 ---
|
||||||
L.add("# ---- 新人礼包相关 ----");
|
L.add("# ---- 新人礼包相关 ----");
|
||||||
L.add("# gift_not_ready: 礼包条件未满足");
|
L.add("# gift_not_ready: 礼包条件未满足");
|
||||||
L.add("gift_not_ready=§c礼包条件未满足");
|
L.add("gift_not_ready=§c礼包条件未满足");
|
||||||
L.add("# gift_claimed: 礼包领取成功");
|
L.add("# gift_claimed: 礼包领取成功");
|
||||||
L.add("gift_claimed=§a礼包领取成功!");
|
L.add("gift_claimed=§a礼包领取成功!");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 审批/IP ---
|
// --- 审批/IP ---
|
||||||
L.add("# ---- 审批与IP限制 ----");
|
L.add("# ---- 审批与IP限制 ----");
|
||||||
L.add("# need_approval: 注册需审批");
|
L.add("# need_approval: 注册需审批");
|
||||||
L.add("need_approval=§e注册需审批 (工单#{id})");
|
L.add("need_approval=§e注册需审批 (工单#{id})");
|
||||||
L.add("# ip_max_accounts: IP注册已达上限");
|
L.add("# ip_max_accounts: IP注册已达上限");
|
||||||
L.add("ip_max_accounts=§cIP注册已达上限");
|
L.add("ip_max_accounts=§cIP注册已达上限");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 管理员 ---
|
// --- 管理员 ---
|
||||||
L.add("# ---- 管理员操作 ----");
|
L.add("# ---- 管理员操作 ----");
|
||||||
L.add("# admin_delete_confirm: 管理员删除账号确认提示");
|
L.add("# admin_delete_confirm: 管理员删除账号确认提示");
|
||||||
L.add("admin_delete_confirm=§c请在聊天中输入玩家名确认删除");
|
L.add("admin_delete_confirm=§c请在聊天中输入玩家名确认删除");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 聊天过滤 ---
|
// --- 聊天过滤 ---
|
||||||
L.add("# ---- 聊天过滤 ----");
|
L.add("# ---- 聊天过滤 ----");
|
||||||
L.add("# chat_muted: 禁言玩家尝试聊天");
|
L.add("# chat_muted: 禁言玩家尝试聊天");
|
||||||
L.add("chat_muted=§c§l[Sdf1_chat] §f你已被禁言,无法聊天");
|
L.add("chat_muted=§c§l[Sdf1_chat] §f你已被禁言,无法聊天");
|
||||||
L.add("# chat_url_blocked: 发送违规链接被拦截");
|
L.add("# chat_url_blocked: 发送违规链接被拦截");
|
||||||
L.add("# {url}=检测到的链接地址");
|
L.add("# {url}=检测到的链接地址");
|
||||||
L.add("chat_url_blocked=§c§l[Sdf1_chat] §f检测到违规第三方链接: §e{url}");
|
L.add("chat_url_blocked=§c§l[Sdf1_chat] §f检测到违规第三方链接: §e{url}");
|
||||||
L.add("# chat_url_violation: 当前违规次数");
|
L.add("# chat_url_violation: 当前违规次数");
|
||||||
L.add("# {count}=当前违规次数");
|
L.add("# {count}=当前违规次数");
|
||||||
L.add("chat_url_violation=§7当前违规次数: §e{count}");
|
L.add("chat_url_violation=§7当前违规次数: §e{count}");
|
||||||
L.add("# chat_url_admin_notify: 通知管理员,{player}=玩家名 {url}=链接 {count}=次数");
|
L.add("# chat_url_admin_notify: 通知管理员,{player}=玩家名 {url}=链接 {count}=次数");
|
||||||
L.add("chat_url_admin_notify=§e§l[Sdf1_chat] §f{player} 发送违规链接: {url} (第{count}次)");
|
L.add("chat_url_admin_notify=§e§l[Sdf1_chat] §f{player} 发送违规链接: {url} (第{count}次)");
|
||||||
L.add("# chat_url_broadcast: 全服通报,{player}=玩家名");
|
L.add("# chat_url_broadcast: 全服通报,{player}=玩家名");
|
||||||
L.add("chat_url_broadcast=§c§l[Sdf1_chat] §e{player} §f因发送违规链接被处罚");
|
L.add("chat_url_broadcast=§c§l[Sdf1_chat] §e{player} §f因发送违规链接被处罚");
|
||||||
L.add("");
|
L.add("");
|
||||||
|
|
||||||
// --- 通用 ---
|
// --- 通用 ---
|
||||||
L.add("# ---- 通用 ----");
|
L.add("# ---- 通用 ----");
|
||||||
L.add("# 未知参数: 未知命令或权限不足时的提示");
|
L.add("# 未知参数: 未知命令或权限不足时的提示");
|
||||||
L.add("未知参数=§c未知参数或权限不足");
|
L.add("未知参数=§c未知参数或权限不足");
|
||||||
L.add("# only_player: 仅玩家可用的命令");
|
L.add("# only_player: 仅玩家可用的命令");
|
||||||
L.add("# only_player=§c此命令仅玩家可用");
|
L.add("# only_player=§c此命令仅玩家可用");
|
||||||
|
|
||||||
writeLines(f, L);
|
writeLines(f, L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== SMTP ====================
|
// ==================== SMTP ====================
|
||||||
|
|
||||||
public void loadSmtp() {
|
public void loadSmtp() {
|
||||||
smtpSettings.clear();
|
smtpSettings.clear();
|
||||||
File file = new File(dataFolder, "SMTP设置.txt");
|
File file = new File(dataFolder, "SMTP设置.txt");
|
||||||
if (!file.exists()) createDefaultSmtp(file);
|
if (!file.exists()) createDefaultSmtp(file);
|
||||||
loadMap(file, smtpSettings);
|
loadMap(file, smtpSettings);
|
||||||
}
|
}
|
||||||
private double parseDouble(String s, double def) {
|
private double parseDouble(String s, double def) {
|
||||||
try { return Double.parseDouble(s.trim()); }
|
try { return Double.parseDouble(s.trim()); }
|
||||||
catch (Exception e) { return def; }
|
catch (Exception e) { return def; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSmtp(String key) {
|
public String getSmtp(String key) {
|
||||||
return smtpSettings.getOrDefault(key, "");
|
return smtpSettings.getOrDefault(key, "");
|
||||||
}
|
}
|
||||||
/** 获取挂机白名单列表 */
|
/** 获取挂机白名单列表 */
|
||||||
public List<String> getAfkWhitelist() {
|
public List<String> getAfkWhitelist() {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
File file = new File(dataFolder, "挂机白名单.txt");
|
File file = new File(dataFolder, "挂机白名单.txt");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
try (BufferedWriter w = new BufferedWriter(
|
try (BufferedWriter w = new BufferedWriter(
|
||||||
new OutputStreamWriter(
|
new OutputStreamWriter(
|
||||||
new FileOutputStream(file),
|
new FileOutputStream(file),
|
||||||
StandardCharsets.UTF_8))) {
|
StandardCharsets.UTF_8))) {
|
||||||
w.write("# 每行一个玩家名,前面加 # 为注释");
|
w.write("# 每行一个玩家名,前面加 # 为注释");
|
||||||
w.newLine();
|
w.newLine();
|
||||||
w.write("# 以下玩家不会被挂机踢出");
|
w.write("# 以下玩家不会被挂机踢出");
|
||||||
w.newLine();
|
w.newLine();
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
try (BufferedReader r = new BufferedReader(
|
try (BufferedReader r = new BufferedReader(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
new FileInputStream(file),
|
new FileInputStream(file),
|
||||||
StandardCharsets.UTF_8))) {
|
StandardCharsets.UTF_8))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = r.readLine()) != null) {
|
while ((line = r.readLine()) != null) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (!line.isEmpty() && !line.startsWith("#")) {
|
if (!line.isEmpty() && !line.startsWith("#")) {
|
||||||
list.add(line);
|
list.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置SMTP单项(聊天输入用) */
|
/** 设置SMTP单项(聊天输入用) */
|
||||||
public void setSmtp(String key, String value) {
|
public void setSmtp(String key, String value) {
|
||||||
smtpSettings.put(key, value);
|
smtpSettings.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 将当前SMTP设置写回文件 */
|
/** 将当前SMTP设置写回文件 */
|
||||||
public void saveSmtp() {
|
public void saveSmtp() {
|
||||||
File file = new File(dataFolder, "SMTP设置.txt");
|
File file = new File(dataFolder, "SMTP设置.txt");
|
||||||
List<String> L = new ArrayList<>();
|
List<String> L = new ArrayList<>();
|
||||||
L.add("# ===== SMTP 邮件服务器配置 =====");
|
L.add("# ===== SMTP 邮件服务器配置 =====");
|
||||||
for (Map.Entry<String, String> e : smtpSettings.entrySet()) {
|
for (Map.Entry<String, String> e : smtpSettings.entrySet()) {
|
||||||
L.add(e.getKey() + "=" + e.getValue());
|
L.add(e.getKey() + "=" + e.getValue());
|
||||||
}
|
}
|
||||||
writeLines(file, L);
|
writeLines(file, L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDefaultSmtp(File f) {
|
private void createDefaultSmtp(File f) {
|
||||||
List<String> L = new ArrayList<>();
|
List<String> L = new ArrayList<>();
|
||||||
L.add("# ===== SMTP 邮件服务器配置 =====");
|
L.add("# ===== SMTP 邮件服务器配置 =====");
|
||||||
L.add("smtp地址=smtp.example.com");
|
L.add("smtp地址=smtp.example.com");
|
||||||
L.add("smtp端口=465");
|
L.add("smtp端口=465");
|
||||||
L.add("smtp账号=your_email@example.com");
|
L.add("smtp账号=your_email@example.com");
|
||||||
L.add("smtp密码=");
|
L.add("smtp密码=");
|
||||||
L.add("发件人名称=Sdf1_login");
|
L.add("发件人名称=Sdf1_login");
|
||||||
L.add("smtp加密=true");
|
L.add("smtp加密=true");
|
||||||
writeLines(f, L);
|
writeLines(f, L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 插件设置 ====================
|
// ==================== 插件设置 ====================
|
||||||
|
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
File file = new File(dataFolder, "插件设置.txt");
|
File file = new File(dataFolder, "插件设置.txt");
|
||||||
if (!file.exists()) createDefaultSettings(file);
|
if (!file.exists()) createDefaultSettings(file);
|
||||||
Map<String, String> m = new LinkedHashMap<>();
|
Map<String, String> m = new LinkedHashMap<>();
|
||||||
loadMap(file, m);
|
loadMap(file, m);
|
||||||
adminTag = m.getOrDefault("管理标签", adminTag);
|
adminTag = m.getOrDefault("管理标签", adminTag);
|
||||||
adminPassword = m.getOrDefault("管理密码", adminPassword);
|
adminPassword = m.getOrDefault("管理密码", adminPassword);
|
||||||
maxAccountsPerIP = parseInt(
|
maxAccountsPerIP = parseInt(
|
||||||
m.getOrDefault("每IP最大账号数", "3"), 3);
|
m.getOrDefault("每IP最大账号数", "3"), 3);
|
||||||
approvalMode = m.getOrDefault("审批模式", approvalMode);
|
approvalMode = m.getOrDefault("审批模式", approvalMode);
|
||||||
autoApproveDelayMinutes = parseInt(
|
autoApproveDelayMinutes = parseInt(
|
||||||
m.getOrDefault("自动审批延迟分钟", "30"), 30);
|
m.getOrDefault("自动审批延迟分钟", "30"), 30);
|
||||||
loginTimeout = parseInt(
|
loginTimeout = parseInt(
|
||||||
m.getOrDefault("登录超时秒数", "60"), 60);
|
m.getOrDefault("登录超时秒数", "60"), 60);
|
||||||
afkEnabled = Boolean.parseBoolean(
|
afkEnabled = Boolean.parseBoolean(
|
||||||
m.getOrDefault("挂机踢出", "false"));
|
m.getOrDefault("挂机踢出", "false"));
|
||||||
afkTimeout = parseInt(
|
afkTimeout = parseInt(
|
||||||
m.getOrDefault("挂机超时秒数", "300"), 300);
|
m.getOrDefault("挂机超时秒数", "300"), 300);
|
||||||
smtpSsl = Boolean.parseBoolean(
|
smtpSsl = Boolean.parseBoolean(
|
||||||
m.getOrDefault("smtp加密", "true"));
|
m.getOrDefault("smtp加密", "true"));
|
||||||
providerPointsPerScore = parseDouble(
|
providerPointsPerScore = parseDouble(
|
||||||
m.getOrDefault("服务商积分倍率", "2.0"),
|
m.getOrDefault("服务商积分倍率", "2.0"),
|
||||||
2.0);
|
2.0);
|
||||||
baseEconomyReward = parseInt(
|
baseEconomyReward = parseInt(
|
||||||
m.getOrDefault("基础经济奖励", "100"),
|
m.getOrDefault("基础经济奖励", "100"),
|
||||||
100);
|
100);
|
||||||
providerEconomyPerScore = parseDouble(
|
providerEconomyPerScore = parseDouble(
|
||||||
m.getOrDefault("经济奖励每评分", "50.0"),
|
m.getOrDefault("经济奖励每评分", "50.0"),
|
||||||
50.0);
|
50.0);
|
||||||
requesterPointsReward = parseInt(
|
requesterPointsReward = parseInt(
|
||||||
m.getOrDefault("报单人积分奖励", "10"),
|
m.getOrDefault("报单人积分奖励", "10"),
|
||||||
10);
|
10);
|
||||||
|
garbageEnabled = Boolean.parseBoolean(
|
||||||
|
m.getOrDefault("垃圾站_启用", "true"));
|
||||||
}
|
garbageInterval = parseInt(
|
||||||
|
m.getOrDefault("垃圾站_清理间隔秒",
|
||||||
|
"300"), 300);
|
||||||
public void saveSettings() {
|
garbageMaxRounds = parseInt(
|
||||||
File file = new File(dataFolder, "插件设置.txt");
|
m.getOrDefault("垃圾站_保留轮数",
|
||||||
List<String> L = new ArrayList<>();
|
"1"), 1);
|
||||||
L.add("# ===== Sdf1_login 插件设置 =====");
|
|
||||||
L.add("管理标签=" + adminTag);
|
|
||||||
L.add("管理密码=" + adminPassword);
|
}
|
||||||
L.add("每IP最大账号数=" + maxAccountsPerIP);
|
|
||||||
L.add("审批模式=" + approvalMode);
|
|
||||||
L.add("自动审批延迟分钟=" + autoApproveDelayMinutes);
|
public void saveSettings() {
|
||||||
L.add("登录超时秒数=" + loginTimeout);
|
File file = new File(dataFolder, "插件设置.txt");
|
||||||
L.add("挂机踢出=" + afkEnabled);
|
List<String> L = new ArrayList<>();
|
||||||
L.add("挂机超时秒数=" + afkTimeout);
|
L.add("# ===== Sdf1_login 插件设置 =====");
|
||||||
// 垃圾站设置
|
L.add("管理标签=" + adminTag);
|
||||||
L.add("# ---- 垃圾站 ----");
|
L.add("管理密码=" + adminPassword);
|
||||||
L.add("垃圾站_启用: "
|
L.add("每IP最大账号数=" + maxAccountsPerIP);
|
||||||
+ garbageEnabled);
|
L.add("审批模式=" + approvalMode);
|
||||||
L.add("垃圾站_清理间隔秒: "
|
L.add("自动审批延迟分钟=" + autoApproveDelayMinutes);
|
||||||
+ garbageInterval);
|
L.add("登录超时秒数=" + loginTimeout);
|
||||||
L.add("垃圾站_保留轮数: "
|
L.add("挂机踢出=" + afkEnabled);
|
||||||
+ garbageMaxRounds);
|
L.add("挂机超时秒数=" + afkTimeout);
|
||||||
|
// 垃圾站设置
|
||||||
writeLines(file, L);
|
L.add("# ---- 垃圾站 ----");
|
||||||
}
|
L.add("垃圾站_启用=" + garbageEnabled);
|
||||||
public double providerPointsPerScore = 2.0;
|
L.add("垃圾站_清理间隔秒=" + garbageInterval);
|
||||||
public int baseEconomyReward = 100;
|
L.add("垃圾站_保留轮数=" + garbageMaxRounds);
|
||||||
public double providerEconomyPerScore = 50.0;
|
|
||||||
public int requesterPointsReward = 10;
|
|
||||||
public boolean garbageEnabled = true;
|
writeLines(file, L);
|
||||||
public int garbageInterval = 300;
|
}
|
||||||
public int garbageMaxRounds = 1;
|
public double providerPointsPerScore = 2.0;
|
||||||
|
public int baseEconomyReward = 100;
|
||||||
|
public double providerEconomyPerScore = 50.0;
|
||||||
private void createDefaultSettings(File f) {
|
public int requesterPointsReward = 10;
|
||||||
List<String> L = new ArrayList<>();
|
public boolean garbageEnabled = true;
|
||||||
L.add("# ===== Sdf1_login 插件设置 =====");
|
public int garbageInterval = 300;
|
||||||
L.add("管理标签=admin");
|
public int garbageMaxRounds = 1;
|
||||||
L.add("管理密码=qweasd");
|
|
||||||
L.add("每IP最大账号数=3");
|
|
||||||
L.add("审批模式=manual");
|
private void createDefaultSettings(File f) {
|
||||||
L.add("自动审批延迟分钟=30");
|
List<String> L = new ArrayList<>();
|
||||||
L.add("登录超时秒数=60");
|
L.add("# ===== Sdf1_login 插件设置 =====");
|
||||||
L.add("挂机踢出=false");
|
L.add("管理标签=admin");
|
||||||
L.add("挂机超时秒数=300");
|
L.add("管理密码=qweasd");
|
||||||
L.add("服务商积分倍率=" + providerPointsPerScore);
|
L.add("每IP最大账号数=3");
|
||||||
L.add("基础经济奖励=" + baseEconomyReward);
|
L.add("审批模式=manual");
|
||||||
L.add("经济奖励每评分=" + providerEconomyPerScore);
|
L.add("自动审批延迟分钟=30");
|
||||||
L.add("报单人积分奖励=" + requesterPointsReward);
|
L.add("登录超时秒数=60");
|
||||||
|
L.add("挂机踢出=false");
|
||||||
writeLines(f, L);
|
L.add("挂机超时秒数=300");
|
||||||
}
|
L.add("服务商积分倍率=" + providerPointsPerScore);
|
||||||
|
L.add("基础经济奖励=" + baseEconomyReward);
|
||||||
// ==================== 通用读写 ====================
|
L.add("经济奖励每评分=" + providerEconomyPerScore);
|
||||||
|
L.add("报单人积分奖励=" + requesterPointsReward);
|
||||||
private void loadMap(File file, Map<String, String> map) {
|
L.add("# ---- 垃圾站 ----");
|
||||||
try (BufferedReader r = new BufferedReader(
|
L.add("垃圾站_启用=true");
|
||||||
new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
L.add("垃圾站_清理间隔秒=300");
|
||||||
String line;
|
L.add("垃圾站_保留轮数=1");
|
||||||
while ((line = r.readLine()) != null) {
|
|
||||||
line = line.trim();
|
|
||||||
if (line.isEmpty() || line.startsWith("#")) continue;
|
writeLines(f, L);
|
||||||
int eq = line.indexOf('=');
|
}
|
||||||
if (eq > 0) map.put(line.substring(0, eq).trim(), line.substring(eq + 1).trim());
|
|
||||||
}
|
// ==================== 通用读写 ====================
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println("[Sdf1_login] 读取失败: " + file.getName());
|
private void loadMap(File file, Map<String, String> map) {
|
||||||
}
|
try (BufferedReader r = new BufferedReader(
|
||||||
}
|
new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
||||||
|
String line;
|
||||||
private void writeLines(File file, List<String> lines) {
|
while ((line = r.readLine()) != null) {
|
||||||
try (BufferedWriter w = new BufferedWriter(
|
line = line.trim();
|
||||||
new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
|
if (line.isEmpty() || line.startsWith("#")) continue;
|
||||||
for (String l : lines) { w.write(l); w.newLine(); }
|
int eq = line.indexOf('=');
|
||||||
} catch (IOException e) {
|
if (eq > 0) map.put(line.substring(0, eq).trim(), line.substring(eq + 1).trim());
|
||||||
System.err.println("[Sdf1_login] 写入失败: " + file.getName());
|
}
|
||||||
}
|
} catch (IOException e) {
|
||||||
}
|
System.err.println("[Sdf1_login] 读取失败: " + file.getName());
|
||||||
|
}
|
||||||
private int parseInt(String s, int def) {
|
}
|
||||||
try { return Integer.parseInt(s.trim()); } catch (Exception e) { return def; }
|
|
||||||
}
|
private void writeLines(File file, List<String> lines) {
|
||||||
/**
|
try (BufferedWriter w = new BufferedWriter(
|
||||||
* 生成6位验证码(字母+数字)
|
new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
|
||||||
*/
|
for (String l : lines) { w.write(l); w.newLine(); }
|
||||||
public String generateSmtpVerifyCode() {
|
} catch (IOException e) {
|
||||||
String chars =
|
System.err.println("[Sdf1_login] 写入失败: " + file.getName());
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
}
|
||||||
+ "abcdefghijklmnopqrstuvwxyz"
|
}
|
||||||
+ "0123456789";
|
|
||||||
StringBuilder sb = new StringBuilder();
|
private int parseInt(String s, int def) {
|
||||||
java.util.Random r = new java.util.Random();
|
try { return Integer.parseInt(s.trim()); } catch (Exception e) { return def; }
|
||||||
for (int i = 0; i < 6; i++) {
|
}
|
||||||
sb.append(chars.charAt(r.nextInt(
|
/**
|
||||||
chars.length())));
|
* 生成6位验证码(字母+数字)
|
||||||
}
|
*/
|
||||||
smtpVerifyCode = sb.toString();
|
public String generateSmtpVerifyCode() {
|
||||||
smtpVerifyExpire =
|
String chars =
|
||||||
System.currentTimeMillis() + 300000L;
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
return smtpVerifyCode;
|
+ "abcdefghijklmnopqrstuvwxyz"
|
||||||
}
|
+ "0123456789";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
/**
|
java.util.Random r = new java.util.Random();
|
||||||
* 检查验证码是否有效
|
for (int i = 0; i < 6; i++) {
|
||||||
*/
|
sb.append(chars.charAt(r.nextInt(
|
||||||
public boolean checkSmtpVerifyCode(String code) {
|
chars.length())));
|
||||||
if (System.currentTimeMillis() > smtpVerifyExpire) {
|
}
|
||||||
smtpVerifyCode = "";
|
smtpVerifyCode = sb.toString();
|
||||||
return false;
|
smtpVerifyExpire =
|
||||||
}
|
System.currentTimeMillis() + 300000L;
|
||||||
return smtpVerifyCode.equalsIgnoreCase(code);
|
return smtpVerifyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除验证码
|
* 检查验证码是否有效
|
||||||
*/
|
*/
|
||||||
public void clearSmtpVerifyCode() {
|
public boolean checkSmtpVerifyCode(String code) {
|
||||||
smtpVerifyCode = "";
|
if (System.currentTimeMillis() > smtpVerifyExpire) {
|
||||||
smtpVerifyExpire = 0;
|
smtpVerifyCode = "";
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
/**
|
return smtpVerifyCode.equalsIgnoreCase(code);
|
||||||
* 检查发送间隔是否>=1分钟
|
}
|
||||||
*/
|
|
||||||
public boolean canSendSmtpVerify() {
|
/**
|
||||||
return System.currentTimeMillis()
|
* 清除验证码
|
||||||
- smtpLastSendTime >= 60000L;
|
*/
|
||||||
}
|
public void clearSmtpVerifyCode() {
|
||||||
|
smtpVerifyCode = "";
|
||||||
public void recordSmtpSendTime() {
|
smtpVerifyExpire = 0;
|
||||||
smtpLastSendTime = System.currentTimeMillis();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
}
|
* 检查发送间隔是否>=1分钟
|
||||||
|
*/
|
||||||
|
public boolean canSendSmtpVerify() {
|
||||||
|
return System.currentTimeMillis()
|
||||||
|
- smtpLastSendTime >= 60000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recordSmtpSendTime() {
|
||||||
|
smtpLastSendTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,296 +1,259 @@
|
|||||||
package Sdf1_login;
|
package Sdf1_login;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
|
||||||
public class GiftManager {
|
public class GiftManager {
|
||||||
|
|
||||||
private final File giftFolder;
|
private final File giftFolder;
|
||||||
private final Main plugin;
|
private final Main plugin;
|
||||||
private final List<Map<String, Object>> stages =
|
private final List<Map<String, Object>> stages =
|
||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
|
|
||||||
public GiftManager(Main plugin) {
|
public GiftManager(Main plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.giftFolder = new File(
|
this.giftFolder = new File(
|
||||||
plugin.getDataFolder(), "新人礼包");
|
plugin.getDataFolder(), "新人礼包");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadStages() {
|
public void loadStages() {
|
||||||
stages.clear();
|
stages.clear();
|
||||||
if (!giftFolder.exists()) {
|
if (!giftFolder.exists()) {
|
||||||
giftFolder.mkdirs();
|
giftFolder.mkdirs();
|
||||||
writeDefaultStages();
|
writeDefaultStages();
|
||||||
}
|
}
|
||||||
File[] files = giftFolder.listFiles(
|
File[] files = giftFolder.listFiles(
|
||||||
(dir, name) -> name.endsWith(".md"));
|
(dir, name) -> name.endsWith(".md"));
|
||||||
if (files == null) return;
|
if (files == null) return;
|
||||||
Arrays.sort(files);
|
Arrays.sort(files);
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
stages.add(parseMarkdown(f));
|
stages.add(parseMarkdown(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> parseMarkdown(File f) {
|
private Map<String, Object> parseMarkdown(File f) {
|
||||||
Map<String, Object> stage = new LinkedHashMap<>();
|
Map<String, Object> stage = new LinkedHashMap<>();
|
||||||
stage.put("stage", stages.size() + 1);
|
stage.put("stage", stages.size() + 1);
|
||||||
stage.put("name",
|
stage.put("name",
|
||||||
f.getName().replace(".md", ""));
|
f.getName().replace(".md", ""));
|
||||||
stage.put("rewards", new ArrayList<String>());
|
stage.put("rewards", new ArrayList<String>());
|
||||||
try {
|
try {
|
||||||
BufferedReader r = new BufferedReader(
|
BufferedReader r = new BufferedReader(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
new FileInputStream(f),
|
new FileInputStream(f),
|
||||||
StandardCharsets.UTF_8));
|
StandardCharsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
List<String> rewards = new ArrayList<>();
|
List<String> rewards = new ArrayList<>();
|
||||||
while ((line = r.readLine()) != null) {
|
while ((line = r.readLine()) != null) {
|
||||||
if (line.contains("礼包内容")
|
if (line.contains("礼包内容")
|
||||||
|| line.contains("奖励")
|
|| line.contains("奖励")
|
||||||
|| line.contains("任务内容")) {
|
|| line.contains("任务内容")) {
|
||||||
int colon = line.indexOf(':');
|
int colon = line.indexOf(':');
|
||||||
if (colon < 0)
|
if (colon < 0)
|
||||||
colon = line.indexOf('\uff1a');
|
colon = line.indexOf('\uff1a');
|
||||||
if (colon >= 0) {
|
if (colon >= 0) {
|
||||||
rewards.add(
|
rewards.add(
|
||||||
line.substring(colon + 1)
|
line.substring(colon + 1)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage.put("rewards", rewards);
|
stage.put("rewards", rewards);
|
||||||
r.close();
|
r.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
private void writeStage(String name, String content) {
|
private void writeStage(String name, String content) {
|
||||||
File f = new File(giftFolder, name);
|
File f = new File(giftFolder, name);
|
||||||
if (f.exists()) return;
|
if (f.exists()) return;
|
||||||
try (PrintWriter pw = new PrintWriter(
|
try (PrintWriter pw = new PrintWriter(
|
||||||
new OutputStreamWriter(
|
new OutputStreamWriter(
|
||||||
new FileOutputStream(f),
|
new FileOutputStream(f),
|
||||||
StandardCharsets.UTF_8))) {
|
StandardCharsets.UTF_8))) {
|
||||||
pw.print(content);
|
pw.print(content);
|
||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDefaultStages() {
|
private void writeDefaultStages() {
|
||||||
writeStage("第一阶段.md",
|
writeStage("第一阶段.md",
|
||||||
"# 第一阶段\n\n## 领取条件\n\n- 无前级条件\n\n## 礼包内容\n\n- 皮革套装 × 1\n- 木制武器工具套装 × 1\n");
|
"# 第一阶段\n\n## 领取条件\n\n- 无前级条件\n\n## 礼包内容\n\n- 皮革套装 × 1\n- 木制武器工具套装 × 1\n");
|
||||||
writeStage("第二阶段.md",
|
writeStage("第二阶段.md",
|
||||||
"# 第二阶段\n\n## 领取条件\n\n- 在线时长>1小时\n\n## 礼包内容\n\n- 500 游戏币\n");
|
"# 第二阶段\n\n## 领取条件\n\n- 在线时长>1小时\n\n## 礼包内容\n\n- 500 游戏币\n");
|
||||||
writeStage("第三阶段.md",
|
writeStage("第三阶段.md",
|
||||||
"# 第三阶段\n\n## 领取条件\n\n- 破坏100个方块\n- 在线>1天\n\n## 礼包内容\n\n- 1500 游戏币\n- 铁质工具套装 × 1\n- 铁质防具 × 1\n");
|
"# 第三阶段\n\n## 领取条件\n\n- 破坏100个方块\n- 在线>1天\n\n## 礼包内容\n\n- 1500 游戏币\n- 铁质工具套装 × 1\n- 铁质防具 × 1\n");
|
||||||
writeStage("第四阶段.md",
|
writeStage("第四阶段.md",
|
||||||
"# 第四阶段\n\n## 领取条件\n\n- 破坏/放置300方块\n- 在线≥7天\n\n## 礼包内容\n\n- 钻石套装 × 1\n- 2000 游戏币\n");
|
"# 第四阶段\n\n## 领取条件\n\n- 破坏/放置300方块\n- 在线≥7天\n\n## 礼包内容\n\n- 钻石套装 × 1\n- 2000 游戏币\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 从任意文件夹加载任务列表 */
|
/** 从任意文件夹加载任务列表 */
|
||||||
public List<Map<String, Object>> loadTasksFromFolder(
|
public List<Map<String, Object>> loadTasksFromFolder(
|
||||||
File folder) {
|
File folder) {
|
||||||
List<Map<String, Object>> tasks =
|
List<Map<String, Object>> tasks =
|
||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
if (!folder.exists() || !folder.isDirectory())
|
if (!folder.exists() || !folder.isDirectory())
|
||||||
return tasks;
|
return tasks;
|
||||||
File[] files = folder.listFiles(
|
File[] files = folder.listFiles(
|
||||||
(dir, name) -> name.endsWith(".md"));
|
(dir, name) -> name.endsWith(".md"));
|
||||||
if (files == null) return tasks;
|
if (files == null) return tasks;
|
||||||
Arrays.sort(files);
|
Arrays.sort(files);
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
Map<String, Object> task =
|
Map<String, Object> task =
|
||||||
new LinkedHashMap<>();
|
new LinkedHashMap<>();
|
||||||
task.put("name",
|
task.put("name",
|
||||||
f.getName().replace(".md", ""));
|
f.getName().replace(".md", ""));
|
||||||
task.put("conditions",
|
task.put("conditions",
|
||||||
new ArrayList<String>());
|
new ArrayList<String>());
|
||||||
task.put("rewards",
|
task.put("rewards",
|
||||||
new ArrayList<String>());
|
new ArrayList<String>());
|
||||||
try {
|
try {
|
||||||
BufferedReader r = new BufferedReader(
|
BufferedReader r = new BufferedReader(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
new FileInputStream(f),
|
new FileInputStream(f),
|
||||||
StandardCharsets.UTF_8));
|
StandardCharsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
List<String> current = null;
|
List<String> current = null;
|
||||||
while ((line = r.readLine()) != null) {
|
while ((line = r.readLine()) != null) {
|
||||||
if (line.startsWith("# ")) {
|
if (line.startsWith("# ")) {
|
||||||
task.put("name",
|
task.put("name",
|
||||||
line.substring(2)
|
line.substring(2)
|
||||||
.trim());
|
.trim());
|
||||||
} else if (line.contains("条件")
|
} else if (line.contains("条件")
|
||||||
|| line.contains("领取条件")
|
|| line.contains("领取条件")
|
||||||
|| line.contains("完成条件")) {
|
|| line.contains("完成条件")) {
|
||||||
current = (List<String>) task
|
current = (List<String>) task
|
||||||
.get("conditions");
|
.get("conditions");
|
||||||
} else if (line.contains("内容")
|
} else if (line.contains("内容")
|
||||||
|| line.contains("奖励")
|
|| line.contains("奖励")
|
||||||
|| line.contains("任务内容")
|
|| line.contains("任务内容")
|
||||||
|| line.contains("礼包内容")) {
|
|| line.contains("礼包内容")) {
|
||||||
current = (List<String>) task
|
current = (List<String>) task
|
||||||
.get("rewards");
|
.get("rewards");
|
||||||
} else if (line.startsWith("- ")
|
} else if (line.startsWith("- ")
|
||||||
&& current != null) {
|
&& current != null) {
|
||||||
current.add(line.substring(2)
|
current.add(line.substring(2)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.close();
|
r.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
tasks.add(task);
|
tasks.add(task);
|
||||||
}
|
}
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canClaim(Player p, int stage) {
|
public boolean canClaim(Player p, int stage) {
|
||||||
Map<String, Object> user = plugin.getDb()
|
String name = p.getName();
|
||||||
.getUser(p.getName());
|
int curStage = ((Number) plugin.getDb()
|
||||||
if (user.isEmpty()) return false;
|
.getField(name, "gift_stage"))
|
||||||
int curStage = ((Number) user.getOrDefault(
|
.intValue();
|
||||||
"gift_stage", 0)).intValue();
|
String claimed = (String) plugin.getDb()
|
||||||
if (stage > curStage + 1) return false;
|
.getField(name, "gift_claimed");
|
||||||
if (stage < 1 || stage > stages.size())
|
if (claimed == null) claimed = "";
|
||||||
return false;
|
return curStage >= stage
|
||||||
String claimed = (String) user.getOrDefault(
|
&& !claimed.contains(
|
||||||
"gift_claimed", "");
|
String.valueOf(stage));
|
||||||
if (claimed.contains("[" + stage + "]"))
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
// debug 绕过:检查 tasks_completed
|
public void claimReward(Player p, int stage) {
|
||||||
String completed = (String) user.getOrDefault(
|
if (!canClaim(p, stage)) return;
|
||||||
"tasks_completed", "");
|
Map<String, Object> user = plugin.getDb()
|
||||||
if (completed.contains("[" + stage + "]"))
|
.getUser(p.getName());
|
||||||
return true;
|
String claimed = (String) user.getOrDefault(
|
||||||
|
"gift_claimed", "");
|
||||||
// 正常条件检查
|
claimed += "[" + stage + "]";
|
||||||
long dbTime = ((Number) user.getOrDefault(
|
plugin.getDb().setField(
|
||||||
"total_online_time", 0L)).longValue();
|
p.getName(), "gift_claimed", claimed);
|
||||||
long sessionTime = 0;
|
plugin.getDb().setField(
|
||||||
Object lastObj = plugin.getDb().getField(
|
p.getName(), "gift_stage",
|
||||||
p.getName(), "last_online_check");
|
Math.max(stage,
|
||||||
if (lastObj != null && plugin.getLoggedIn()
|
((Number) user.getOrDefault(
|
||||||
.contains(p.getName())) {
|
"gift_stage", 0))
|
||||||
long last = ((Number) lastObj).longValue();
|
.intValue()));
|
||||||
if (last > 0) {
|
|
||||||
sessionTime =
|
if (stage == 1) {
|
||||||
System.currentTimeMillis() - last;
|
giveItem(p, Material.LEATHER_HELMET);
|
||||||
}
|
giveItem(p, Material.LEATHER_CHESTPLATE);
|
||||||
}
|
giveItem(p, Material.LEATHER_LEGGINGS);
|
||||||
long onlineTime = dbTime + sessionTime;
|
giveItem(p, Material.LEATHER_BOOTS);
|
||||||
int broken = ((Number) user.getOrDefault(
|
giveItem(p, Material.WOODEN_SWORD);
|
||||||
"blocks_broken", 0)).intValue();
|
giveItem(p, Material.WOODEN_PICKAXE);
|
||||||
int placed = ((Number) user.getOrDefault(
|
giveItem(p, Material.WOODEN_AXE);
|
||||||
"blocks_placed", 0)).intValue();
|
giveItem(p, Material.WOODEN_SHOVEL);
|
||||||
|
} else if (stage == 2) {
|
||||||
switch (stage) {
|
if (plugin.getEconomy() != null) {
|
||||||
case 1: return true;
|
double before = plugin.getEconomy()
|
||||||
case 2: return onlineTime >= 3600000;
|
.getBalance(p);
|
||||||
case 3: return broken >= 100
|
plugin.getEconomy()
|
||||||
&& onlineTime >= 86400000L;
|
.depositPlayer(p, 500);
|
||||||
case 4: return (broken + placed) >= 300
|
double after = plugin.getEconomy()
|
||||||
&& onlineTime >= 604800000L;
|
.getBalance(p);
|
||||||
default: return false;
|
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||||
}
|
+ (long) before
|
||||||
}
|
+ "§f → §a" + (long) after);
|
||||||
|
}
|
||||||
public void claimReward(Player p, int stage) {
|
} else if (stage == 3) {
|
||||||
if (!canClaim(p, stage)) return;
|
if (plugin.getEconomy() != null) {
|
||||||
Map<String, Object> user = plugin.getDb()
|
double before = plugin.getEconomy()
|
||||||
.getUser(p.getName());
|
.getBalance(p);
|
||||||
String claimed = (String) user.getOrDefault(
|
plugin.getEconomy()
|
||||||
"gift_claimed", "");
|
.depositPlayer(p, 1500);
|
||||||
claimed += "[" + stage + "]";
|
double after = plugin.getEconomy()
|
||||||
plugin.getDb().setField(
|
.getBalance(p);
|
||||||
p.getName(), "gift_claimed", claimed);
|
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||||
plugin.getDb().setField(
|
+ (long) before
|
||||||
p.getName(), "gift_stage",
|
+ "§f → §a" + (long) after);
|
||||||
Math.max(stage,
|
}
|
||||||
((Number) user.getOrDefault(
|
giveItem(p, Material.IRON_PICKAXE);
|
||||||
"gift_stage", 0))
|
giveItem(p, Material.IRON_AXE);
|
||||||
.intValue()));
|
giveItem(p, Material.IRON_SWORD);
|
||||||
|
giveItem(p, Material.IRON_HELMET);
|
||||||
if (stage == 1) {
|
giveItem(p, Material.IRON_CHESTPLATE);
|
||||||
giveItem(p, Material.LEATHER_HELMET);
|
giveItem(p, Material.IRON_LEGGINGS);
|
||||||
giveItem(p, Material.LEATHER_CHESTPLATE);
|
giveItem(p, Material.IRON_BOOTS);
|
||||||
giveItem(p, Material.LEATHER_LEGGINGS);
|
} else if (stage == 4) {
|
||||||
giveItem(p, Material.LEATHER_BOOTS);
|
if (plugin.getEconomy() != null) {
|
||||||
giveItem(p, Material.WOODEN_SWORD);
|
double before = plugin.getEconomy()
|
||||||
giveItem(p, Material.WOODEN_PICKAXE);
|
.getBalance(p);
|
||||||
giveItem(p, Material.WOODEN_AXE);
|
plugin.getEconomy()
|
||||||
giveItem(p, Material.WOODEN_SHOVEL);
|
.depositPlayer(p, 2000);
|
||||||
} else if (stage == 2) {
|
double after = plugin.getEconomy()
|
||||||
if (plugin.getEconomy() != null) {
|
.getBalance(p);
|
||||||
double before = plugin.getEconomy()
|
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
||||||
.getBalance(p);
|
+ (long) before
|
||||||
plugin.getEconomy()
|
+ "§f → §a" + (long) after);
|
||||||
.depositPlayer(p, 500);
|
}
|
||||||
double after = plugin.getEconomy()
|
giveItem(p, Material.DIAMOND_HELMET);
|
||||||
.getBalance(p);
|
giveItem(p, Material.DIAMOND_CHESTPLATE);
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
giveItem(p, Material.DIAMOND_LEGGINGS);
|
||||||
+ (long) before
|
giveItem(p, Material.DIAMOND_BOOTS);
|
||||||
+ "§f → §a" + (long) after);
|
}
|
||||||
}
|
p.sendMessage(plugin.getConfig2().msg(
|
||||||
} else if (stage == 3) {
|
"gift_claimed"));
|
||||||
if (plugin.getEconomy() != null) {
|
}
|
||||||
double before = plugin.getEconomy()
|
|
||||||
.getBalance(p);
|
private void giveItem(Player p, Material mat) {
|
||||||
plugin.getEconomy()
|
p.getInventory().addItem(new ItemStack(mat));
|
||||||
.depositPlayer(p, 1500);
|
}
|
||||||
double after = plugin.getEconomy()
|
|
||||||
.getBalance(p);
|
public List<Map<String, Object>> getStages() {
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
return stages;
|
||||||
+ (long) before
|
}
|
||||||
+ "§f → §a" + (long) after);
|
|
||||||
}
|
public int getMaxStage() {
|
||||||
giveItem(p, Material.IRON_PICKAXE);
|
return stages.size();
|
||||||
giveItem(p, Material.IRON_AXE);
|
}
|
||||||
giveItem(p, Material.IRON_SWORD);
|
}
|
||||||
giveItem(p, Material.IRON_HELMET);
|
|
||||||
giveItem(p, Material.IRON_CHESTPLATE);
|
|
||||||
giveItem(p, Material.IRON_LEGGINGS);
|
|
||||||
giveItem(p, Material.IRON_BOOTS);
|
|
||||||
} else if (stage == 4) {
|
|
||||||
if (plugin.getEconomy() != null) {
|
|
||||||
double before = plugin.getEconomy()
|
|
||||||
.getBalance(p);
|
|
||||||
plugin.getEconomy()
|
|
||||||
.depositPlayer(p, 2000);
|
|
||||||
double after = plugin.getEconomy()
|
|
||||||
.getBalance(p);
|
|
||||||
p.sendMessage("§a§l[礼包] §f游戏币: §e"
|
|
||||||
+ (long) before
|
|
||||||
+ "§f → §a" + (long) after);
|
|
||||||
}
|
|
||||||
giveItem(p, Material.DIAMOND_HELMET);
|
|
||||||
giveItem(p, Material.DIAMOND_CHESTPLATE);
|
|
||||||
giveItem(p, Material.DIAMOND_LEGGINGS);
|
|
||||||
giveItem(p, Material.DIAMOND_BOOTS);
|
|
||||||
}
|
|
||||||
p.sendMessage(plugin.getConfig2().msg(
|
|
||||||
"gift_claimed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void giveItem(Player p, Material mat) {
|
|
||||||
p.getInventory().addItem(new ItemStack(mat));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Map<String, Object>> getStages() {
|
|
||||||
return stages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxStage() {
|
|
||||||
return stages.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+3186
-3055
File diff suppressed because it is too large
Load Diff
+1644
-1656
File diff suppressed because it is too large
Load Diff
@@ -1,86 +1,89 @@
|
|||||||
name: Sdf1_login
|
name: Sdf1_login
|
||||||
version: 1.0
|
version: 1.0
|
||||||
main: Sdf1_login.Main
|
main: Sdf1_login.Main
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
commands:
|
commands:
|
||||||
sdf1_login:
|
sdf1_login:
|
||||||
description: Sdf1_login主命令
|
description: Sdf1_login主命令
|
||||||
usage: /sdf1_login
|
usage: /sdf1_login
|
||||||
reg:
|
reg:
|
||||||
description: 注册
|
description: 注册
|
||||||
usage: /reg <密码>
|
usage: /reg <密码>
|
||||||
login:
|
login:
|
||||||
description: 登录
|
description: 登录
|
||||||
usage: /login <密码>
|
usage: /login <密码>
|
||||||
l:
|
l:
|
||||||
description: 登录快捷版
|
description: 登录快捷版
|
||||||
usage: /l <密码>
|
usage: /l <密码>
|
||||||
注册:
|
注册:
|
||||||
description: 注册(中文)
|
description: 注册(中文)
|
||||||
usage: /注册 <密码>
|
usage: /注册 <密码>
|
||||||
登录:
|
登录:
|
||||||
description: 登录(中文)
|
description: 登录(中文)
|
||||||
usage: /登录 <密码>
|
usage: /登录 <密码>
|
||||||
玩家信息:
|
玩家信息:
|
||||||
description: 打开面板(中文)
|
description: 打开面板(中文)
|
||||||
usage: /玩家信息
|
usage: /玩家信息
|
||||||
改密码:
|
改密码:
|
||||||
description: 修改密码(中文)
|
description: 修改密码(中文)
|
||||||
usage: /改密码 <旧密码> <新密码> <确认新密码>
|
usage: /改密码 <旧密码> <新密码> <确认新密码>
|
||||||
设置邮箱:
|
设置邮箱:
|
||||||
description: 设置邮箱(中文)
|
description: 设置邮箱(中文)
|
||||||
usage: /设置邮箱 <邮箱地址>
|
usage: /设置邮箱 <邮箱地址>
|
||||||
撤销:
|
撤销:
|
||||||
description: 撤销操作(中文)
|
description: 撤销操作(中文)
|
||||||
usage: /撤销
|
usage: /撤销
|
||||||
删除:
|
删除:
|
||||||
description: 删除玩家(中文)
|
description: 删除玩家(中文)
|
||||||
usage: /删除 <玩家> <密码>
|
usage: /删除 <玩家> <密码>
|
||||||
找回密码:
|
找回密码:
|
||||||
description: 找回密码(中文)
|
description: 找回密码(中文)
|
||||||
usage: /找回密码
|
usage: /找回密码
|
||||||
签到:
|
签到:
|
||||||
description: 每日签到(中文)
|
description: 每日签到(中文)
|
||||||
usage: /签到
|
usage: /签到
|
||||||
oa:
|
oa:
|
||||||
description: 申请删除账号
|
description: 申请删除账号
|
||||||
usage: /oa [玩家名]
|
usage: /oa [玩家名]
|
||||||
删除账号:
|
删除账号:
|
||||||
description: 申请删除账号(中文)
|
description: 申请删除账号(中文)
|
||||||
usage: /删除账号 [玩家名]
|
usage: /删除账号 [玩家名]
|
||||||
通过:
|
通过:
|
||||||
description: 批准OA请求(中文)
|
description: 批准OA请求(中文)
|
||||||
usage: /通过 <编号>
|
usage: /通过 <编号>
|
||||||
拒绝:
|
拒绝:
|
||||||
description: 拒绝OA请求(中文)
|
description: 拒绝OA请求(中文)
|
||||||
usage: /拒绝 <编号> [理由]
|
usage: /拒绝 <编号> [理由]
|
||||||
accept:
|
accept:
|
||||||
description: 批准OA请求
|
description: 批准OA请求
|
||||||
usage: /accept <编号>
|
usage: /accept <编号>
|
||||||
deny:
|
deny:
|
||||||
description: 拒绝OA请求
|
description: 拒绝OA请求
|
||||||
usage: /deny <编号> [理由]
|
usage: /deny <编号> [理由]
|
||||||
sdf1debug:
|
sdf1debug:
|
||||||
description: 调试指令
|
description: 调试指令
|
||||||
usage: /sdf1debug <玩家> take.<阶段>
|
usage: /sdf1debug <玩家> take.<阶段>
|
||||||
email:
|
email:
|
||||||
description: 绑定邮箱
|
description: 绑定邮箱
|
||||||
usage: /email <邮箱>
|
usage: /email <邮箱>
|
||||||
绑定:
|
绑定:
|
||||||
description: 绑定邮箱(中文)
|
description: 绑定邮箱(中文)
|
||||||
usage: /绑定 <邮箱>
|
usage: /绑定 <邮箱>
|
||||||
调试:
|
调试:
|
||||||
description: 调试模式
|
description: 调试模式
|
||||||
usage: /调试
|
usage: /调试
|
||||||
绑定邮箱:
|
绑定邮箱:
|
||||||
description: 绑定邮箱
|
description: 绑定邮箱
|
||||||
usage: /绑定邮箱
|
usage: /绑定邮箱
|
||||||
chat:
|
chat:
|
||||||
description: 聊天过滤管理
|
description: 聊天过滤管理
|
||||||
usage: /chat
|
usage: /chat
|
||||||
recycle:
|
recycle:
|
||||||
description: 打开垃圾回收站
|
description: 打开垃圾回收站
|
||||||
usage: /recycle
|
usage: /recycle
|
||||||
垃圾清理:
|
垃圾清理:
|
||||||
description: 手动清理掉落物
|
description: 手动清理掉落物
|
||||||
usage: /垃圾清理
|
usage: /垃圾清理
|
||||||
|
menu:
|
||||||
|
description: 雪球菜单开关控制
|
||||||
|
usage: /menu <开/关>
|
||||||
Reference in New Issue
Block a user