From 606728d09acb7432128c734954be3005ead465c9 Mon Sep 17 00:00:00 2001 From: youpaishidifu <1@ypshidifu.cn> Date: Wed, 30 Sep 2026 17:32:08 +0800 Subject: [PATCH] =?UTF-8?q?SN=E7=AE=A1=E7=90=86=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=A1=B6=E5=B1=82=E5=8A=9E=E7=90=86=E7=AD=BE=E5=8F=91=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=20issue=5Fnew=EF=BC=88=E6=8C=89=E7=8E=A9=E5=AE=B6ID+?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B=E7=9B=B4=E5=8F=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Sdf1_login/SnManager.java | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/main/java/Sdf1_login/SnManager.java b/src/main/java/Sdf1_login/SnManager.java index 99a51f7..670931a 100644 --- a/src/main/java/Sdf1_login/SnManager.java +++ b/src/main/java/Sdf1_login/SnManager.java @@ -1849,6 +1849,9 @@ public class SnManager implements Listener { result = doReportCheck(sn, player, force); } else if ("issue".equalsIgnoreCase(cmd)) { result = doIssue(sn, player, itemType, reason, force); + } else if ("issue_new".equalsIgnoreCase(cmd)) { + // 顶层「办理签发」:没有旧 SN,只凭 玩家ID + 设备类型 直发 + result = doIssueNew(player, itemType, reason, force); } else { result = "未知命令: " + cmd; } @@ -2089,6 +2092,65 @@ public class SnManager implements Listener { return "办理成功,新SN=" + newSn; } + /** + * 顶层「办理签发」(issue_new):只凭 玩家ID + 设备类型 直接签发, + * 不依赖任何旧 SN 记录——管理端 SN 页顶层表单走的就是这条链路。 + * + *

与 {@link #doIssue} 的区别:doIssue 必须先查到旧 SN 并复核它 + * "已注销/销毁/补发了结";本方法没有旧 SN,改为直接核对 + * 「同种类仅 1 个」名额与冷静期,然后按类型登记发放。

+ * + *

名额/冷静期查的是本服本地库(权威),不在 PHP 侧预判—— + * web_item_sn 是 Java 推送的副本,可能滞后 30 秒。

+ * + * @param force 管理员强制操作(PHP 顶层入口固定传 0):仅跳过冷静期校验, + * 「同种类仅 1 个」不豁免 + */ + private String doIssueNew(String player, String itemType, String reason, + boolean force) { + if (player == null || player.isEmpty()) return "缺少玩家ID"; + if (itemType == null || itemType.isEmpty()) return "缺少设备类型"; + if (!TYPE_MENU.equals(itemType) && !TYPE_ECHO.equals(itemType) + && !TYPE_WAND.equals(itemType) && !TYPE_PVP.equals(itemType)) { + return "未知设备类型: " + itemType; + } + + Player online = Bukkit.getPlayerExact(player); + if (online == null) return "玩家不在线,待其上线后再办理"; + + String name = online.getName(); + // ★ 名额校验(findActive 看 active/lost/illegal 三种占位状态) + Map old = findActive(name, itemType); + if (old != null) { + return "该玩家已有有效" + typeName(itemType) + "登记(SN=" + + str(old.get("sn")) + "),请先注销/补发后再签发"; + } + if (!force) { + long cd = getCooldownUntil(name); + long now = System.currentTimeMillis(); + if (cd > now) { + long mins = (cd - now + 59999) / 60000; + return "注销冷静期未结束,还剩约 " + mins + " 分钟"; + } + } + + String newSn = force + ? applySnForce(online, itemType, typeName(itemType)) + : applySn(online, itemType, typeName(itemType)); + if (newSn == null) return "办理申领被拒(见玩家提示)"; + + ItemStack fresh = buildSnItem(online, itemType, newSn); + if (fresh == null) { + // 类型能过上面的白名单却构建失败 → 回滚,别白占"同种类仅1个"名额 + destroySn(newSn, "顶层办理签发物品构建失败回滚"); + return "办理登记成功但物品构建失败"; + } + giveTo(online, fresh); + logSn(newSn, itemType, "issue_admin", name, + reason.isEmpty() ? "管理员顶层办理签发" : reason); + return "办理成功,新SN=" + newSn; + } + /** * 报失核查:按统一三条件门槛给结论。 * force=1(管理员手动核查,回执只进 web_sn_commands,管理端可见)时