diff --git a/CHANGELOG.md b/CHANGELOG.md index 6045be5..8d4e3ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,22 @@ ### 新增 +- status 只顯示主要拒絕原因;邀請碼輸入標籤不綁定位數,同類錯誤與重試指引統一成單句紅色。 +- 修正輸入 Dialog 在到期邊界或排程提早觸發時未關閉,以及逾時提交無回覆;仍保留設定的輸入期限。 + +- 健康檢查的狀態與整合能力依設定語系顯示,並以語意顏色區分狀態、布林值與獎勵數量。 + +- Console 多行回覆逐行保留核心 log 標頭,一般回覆每行 prefix;help 合併入口、使用後台標題與文字導航。doctor/inspect/離線診斷與雙語分號句拆行,玩家報告保留一次標題 prefix。 + +- help 依標題估算寬度補長框線;返回依權限篩選後的上層分頁定位,避免第 2 頁項目返回第 1 頁。 + +- 首頁 `/ic help` 點擊直接開啟說明,與管理員說明入口一致;其他操作維持只填入聊天列。 + +- help 使用同列 prefix/標題分隔線與固定三項導航;可用項目黃色且可點擊,停用項目深灰且沒有互動事件,Console 同步呈現狀態。 + +- 統一指令、help、status/stats、聊天確認、原生 Dialog 與 MESSAGE 資格通知的 prefix、樣式及 HEX 解析;Console 使用可讀 16 色且不額外套裝飾,動態值不會被重新當成格式。 +- 套用完整繁中/英文文案;help 改為五項常用首頁、權限篩選的分類/分頁與完整用法詳情;唯讀導覽可點擊,操作只填入指令,所有 help 路徑及適用參數支援權限分級 Tab;確認畫面的 prefix 獨立一行,保留邀請碼複製、綠紅按鈕與 hover。已有自訂語系不被覆寫。 +- messages 缺鍵可使用 JAR 內建語系備援;設定載入前補回缺少的內建 YAML,不覆寫既有設定,寫入中斷不留下半份目標檔案。 - 初始 Kotlin 多模組專案骨架。 - 標準領域詞彙與已接受的 1.0 設計規格。 - Java 8 bytecode 驗證與初始 CI workflow。 diff --git a/docs/operations/bukkit-workflow.md b/docs/operations/bukkit-workflow.md index 68a1d0e..f3f0c51 100644 --- a/docs/operations/bukkit-workflow.md +++ b/docs/operations/bukkit-workflow.md @@ -16,8 +16,32 @@ ## 玩家指令 +### 訊息、prefix 與顯示設定 + +啟動及 `/ic reload` 載入設定前,都會從 JAR `config/` 白名單補回缺少的內建 YAML;已有檔案(包括損壞檔)不覆寫。復位不包含資料庫、`anti-abuse.key` 或任意自訂語系。寫入失敗或檔案無效會明確報錯;正常模式 reload 失敗仍保留上一份有效快照,storage 變更仍須遵守既有切換/重啟限制。 + +messages 查詢順序為玩家自訂語系、設定預設語系、對應內建語系、內建預設語系。只有使用內建備援時才回報缺鍵,同一快照的相同查詢語系/鍵不反覆警告;全部來源都缺鍵時仍顯示可辨識的 missing 訊息。 + +各語系使用 `presentation.prefix`(預設 `&7[&6InviteCode&7]&r`)。只有此鍵可為空字串,且必須為不帶首尾空白的單行文字。指令、help、status/stats、管理查詢及 MESSAGE 資格獎勵都經過共用輸出處理:一份完整回覆只加一次 prefix;純值、按鈕與 hover 不另加。一般回覆在同列自動補一個空格;聊天確認的 prefix 獨立一行,不留尾端空格。空 prefix 不產生空白行,Dialog 改用有意義的標題。 + +內建繁中/英文文案已套用。已有自訂 messages 不會自動改寫;要採用新文案,先備份自訂檔,再比對 JAR 的 `config/messages/` 調整,或在停服備份後移走指定語系檔,讓下次載入補回內建檔。不要移除資料庫或金鑰。缺鍵仍可使用內建備援。 + +受信任的模板支援 `&0`~`&f`、`&k`~`&o`、`&r` 及 `&#RRGGBB`;動態玩家名稱、原因、錯誤明細等以純值插入,不再次解析色碼或 `{變數}`。邀請碼的可點擊區域只涵蓋 `{code}` 本身,複製/舊版聊天填入的內容保持原始邀請碼。help 的操作用法點擊只填入聊天列;分類、分頁與返回可直接執行唯讀 help;用法、說明及玩家/管理分類按權限與發送者身分篩選。`runtime.help-row` 控制用法列與分隔文字,`runtime.help-description.*` 各自控制說明的樣式;說明不繼承外層用法列的粗體等格式。管理 inspect 的診斷欄位/識別符維持原文。 + +聊天確認依序顯示 prefix、標題、邀請人、邀請碼、問題、無冒號的期限提示、綠紅同意/不同意按鈕。聊天靠左,原生 Dialog 使用原生訊息區塊置中;不補空格、不做每秒刷新。Dialog 按鈕使用文字顏色,底色沿用客戶端原生外觀。資格已達成的通知不代表所有外部獎勵已送達,離線補發仍依原本 Reward 狀態處理。 + +Console 以標準黑底為基準篩選至少 4.5:1 對比的基本色;近黑/暗灰轉灰色,其餘暗色在可讀色中選最近值,移除額外粗體等裝飾。使用伺服器既有色碼輸出,不自行插入 ANSI 控制。這不保證自訂終端主題的外觀。第二階段的輸出及封裝測試與真實核心/客戶端驗收分開記錄,實際排版、色彩與點擊互動仍須後續矩陣及集中真人驗收。 + +詳細範圍見 [已核准顯示規格](../plans/command-feedback-display-spec.md) 與 [四階段計畫](../plans/command-feedback-implementation-plan.md)。 + Console 可使用 `/invitecode`、`/invitecode help` 與管理指令。需要玩家身分與狀態的 `code`、`claim`、`confirm`、`cancel`、`status` 與 `stats` 會明確回覆只限玩家使用。 +`/ic` 只顯示 `code`、`claim`、`status`、`stats`、`help`,有管理權限時增加 `/ic help admin` 入口。 +`/ic help admin [page]` 每頁最多五個分類,使用 `/ic help admin invitation` 查看操作,再以 +`/ic help admin invitation transfer` 查看完整參數與範例。不存在或未授權的頁面顯示一般錯誤。 +`confirm`/`cancel` 保留情境提示與明確查詢 help,不列在首頁或一般說明。所有 help 子路徑及有效頁碼 +提供權限篩選 Tab;資格 profile ID 在 force-qualify 的指定位置提示。UUID、Invite Code 與 reason 不猜值。 + Tab 建議會依發送者身分、權限與當前參數位置篩選。已完成的指令、不明路徑、Invite Code、UUID、reason 與超出語法長度的位置會回傳空集合,不會退回顯示所有線上玩家。 | 指令 | 權限 | 行為 | @@ -91,3 +115,54 @@ Invitation、Eligibility、Code Rotation 與 Storage Migration 會留下 actor 9. 以一般玩家、無權限管理員、Console 分別驗證權限與玩家專用限制;切換 `zh_TW`/`en_US`,確認語系 fallback、Dialog 文字與缺鍵紀錄;確認六碼 HEX Invite Code 在新版 client 呈現精確 RGB,在舊版呈現最接近的 legacy color。 跨 Minecraft 版本的真實伺服器矩陣由 Issue #12 執行。 + + +### Help 框線與導航顯示 + +help 以同列 prefix/標題的分隔線起始、內容後加結尾線,固定顯示 `[上一頁] [返回] [下一頁]`。 +黃色可用,深灰停用;停用項目沒有點擊或 hover,首頁三項皆停用。 +Console 可用項目顯示其導航指令。`runtime.help-frame-*`/`help-navigation-*` 控制格式與色彩, +`presentation.prefix` 仍可自訂或設空。頁面導覽為唯讀,真正操作用法仍只填入聊天列。 + + +2026-10-18 補充:首頁 `/ic help` 與 `/ic help admin` 都是唯讀導覽,點擊直接開啟; +`code`/`claim`/`status`/`stats` 等操作仍只填入聊天列,不自動執行。 + + +## 2026-10-18 Help 框線長度與返回頁規則 + +所有新舊 help 頁共用框線版面:以可見文字的字型寬度估算補長較短框線,兼顧窄拉丁字、中文及粗體; +不靠空格位移標題。既有 messages 框線是最小長度,最多補 256 個線字元。 +這是預設字型的近似,不保證資源包、Unicode 字型設定、GUI scale、窄聊天視窗下的像素對齊; +長標題可延長底線,無法避免客戶端換行時仍需真人確認。 +返回目標由共同 help 樹與目前權限篩選後的分頁決定,回到包含該項目的上層頁; +例如全權限的 storage/reload/doctor 返回管理索引 2/2,而只見 doctor 的管理員返回 1/1。 +分類頁、詳細頁與未來新增命令都套用相同規則,不為個別指令寫死頁碼; +這是可重建的上層導覽,不記錄跨命令的瀏覽器式歷史。 + + +## 2026-10-18 Console 與逐欄報告規格 + +Console 不把多行文字一次塞入 sendMessage;每個邏輯行獨立送給伺服器,時間戳與 INFO 由核心產生, +不自行偽造。一般回覆與 doctor/inspect 每行加一次語系 prefix,維持各段顏色; +已成區塊的 help 仍只在標題出現 prefix,內容各行獨立輸出以保留真實 log 標頭。 +玩家 doctor/inspect 使用一次標題 prefix 加逐欄內容,不在各行重複。 +Console 首頁只列 help 入口,help 與 help admin 都開共用管理索引,標題改為「後台指令說明」。 +不新增權限或第二份路由清單。玩家仍區分一般/管理說明。 +Console 導航只列實際可輸入的上一頁/返回/下一頁命令,不顯示不可點擊的按鈕或停用項目,省略前導斜線。 +玩家三項固定導航、停用無事件、返回所在父頁與框線共用規則保留。 + +面向使用者的繁中/英文分號句改為真正換行。doctor、inspect 與離線工具多表數量、匿名化影響範圍 +改成一行一個欄位;玩家無法登記的多項原因逐項換行。離線工具不偽造伺服器 timestamp/INFO。 +動態玩家輸入、原因、UUID、SQL/migration 檔案、程式語法與註解不作盲目分號替換。 +核心與 storage 的本輪變更經去除字串後比對,僅訊息文字改變,沒有狀態、schema、備份或交易行為變更。 +原 value.reason-separator 保留相容鍵;狀態畫面的多原因目前固定逐行顯示。 + +新增可自訂語系鍵 runtime.help-console-home-header、runtime.help-topic.console、 +runtime.help-console-navigation-title、admin.inspect-*-title 及 admin.inspect-* 報告模板。 +既有檔案通常不自動覆寫;本輪獲准更新 Folia 時先備份再部署完整雙語文案,其他核心不部署。 + + +## 2026-10-29 Doctor 語系值與色彩 + +健康檢查的一般欄位與已知狀態透過 `admin.doctor-value.*` 翻譯,沿用 config 的預設/客戶端語系政策。選配整合未啟用顯示紅色說明,不等於插件健康失敗;未知代碼中性灰保留原值。0 獎勵數量灰色,正數待執行黃/執行中青/結果待確認金。Console 使用黑底可讀的 legacy 色與每行 prefix,玩家標題 prefix 一次。僅 Folia 更新,驗收及資料保留證據見 `../testing/evidence/2026-10-29-doctor-localization.json`。 diff --git a/docs/plans/command-feedback-and-messages.md b/docs/plans/command-feedback-and-messages.md new file mode 100644 index 0000000..074fbfa --- /dev/null +++ b/docs/plans/command-feedback-and-messages.md @@ -0,0 +1,95 @@ +# 指令回饋、messages 與 prefix 待討論項目 + +狀態:2026-10-18 整體規格已確認通過,包含 console 16 色、不額外套粗體。第一至三階段的實作與 Agent 可執行檢查見 [顯示規格](command-feedback-display-spec.md) 與 [第三階段證據](../testing/evidence/2026-10-18-command-feedback-stage3.md)。F205 JAR 與既有真人驗收保持原版本綁定;第四階段尚未開始,最新 Folia 及渲染客戶端缺口另列。以下各輪保留討論歷程,後續已確認的修訂優先。 + +## 已提出的需求 + +- 重新討論指令回饋的顯示方式與排版,更新 `messages` 文字。 +- 每個訊息前面都要有 prefix;實際內容、顏色與可設定方式待討論。 +- 此前已提出的排版/美術改善一併檢視,保留邀請碼直接點擊複製、懸浮提示與確認互動。 + +## 定稿前需要明確的部分 + +1. prefix 的文字、顏色與語系設定位置;例如是否採 `[InviteCode]`,目前只是候選,不當成已選定。 +2. 成功、錯誤、提醒、help、status/stats 的文字層級與多行排版;多行訊息是整段一次 prefix,或每行都有 prefix。 +3. 「每個訊息」如何涵蓋聊天、console、Dialog 內文/標題、按鈕與懸浮提示;須先列出顯示項目讓使用者確認,不自行刪減 prefix 需求或在每個按鈕硬加字樣。 +4. 玩家與 console 的顯示差異、繁中/英文的一致性,以及玩家自訂 messages 的設定升級方式。 +5. prefix 只影響顯示文字;複製到剪貼簿的內容仍須是原始邀請碼,點擊執行的命令、HEX 色彩與期限判定不能被排版變更破壞。 + +建議的第一個行動:盤點現有訊息,提供「成功、拒絕、確認」三種靜態樣例,再討論上列規則。此為建議,不表示已批准特定設計、建立 GitHub issue 或開始改程式。 + +定稿後才建立/更新經授權的 GitHub issue,依本機 develop 狀態與候選依賴選擇分支,實作後補足舊版聊天、新版 Dialog、console 與複製/點擊互動的必要驗證。顯示修改若形成新 JAR,舊 F205 的真人結果保留原版本綁定。 + +## 第一輪討論(前三項已確認) + +關服終端機例外依使用者要求先保留紀錄,暫不修復、不做隔離測試;本輪只討論顯示設計。 + +### 現況與限制 + +- 一般指令、help 指令列、管理查詢、互動聊天、Dialog 與 MESSAGE 獎勵各有輸出路徑。未來實作不能只修改一般 send 入口。 +- `value.yes/no` 等是組合回覆的值;不能在語系解析器替每個鍵無條件加 prefix。 +- 建立邀請關係不等於達成資格;達成資格也不等於獎勵已成功發送。 +- 保留邀請碼 HEX 色彩、直接點擊複製、hover、同意/不同意與 60 秒期限。複製內容與點擊命令不包含 prefix。 +- Dialog 按鈕底色由客戶端控制,設計不承諾可任意更改。舊版不保證呈現 HEX 顏色。 + +### 建議方向 + +1. prefix 使用可設定的 `[InviteCode]`。預設灰色括號、金色產品名稱;成功綠色、提醒黃色、拒絕紅色,但仍以文字說明結果。 +2. 聊天與命令 console 每則完整回覆標示一次;多行回覆只在首行放 prefix。Dialog 在標題標示產品名稱。按鈕、hover、欄位名稱與值不各自重複標示。這是對「每個訊息」的建議解讀,須由使用者確認,尚未定案。伺服器 logger 已有插件標識,避免重複。 +3. 玩家先看結果,再看原因與可行的下一步;管理員 console 保留診斷欄位。只有確實可行的操作才給建議,不能要求已失去資格的玩家再換碼重試。 +4. prefix 集中設定,不要求維護者手動貼在每個 messages 鍵上;具體配置位置、可否留空與升級方式留待後續討論。 + +### 第一輪問題 + +1. 是否接受上述 prefix 範圍:一則回覆一次、多行首行一次、Dialog 標題標示,按鈕/hover/值不另加? +2. 是否接受預設 `[InviteCode]` 灰括號與金色名稱,並可自訂? +3. 是否接受玩家用白話的「結果 → 原因/下一步」,管理員輸出保留必要診斷資料,並將成功/提醒/拒絕分色? + +使用者後續回覆「三題都依妳建議」:上述問題 1–3 已確認。建議方向 1–3 為顯示規格決定;第 4 項的配置細節仍待確認。這不是程式修改或 remote write 授權。不新增 ADR 或改寫領域詞彙。 + +## 第二輪討論(已確認,確認區與缺檔行為追加調整) + +4. **Help**:每行「指令 — 簡短用途」,沿用依權限及玩家/console 身分篩選;有權限的管理員分「玩家操作/管理操作」,console 不列玩家專用指令。不新增路由或分頁。玩家點擊只填入聊天列,不立即執行,避免誤觸建立邀請碼而失去 claim 資格。完整管理用法須與既有 parser 對應,不以省略號代替正式參數說明。 +5. **Status/stats**:status 回答自己的登記狀態與待補發筆數,stats 回答作為邀請人的人數統計;每欄一行。沿用現有欄位,不新增排行榜、獎勵金額或資格進度百分比。若不能登記,顯示可取得的實際原因;原因未能判定時不猜測,須在實作前核對資料路徑。 +6. **確認畫面**:標題 `[InviteCode] 確認邀請碼`,其後依序邀請人、邀請碼、確認問題、`請在 {seconds} 秒內選擇`、同意/不同意。末句不加冒號,不新增每秒重繪或聊天倒數洗版;依現有機制逾時失效,使用過期操作時說明重新開始方式。聊天按鈕保留 hover 與直接操作,Dialog 使用等價內容與可支援的文字顏色,底色由客戶端控制。 +7. **設定位置與文字形式**:建議 prefix、訊息及其顏色放在各語系 messages 檔;config.yml 只保留語系選擇等行為設定。插件自動加 prefix,不要求每句手貼。多行先用 YAML `|-` 字串,不引入陣列或可執行的格式語法;prefix 是否允許空值、顏色語法與按鈕樣式鍵留待此項接受後確認。沿用既有 JAR 與執行期設定檔路徑。 +8. **設定更新**:建議保留管理員自訂內容,新增缺鍵時用同語系內建預設作最後備援並記錄可操作提示;不默默重寫 YAML。客戶端語系→設定預設語系的既有選擇規則保留,各語系都須先有完整內建樣板。舊檔在本輪若不需破壞性格式變更,不只因文案修改而升 messages-version;若最終配置契約確實不相容,再明確設計版本處理。reload 仍需整份驗證成功後一次套用,失敗保留舊設定。此為新提案,現況缺鍵仍回傳 `[missing: key]`,不能宣稱已有內建備援。 + +預覽用的 status: + +```text +[InviteCode] 我的邀請狀態 +可使用邀請碼:否 +邀請關係:等待達成資格 +待補發獎勵:0 筆 +``` + +預覽用的 stats: + +```text +[InviteCode] 我的邀請統計 +等待達成資格:2 人 +已達成資格:5 人 +``` + +以上數字是樣例。status 原因與完整管理用法須在實作前補齊對應證據,不新增未驗證的獎勵成功敘述。 + +使用者回覆「4–8 都依妳建議」,並追加兩項要求:確認區 prefix 獨立第一行、後面不留空格,其他內容放第 2–7 行;確認畫面希望置中。缺少檔案時須從 JAR 複製初始檔案。舊的同列確認標題樣例由下列第三輪草案取代,對齊範圍仍需確認。 + +## 第三輪討論(已確認,console 色彩另行修訂) + +9. **七行確認區與對齊範圍**:建議第 1 行只有 prefix,第 2 行「確認邀請碼」,第 3–6 行依序為邀請人、邀請碼、問題、期限,第 7 行按鈕。聊天仍靠左,原生 Dialog 以 prefix 作標題、其他內容置中;使用者若也希望聊天置中,需另確認客戶端寬度與字型限制,不用固定空格假裝精準置中。各平台的置中 API 與實際客戶端外觀需在實作階段核對,目前 adapter 沒有明確設定對齊。Dialog 的「七行」是七個邏輯區塊,不保證自訂長文字在窄視窗仍只有七個實際文字行。 +10. **prefix 配置鍵**:建議各語系用 `presentation.prefix: "&7[&6InviteCode&7]&r"`,值不含尾端空格。一般同列回覆由 renderer 加一個分隔空格;確認區獨立行不加。建議允許 `""` 關閉 prefix,並省略其分隔空格與獨立空行;這需要有別於現行所有鍵不得空白的解析規則。Dialog 標題不能依賴空 prefix 保持可識別性,關閉時以「確認邀請碼」作標題且不重複內文標題。 +11. **顏色語法**:建議支援 `&0`–`&f`、`&k`–`&o`、`&r` 與單一 HEX 寫法 `&#RRGGBB`。先不引入 MiniMessage、漸層或新增套件;未支援的文字視為原文。支援 RGB 的平台呈現 HEX,舊版用既有最近基本色策略;console 命令回覆移除樣式碼,伺服器 logger 另循既有規則。模板先解析樣式再插入玩家輸入等動態值,避免名稱/外部文字被當成格式指令;複製及 click payload 始終不帶樣式。此為待實作契約,不是聲稱現有 messages 已支援上述語法。 +12. **完整繁中文案方向**:見 [繁中完整訊息草案](command-feedback-messages-zh-TW.draft.yml)。保留既有鍵與變數,更新白話敘述;新增 prefix 與 help 說明鍵。建立關係、達成資格、獎勵已交付不能混稱。資格通知維持「已達成資格」,不聲稱所有獎勵已入帳。診斷識別符保留原文。建議以此為基礎,繁中與英文同步維護;英文完整對照在繁中內容確認後產生。 +13. **缺檔復位時機與邊界**:已接受「缺檔從 JAR 補回、不覆寫既有檔案」。建議啟動及 `/ic reload` 載入前皆執行,僅針對 JAR 內建設定檔白名單;不把缺少自訂語系或損壞的 YAML 視為可任意重設。無法寫入、資源缺失或設定無效時明確報錯;reload 保留最後有效設定。資料庫與 anti-abuse key 不屬於此設定檔復位規則,不藉此重建任何既有資料或金鑰。 + +第三輪確認後仍需核對完整 help 用法與英文文案,再讓使用者確認整體規格,方可提出程式實作計畫。本輪只更新設計文件與離線預覽,沒有建置、部署或變更已驗收 JAR。 + +## 整體審閱稿 + +使用者已接受第 9–13 項,明確指定聊天靠左、Dialog 置中;並撤換原先 console 純文字方向:console 希望保留玩家相同的色彩語意,玩家專用指令才拒絕,要求評估粗體與 HEX 的能力/黑底可讀性。 + +已完成 [完整 help 用法核對](command-feedback-help-reference.md) 與 [英文完整文案](command-feedback-messages-en-US.draft.yml)。繁中與英文保留全部既有訊息鍵及變數;help 用途依 20 個 parser route ID 補齊。新增「此指令只能由玩家執行」的對等文字,不因 console 而拒絕管理命令。 + +最後建議的 console 策略為:保留成功/警告/錯誤色彩,預設 16 色、不額外套粗體,HEX 選最近基本色並避開過暗結果;不引入 HEX 偵測或終端依賴。終端能力與實際主題不保證相同,此建議及完整整合稿仍待使用者最後確認。以 [整體規格](command-feedback-display-spec.md) 為本輪審閱依據,不將原先「移除全部色碼」歷史提案當成現行要求。 diff --git a/docs/plans/command-feedback-display-spec.md b/docs/plans/command-feedback-display-spec.md new file mode 100644 index 0000000..d2ef5cc --- /dev/null +++ b/docs/plans/command-feedback-display-spec.md @@ -0,0 +1,152 @@ +# 指令回饋與 messages 整體規格 + +## 2026-10-30 驗收修正:原因、單句錯誤與輸入逾時 + +使用者核准沿目前功能分支修正。`/ic status` 沿既有資格理由次序,只顯示第一個主要原因: +已建立邀請碼優先於已有邀請關係,再其次才是登記期限到期。只調整呈現,不放寬資格判定。 +不插入多原因換行;客戶端仍可能依聊天寬度自然折行。 +`/ic claim` 的多原因回覆目前保留,先將原文列為討論項,不自行擴大為全專案理由篩選。 + +邀請碼格式錯誤、逾時與其他同類錯誤+重試指引採單句、單一紅色;保留雙語語意、變數與指令。 +狀態報告與成功後的下一步多行指引不套用這項錯誤句型規則。 +原生輸入標籤為「邀請碼」/「Invite code」,不限制成六位文案;實際格式驗證及儲存均不變。 + +原生輸入沿 `claim.chat-input-timeout`,預設 60 秒。到期包含剛好等於期限,關閉輸入框並提示; +排程若先於實際時間到期,按剩餘時間再次排程,不因一次未到期而永久失去關閉工作。 +提交處再次核對到期,避免晚到的提交悄悄消失;若取消先於到期排程處理,仍明確顯示取消。 +確認階段沿原 `confirmation-timeout`;共用會話比較使用同一到期邊界。 +新候選的原生畫面仍需真人複驗;先保留 B 已登記的邀請完成離線補發,再停服部署,不重設 B。 + +狀態:2026-10-18 使用者確認整體規格通過。第一、二階段已完成訊息實作及封裝;[第三階段證據](../testing/evidence/2026-10-18-command-feedback-stage3.md) 記錄獲准的八核心與兩個網路玩家流程、最新 Folia 及渲染客戶端限制。前一候選已部署 Human,但第四階段因首頁資訊過量正在修正,尚未完成真人外觀;[實作與測試計畫](command-feedback-implementation-plan.md) 保留後續範圍與 remote 邊界。 + +## 回覆與 prefix + +- 使用各語系 `presentation.prefix`,預設 `&7[&6InviteCode&7]&r`;允許空字串關閉。 +- prefix 是單行,不含尾端空格;一般回覆由輸出層加一個分隔空格,多行只在首行標示。 +- 確認區將 prefix 獨立成第一行,沒有尾端空格。關閉時省略 prefix 及空行;Dialog 改用「確認邀請碼/Confirm Invite Code」作標題,不重複內文標題。 +- 按鈕、hover、欄位名稱與值不是獨立回覆,不各自加 prefix。伺服器 logger 沿用既有插件標識,不再重複。 +- 一般指令、help、status/stats、管理查詢、互動元件與 MESSAGE 獎勵都需涵蓋,不只修改一般 send 入口。 + +## 玩家聊天與 Dialog + +- 聊天靠左,Dialog 標題及確認內文置中;使用平台提供的配置,不以空格補位置。 +- 確認區七個邏輯區塊:prefix、確認邀請碼、邀請人、邀請碼、是否使用、選擇期限、同意/不同意。長文或窄視窗仍可能換行。 +- 期限提示使用 `請在 {seconds} 秒內選擇`,末尾無冒號,不每秒刷新。 +- 邀請碼直接點擊複製與 HEX 彩蛋保留。按鈕綠/紅字與 hover 保留,Dialog 底色由客戶端控制。 +- 玩家首頁及詳細用法的操作指令點擊只填入聊天列;help 分類、頁碼與返回可直接執行唯讀導覽。確認區的同意/不同意維持原本操作。 +- 原生輸入 Dialog 同樣使用 prefix 作標題,內文放輸入用途與欄位;空 prefix 時以輸入用途作標題。不增加新的輸入模式。 + +## 色彩與 console 已確認規則 + +所有模板接受基本色 `&0`–`&f`、樣式 `&k`–`&o`、重設 `&r` 及 HEX `&#RRGGBB`。第一階段實作底層解析,第二階段接入指令/聊天/Dialog。保留未支援的文字為原文,不新增格式套件。 + +| 輸出 | 顏色 | 粗體及其他樣式 | +| --- | --- | --- | +| 支援 RGB 的玩家聊天/Dialog | 基本色與 HEX;邀請碼依六碼顏色呈現 | 依平台能力呈現;內建文案不靠粗體辨識結果 | +| 舊版玩家聊天 | HEX 轉最近基本色,保留既有邀請碼降色策略 | 依平台能力呈現 | +| Console 命令回覆 | 保留同一組成功/警告/錯誤色彩;預設 16 色,HEX 轉基本色,過暗結果改成可讀的亮色 | 不額外套用粗體;移除模板的粗體、斜體、底線、刪除線及隨機字樣式,保留文字與顏色 | +| 無色彩能力的宿主輸出 | 由伺服器既有輸出能力處理;不得直接印出格式碼或自行塞 ANSI escape | 純文字仍有完整結果與原因 | + +Console 不新增 HEX 自動偵測或 JLine 依賴;即使宿主支援 true color,預設仍用 16 色。建議 HEX 從基本色選最接近者,以標準黑底為降色可讀性基準;若結果過暗,改選亮色子集。內建文案以灰/白/金/黃/綠/紅為主,不使用黑字。實際終端機可自訂色盤及底色,不能保證所有主題的對比;後續驗收核對實際宿主。 + +粗體不適合作為 console 必要層級:部分終端機把它當成亮度,不一定增加字重。上述「不額外套粗體」不禁止宿主用亮度實作亮色。 + +依據:[Microsoft Console VT 文件](https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) 的 SGR 1 為 Bold/Bright,且色盤可自訂;[JLine attributed strings](https://jline.org/docs/advanced/attributed-strings/) 說明輸出取決於終端能力。這些資料不證明本機 Minecraft 輸出路徑已支援任一效果。 + +Console 的內容與權限依指令用途判斷,不因使用 console 而一律拒絕。只有玩家專用指令回覆「此指令只能由玩家執行/Only a player can run this command.」。Console help 隱藏玩家專用列;管理員玩家只看有權限的列。 + +## Help 與個人查詢 + +完整指令、參數、權限與限制見 [help 核對表](command-feedback-help-reference.md),依實際 parser/controller 整理。不新增指令,不用省略號代替正式用法。 + +- `/ic` 首頁只列 `code`、`claim`、`status`、`stats`、`help`;各列仍需相應權限。具管理權限時只增加一個 `/ic help admin` 入口。 +- `/ic help` 顯示玩家索引;console 改顯示管理索引。`/ic help admin [page]` 顯示管理分類,每頁最多五項,先按權限篩選再分頁。 +- 使用完整路徑 `/ic help admin invitation` 查看分類,再以 `/ic help admin invitation transfer` 查看完整參數、用途與範例。不提供 `/ic help invitation` 簡寫。 +- `confirm`/`cancel` 不列在首頁與一般說明;claim 互動情境保留必要提示,可明確查詢 `/ic help confirm`/`ic help cancel`。Tab 可依權限探索這些明確命令。 +- `/ic reload` 是主要操作寫法,`/ic admin reload` 保留別名;help 統一在 `/ic help admin reload` 查閱。 +- 所有 help 路徑與可用頁碼提供權限分級 Tab;實際操作參數只在正確位置提示玩家名稱、backend 或資格 profile ID。UUID、邀請碼、原因、完整指令尾端與未知/超長路徑回傳空集合。 +- help 標題、分類、詳細文案、導航與錯誤均由雙語 messages 設定。完整回覆只顯示一次 prefix;未授權或不存在的頁面不洩漏操作參數。 +- `/ic status` 逐欄顯示可登記、邀請關係、待補發獎勵;無法登記時列出真實原因。 +- `/ic stats` 逐欄顯示等待達成資格與已達成資格人數;不新增排行榜、金額或猜測的百分比。 +- 「建立關係」「達成資格」「交付成功」分開敘述;資格通知不等於所有獎勵已入帳。 +- 管理查詢沿用必要識別符、狀態與診斷資料,不藉文案修改變更資料查詢/管理操作語意。 + +## 配置與復位 + +- [繁中完整草案](command-feedback-messages-zh-TW.draft.yml) 與 [英文完整草案](command-feedback-messages-en-US.draft.yml) 具有相同鍵、變數與互動語意。prefix、文案及顏色放各語系 messages,語系選擇仍在 config.yml。 +- 多行使用 YAML `|-` 字串;只有 prefix 可為空,不將其他必填鍵改成可任意空白。 +- 模板樣式與動態文字分開處理,動態值不再解析成格式指令;複製值與 click payload 不含 prefix 或色碼。 +- 保留既有語系選擇規則;缺鍵可用同語系內建預設作備援並提示管理員,不改寫管理員的 YAML。 +- 啟動與 reload 載入前,從 JAR 補回白名單中缺少的初始設定檔;已有檔案不覆寫。損壞、無權限、無法讀取時明確報錯;reload 保留最後有效設定。 +- 補回 storage.yml 不代表可在 reload 直接切換儲存;繼續沿用既有切換與重啟限制。資料庫與 anti-abuse key 不屬於設定檔復位,不重建現有資料或金鑰。 +- 保留 JAR 的 `config/` 資源結構與目前執行期輸出位置。不只因文案更新調高 messages-version;任何格式不相容須另外確認版本處理。 + +## 後續驗證與範圍 + +實作後需要自動回歸:全部訊息鍵/變數與語系備援、prefix 次數及空白、樣式解析與動態文字隔離、每條 help 與 parser 一致、權限及 console 篩選、無參數尾端 tab 空集合、缺檔復位而不覆寫、reload 失敗不切換,以及 copy/hover/click payload 保留。 + +平台複驗涵蓋舊版聊天、新版 Paper/Folia Dialog 和 console。真人驗收核對實際置中、字型、顏色與互動;HTML 模擬和靜態檢查不能代替。新 JAR 的證據另綁版本,不改寫 F205 既有驗收。 + +規格已通過,第一至三階段的實作與 Agent 檢查分別記錄於證據文件;第四階段已開始,2026-10-18 依真人回饋加入分層 help。真實網路/回呼不代替客戶端渲染與真人外觀,最新 Folia 的缺口另列。關服例外維持暫緩,沒有隔離測試。Human 更新依本輪授權進行,證據另記;沒有 push、PR 或發行。 + + +## 2026-10-18 Help 分隔與固定導航 + +所有成功的 help 首頁、分類、分頁與詳細頁均使用同一行標題:灰色分隔線、語系 prefix、金色說明名稱/頁碼。 +prefix 不再單獨佔一行、不重複;仍由 `presentation.prefix` 自訂,空值維持停用。 +內容後加灰色結尾線,底部固定依序顯示上一頁、返回、下一頁。可用按鈕黃色、有唯讀 help 點擊與 hover; +停用按鈕深灰色,沒有 click 或 hover 事件,按下不做任何事。首頁三項均停用;首/末頁按實際可用性停用, +詳細頁只保留返回可用。Console 使用相同順序與狀態,可用項目另顯示導航命令,顏色仍遵守可讀 16 色。 +模板使用 `runtime.help-frame-header`(`{prefix}`/`{title}`)、`help-frame-divider`、 +`help-navigation-enabled`/`help-navigation-disabled`(`{text}`)與 `help-navigation-hover`; +沿用三項標籤設定。動態文字不重新解析樣式,模板不能自訂點擊目標。 + + +2026-10-18 補充:首頁 `/ic help` 與 `/ic help admin` 都是唯讀導覽,點擊直接開啟; +`code`/`claim`/`status`/`stats` 等操作仍只填入聊天列,不自動執行。 + + +## 2026-10-18 Help 框線長度與返回頁規則 + +所有新舊 help 頁共用框線版面:以可見文字的字型寬度估算補長較短框線,兼顧窄拉丁字、中文及粗體; +不靠空格位移標題。既有 messages 框線是最小長度,最多補 256 個線字元。 +這是預設字型的近似,不保證資源包、Unicode 字型設定、GUI scale、窄聊天視窗下的像素對齊; +長標題可延長底線,無法避免客戶端換行時仍需真人確認。 +返回目標由共同 help 樹與目前權限篩選後的分頁決定,回到包含該項目的上層頁; +例如全權限的 storage/reload/doctor 返回管理索引 2/2,而只見 doctor 的管理員返回 1/1。 +分類頁、詳細頁與未來新增命令都套用相同規則,不為個別指令寫死頁碼; +這是可重建的上層導覽,不記錄跨命令的瀏覽器式歷史。 + + +## 2026-10-18 Console 與逐欄報告規格 + +Console 不把多行文字一次塞入 sendMessage;每個邏輯行獨立送給伺服器,時間戳與 INFO 由核心產生, +不自行偽造。一般回覆與 doctor/inspect 每行加一次語系 prefix,維持各段顏色; +已成區塊的 help 仍只在標題出現 prefix,內容各行獨立輸出以保留真實 log 標頭。 +玩家 doctor/inspect 使用一次標題 prefix 加逐欄內容,不在各行重複。 +Console 首頁只列 help 入口,help 與 help admin 都開共用管理索引,標題改為「後台指令說明」。 +不新增權限或第二份路由清單。玩家仍區分一般/管理說明。 +Console 導航只列實際可輸入的上一頁/返回/下一頁命令,不顯示不可點擊的按鈕或停用項目,省略前導斜線。 +玩家三項固定導航、停用無事件、返回所在父頁與框線共用規則保留。 + +面向使用者的繁中/英文分號句改為真正換行。doctor、inspect 與離線工具多表數量、匿名化影響範圍 +改成一行一個欄位;玩家無法登記的多項原因逐項換行。離線工具不偽造伺服器 timestamp/INFO。 +動態玩家輸入、原因、UUID、SQL/migration 檔案、程式語法與註解不作盲目分號替換。 +核心與 storage 的本輪變更經去除字串後比對,僅訊息文字改變,沒有狀態、schema、備份或交易行為變更。 +原 value.reason-separator 保留相容鍵;狀態畫面的多原因目前固定逐行顯示。 + +## 2026-10-29 健康檢查語系與語意配色 + +`/ic admin doctor` 的欄位與狀態值共用 messages 語系選擇,Console 使用設定預設語言; +玩家依 `use-client-locale` 決定是否使用客戶端語言。Paper、SQLite、MySQL、JSON、PlaceholderAPI、 +Vault 等名稱保留。布林改成符合欄位的已啟用/未啟用、可用/不可用、支援/不支援,正值綠、反值紅; +整合未啟用不代表插件故障。 + +運作中與接受新工作為綠;啟動/停止中為黃、維護中為金、已停止/不接受新工作為灰。 +獎勵數量 0 為灰;正數待執行為黃、執行中為青、結果待確認為金。未知值以灰色保留原始診斷值。 +顏色只由可信語系模板提供,動態值不重新解析格式。Console 沿用黑底可讀的 legacy 16 色輸出且不額外粗體。 +語系鍵使用 `admin.doctor-value.*`;玩家報告標題 prefix 一次,Console 每行一次並由核心提供 log 標頭。 + +新增可自訂語系鍵 runtime.help-console-home-header、runtime.help-topic.console、 +runtime.help-console-navigation-title、admin.inspect-*-title 及 admin.inspect-* 報告模板。 +既有檔案通常不自動覆寫;本輪獲准更新 Folia 時先備份再部署完整雙語文案,其他核心不部署。 diff --git a/docs/plans/command-feedback-help-reference.md b/docs/plans/command-feedback-help-reference.md new file mode 100644 index 0000000..7a53276 --- /dev/null +++ b/docs/plans/command-feedback-help-reference.md @@ -0,0 +1,68 @@ +# Help 完整用法核對表 + +2026-10-15 唯讀核對,來源 HEAD `e8e2b1f`。產品命令解析器與 controller 是用法依據;下表是待實作 help 的呈現規格,不表示目前 help 已具備此排版。 + +`/ic` 是 `/invitecode` 的別名。表中 `<...>` 必填,`[...]` 選填;符號本身不輸入。Console 輸入時省略 `/`。下列每項仍需基本權限 `invitecode.command.basic`,並符合各列權限。 + +## 完整清單 + +| ID | 用法 | 用途 | 執行者 | 權限 | +| --- | --- | --- | --- | --- | +| help | `/ic help` | 查看玩家指令索引;`/ic` 為精簡首頁 | 玩家、console | `invitecode.command.basic` | +| code | `/ic code` | 查看或建立自己的邀請碼 | 玩家 | `invitecode.command.code` | +| claim | `/ic claim [code]` | 使用別人的邀請碼;省略 code 時依設定開啟輸入 | 玩家 | `invitecode.command.claim` | +| confirm | `/ic confirm` | 同意目前的邀請確認 | 玩家 | `invitecode.command.claim` | +| cancel | `/ic cancel` | 取消輸入或確認 | 玩家 | `invitecode.command.claim` | +| status | `/ic status` | 查看自己的邀請狀態 | 玩家 | `invitecode.command.status` | +| stats | `/ic stats` | 查看自己的邀請統計 | 玩家 | `invitecode.command.stats` | +| inspect-player | `/ic admin inspect player ` | 查詢玩家紀錄 | 玩家、console | `invitecode.admin.inspect` | +| inspect-invitation | `/ic admin inspect invitation ` | 查詢邀請關係 | 玩家、console | `invitecode.admin.inspect` | +| inspect-reward | `/ic admin inspect reward ` | 查詢獎勵動作 | 玩家、console | `invitecode.admin.inspect` | +| unlink | `/ic admin invitation unlink ` | 解除邀請關係 | 玩家、console | `invitecode.admin.invitation` | +| transfer | `/ic admin invitation transfer ` | 轉移邀請關係 | 玩家、console | `invitecode.admin.invitation` | +| force-qualify | `/ic admin invitation force-qualify ` | 強制達成指定資格 | 玩家、console | `invitecode.admin.qualification` | +| reset-eligibility | `/ic admin eligibility reset ` | 重設登記資格 | 玩家、console | `invitecode.admin.eligibility` | +| retry-reward | `/ic admin reward retry ` | 重試獎勵動作 | 玩家、console | `invitecode.admin.reward` | +| mark-delivered | `/ic admin reward mark-delivered ` | 標記獎勵動作已交付 | 玩家、console | `invitecode.admin.reward` | +| rotate-code | `/ic admin code rotate ` | 輪替玩家邀請碼 | 玩家、console | `invitecode.admin.code` | +| migrate-storage | `/ic admin storage migrate ` | 更新目前儲存結構 | 玩家、console | `invitecode.admin.storage` | +| reload | `/ic reload` | 重新載入設定與訊息;`/ic admin reload` 等價 | 玩家、console | `invitecode.admin.reload` | +| doctor | `/ic admin doctor` | 檢查執行狀態與儲存健康 | 玩家、console | `invitecode.admin.doctor` | + +Help 的顯示列依這些 ID 與固定路由產生,用途從雙語 `runtime.help-description` 取得;不讓文案編輯改變 parser 的路由與參數規則。首頁與分層索引依權限顯示;完整用法只在各指令詳細頁展開。 + +## 參數與容易混淆之處 + +- `code`:有效邀請碼,不是玩家名稱。 +- `player-reference`:玩家 UUID 或已知名稱;同名有歧義時改用 UUID。 +- `invitation-uuid`:邀請關係 ID,不能以玩家 UUID 代替。 +- `reward-action-uuid`:獎勵動作 ID,不是 Reward Delivery ID。 +- `qualification-profile-id`:資格設定的 ID,不是玩家名稱/UUID。 +- `reason`:管理原因,必填,可包含多個單字;parser 將剩餘參數以空格合併。不要以文件中的尖括號或示例字串代替實際原因。 +- `SQLITE|MYSQL`:二選一,且必須與目前設定的 backend 相同;不接受 JSON。此指令更新 schema,**不是**跨 backend 搬移工具。 +- `root` 不是子命令;`/ic` 本身就會顯示 help。 +- 玩家用法與管理用法的權限不變;此規格不授權變更服務狀態下哪些命令可用。 + +## 原始碼依據 + +- [InviteCodeCommandParser.kt](../../invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParser.kt):20 個命令 ID、參數數量、選填 code、reason 合併及 reload 別名。 +- [AdminWorkflowController.kt](../../invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt):玩家 reference、Invitation/Reward Action UUID、qualification profile ID。 +- [PlayerReferenceResolver.kt](../../invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/PlayerReferenceResolver.kt):UUID/已知名稱解析。 +- [InviteCodePlugin.kt](../../invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt):runtime 權限與 storage migrate backend 限制。 +- [plugin.yml](../../invitecode-plugin/src/main/resources/plugin.yml):主命令、`ic` 別名與 permission 定義。 + +本輪未執行命令或 build;用法核對屬靜態證據。日後實作需以 parser 驅動檢查 help 的每條路由,避免維護兩份互相分歧的用法。 + +## 2026-10-18 真人回饋修訂:分層說明 + +`/ic`:五個常用操作與有權限的管理說明入口,不列完整管理用法。 +`/ic help`:玩家操作索引(console 為管理索引)。 +`/ic help admin [page]`:管理分類,每頁五項;分類再進 `/ic help admin invitation`,操作再進 +`/ic help admin invitation transfer`。完整參數仍以下表及 parser 為準。 +`confirm`/`cancel` 只在互動情境提示,明確查詢其 help 仍有效。 + +詳情模板使用 `runtime.help-detail.*` 的 `{usage}` 與 `{example}`;範例為展示用途,UUID 類欄位使用 +`EXAMPLE_INVITATION_UUID`/`EXAMPLE_ACTION_UUID`,必須換成實際 ID。分類使用 `runtime.help-topic*`, +導航使用 `runtime.help-previous`/`help-next`/`help-back`,頁碼錯誤使用 `runtime.help-page-error`。 +操作只填入聊天列;分類與分頁只執行唯讀 help。基本權限及每項專屬權限同時成立才顯示或提供 Tab。 +不提供 help 簡寫,不為 UUID/邀請碼/reason 猜值;額外參數回傳空 Tab 集合。 diff --git a/docs/plans/command-feedback-implementation-plan.md b/docs/plans/command-feedback-implementation-plan.md new file mode 100644 index 0000000..12a8b10 --- /dev/null +++ b/docs/plans/command-feedback-implementation-plan.md @@ -0,0 +1,242 @@ +# 指令回饋與 messages 實作、測試計畫 + +日期:2026-10-18。使用者已授權沿用功能 Worktree 執行第三階段,明確暫不 push。[第一階段證據](../testing/evidence/2026-10-18-command-feedback-stage1.md) 記錄底層實作;[第二階段證據](../testing/evidence/2026-10-18-command-feedback-stage2.md) 記錄輸出整合與封裝;[第三階段證據](../testing/evidence/2026-10-18-command-feedback-stage3.md) 記錄八個選定核心及兩個網路玩家流程。Agent 可執行範圍已通過,保留最新 Folia 及渲染客戶端缺口;第四階段尚未開始。 + +## 基線與分支 + +- 已唯讀查詢遠端:`develop` 與 `origin/develop` 均為 `5041c701f824ba5934a0647f2db52a475f503bca`;主要 checkout `D:\Code\Java\Plugin\InviteCodeKt\repo` 乾淨。 +- 已使用 branch:`codex/feat/command-feedback-messages`。 +- 已使用 Worktree:`D:\Code\Java\Plugin\InviteCodeKt\worktrees\feat-command-feedback-messages`。 +- 起點為開始實作時重新核對的最新 `develop`,未來 PR target 為 `develop`。 +- 現有 `codex/release/1.0.0` HEAD `e8e2b1f` 的產品原始碼與 develop 相同,差異只有文件及版號;此功能不依賴未合併的 runtime 修改,不需要先合併 release。 +- 第一階段已把明確列出的規格、雙語草案、help 核對表及本計畫複製到功能 Worktree;release 來源保留,不搬移、不 stash、不 cherry-pick 整條發行歷史。第二階段同步更新功能 Worktree 的參考文案,執行期權威為 plugin 的 `config/messages/`。 +- release 的歷史驗收文件、其他 Worktree 及 F205 產物保持原樣。功能分支沿用 develop 版號,不夾帶 1.0.0 升版;功能合併後另行規劃發行候選重建及複驗。 +- 此次已核准第一至三階段的本機實作、驗證與可回復的 task commit;GitHub Issue 建立、push、PR、merge、tag、發布皆需對應的明確授權,尚未執行。 + +## 範圍與方法 + +驗收依據為 [已通過的顯示規格](command-feedback-display-spec.md)、[help 核對表](command-feedback-help-reference.md) 與兩份語系草案。 + +1. 訊息模板/輸出處理:以少量共用處理統一 prefix、色彩與純值片段,將模板格式和動態值隔離。平台 API 留在 adapter;不改邀請、資格、獎勵交付與儲存契約。 +2. 各發送路徑接入:命令、help、status/stats、管理查詢、互動聊天、Dialog、MESSAGE 獎勵。保留玩家左對齊與 Dialog 置中;不以空格補位置。 +3. 雙語 messages、prefix 設定、缺鍵備援、啟動/reload 缺檔復位,保留自訂檔案與原本儲存切換限制。 +4. Console 16 色、不額外套粗體、HEX 降色並避開過暗結果;沿用伺服器輸出能力,不插入自製 ANSI 控制或引入終端依賴。 + +不新增 production dependency、資料庫 schema migration、排行榜、每秒倒數或新的指令用途。關服終端例外維持暫緩,不做其隔離測試,也不修改 InstanceHarbor。 + +## 四個實作與驗收階段 + +### 第一階段:訊息與設定回歸 + +先寫會失敗的行為測試,再完成最小實作: + +- prefix 同列/獨立行/空字串、不重複、不留尾端空格及多餘空行;純值、hover、按鈕不另加。 +- 繁中/英文鍵與變數一致、現有自訂文字不被替換、語系選擇與缺鍵備援。 +- 基本色與 HEX、玩家舊版降色、console 16 色與裝飾樣式去除、黑色/過暗輸入仍可讀。 +- 動態文字含 `&a`、`�`、大括號等不會被再次當作模板;複製與命令 payload 保持原值。 +- 缺少內建檔案時補回;已有檔案逐位元組不變;無法讀寫/損壞檔明確失敗;reload 不切換到半套設定。 + +證據:測試結果與對應案例清單;不是僅對輸出常數逐字自我比對。 + +### 第二階段:輸出整合與封裝 + +- 每條 help 用法對照 20 個 parser 項目,測一般玩家、部分管理權限、完整管理員與 console;既有別名保留。 +- 無參數指令及超出合法位置的 tab 一律空集合,不回落為玩家名稱。 +- 測 code → claim 前置檢查 → 輸入/cancel → 確認/不同意/逾時 → 建立關係 → 資格通知/離線補發的必要整合路徑;不改其領域語意。 +- 聊天與兩種原生 Dialog adapter 保留點碼、hover、按鈕與關閉/逾時語意。核對實際 API 的置中能力,不靠 HTML 樣例推定可行。 +- 依 README,先核對 mise 現有選版與 JDK,再用 Wrapper 執行 `check shadowJar`;補做既有 local Java 8 相容性驗證,不安裝新 JDK。 +- 檢查 JAR 的 plugin.yml、UTF-8、`config/` 資源與雙語 messages、Java 8 class 邊界;保存 commit、JAR SHA-256 及測試摘要。更新操作文件、設定說明與 CHANGELOG。 + +沿用既有完整 check;MySQL 整合僅在已核對隔離資料與憑證邊界時執行,不觸及既有 DB。後續若授權 PR,沿用現行 Windows/Linux、Java 8/11 及隔離 MySQL CI,不在本輪觸發 remote。 + +### 第三階段:Agent 真實核心矩陣 + +沿用 `test-servers/matrix.json` 的八個 profile,不以三台真人測服代替發行矩陣:Spigot 1.8.8/1.12.2/1.16.5/latest、Paper 1.20.6/1.21.8/latest、Folia latest(實驗性)。 + +- 開始前以 InstanceHarbor 現行文件與實際資源核對版本、build、JDK、SHA、未被占用的 port,將 latest 鎖到本輪實際核心;不把舊的 latest 名稱當成版本證據。 +- Agent 實例與 Human 分離,不接人工 Velocity;優先重用驗證過的不可變核心。若舊 runner 與現行管理器契約不符,先回報,不擴張修管理器。 +- 每個 profile 做載入、console help/doctor/reload、色碼無外洩、缺檔復位與重啟保留檢查;用隔離資料,不重建既有世界。 +- 對可支援的客戶端自動化先核對工具與版本,再補真實聊天/Dialog 路徑與截圖證據;不把合成 callback、console smoke 或缺少客戶端覆蓋說成真人通過。缺工具不擅自安裝依賴或刪減驗收。 +- 失敗保存最小證據;停止本輪擁有的程序,保留待驗收 JAR 與必要資料,不清除固定 Human 世界。 + +本輪結果:八個選定核心 smoke 與 failed-reload/退出稽核通過,Spigot 1.8.8 聊天及 Paper 1.21.8 原生 Dialog 實際網路回呼/離線補發通過。使用者明確同意 Folia 以最後 STABLE 26.1.2 build 8 替代;26.3 ALPHA 未驗證。現有 mc-pilot 沒有已建立客戶端,也沒有 26.3/1.21.8 Fabric 變體,未安裝依賴;沒有渲染畫面、滑鼠或剪貼簿驗收,26.3 Dialog 玩家路徑仍未驗證。不以此宣稱所有遊戲內與真人門檻通過。 + +所有本輪程序與 port 已釋放;自動核准審查拒絕刪除可重建 `data/`,約 1.70 GiB 仍保留,磁碟清理狀態為 `retained-cleanup-blocked`。未將測試通過等同清理完成;路徑與證據見第三階段摘要。 + +### 第四階段:集中一次的真人外觀驗收 + +優先使用既有固定 Spigot 1.8.8、Paper 26.3、Folia 26.1.2 測服,準備時重新核對其存在、核心 build 與路由;現有 Paper 26.2 做受影響 adapter 的 Agent 複驗,若能力路徑不同再補真人項目。不為本計畫新建或啟動伺服器。 + +交付完整操作清單,綁定新 commit/JAR hash;玩家可集中完成: + +1. 兩帳號分工:A 建立/查看邀請碼並測複製/hover;B 測 claim 的前置拒絕、聊天 cancel 或 Dialog 輸入。 +2. 確認七區塊、玩家聊天靠左、Dialog 置中、無尾端空格/期限冒號、綠紅按鈕;同意/不同意/逾時各一次。 +3. help 只填入不立即執行;不同權限可見列正確;status/stats 與資格通知用詞清楚。 +4. 管理員操作 console help/doctor/reload,檢查 16 色、無裝飾粗體與暗色不可讀問題;玩家專用指令的拒絕正確。 +5. 繁中/英文、有效 reload、失敗保留、正常重啟後設定與資料保留。離線獎勵補發不因顯示改動而重複。 + +三種平台盡量共用同一清單,不要求每個開發 checkpoint 反覆真人測試。新產物尚未經真人核對前,只回報「Agent 驗證完成,待使用者驗收」。 + +## 停止條件與後續 + +- 新增 dependency、實際格式不相容、改資料契約、或平台 API 無法達到已核准 Dialog 置中時,先說明具體限制及替代選項,不默默降低規格。 +- 核心/客戶端不可用、環境邊界不明或已有程序占用時,只暫停相依測試,持續完成可獨立工作;清楚列出未驗證項目,不直接宣布通過。 +- 既有 release Worktree 的相關草案以本任務具體檔案清單複製;其他 dirty/untracked 不納入,不廣泛 stage。 +- 整體驗收後才請使用者核准該版本的 push/PR/merge;發行候選重建、回流 release/main、tag 及發布另行規劃。 + +第一至三階段沿用上述 task Worktree;實際檢查結果及限制見各階段證據。建議下一步依第四階段準備集中真人外觀驗收,先唯讀核對固定測服的核心/JAR/路由,再按明確部署安排更新目標產物及交付操作清單。這輪沒有部署或真人操作,也不需要先合併 release 或進行 remote write。 + +2026-10-18 第四階段準備:固定四台均可被現行管理器發現且已停止,三台主測服選定 +Spigot 1.8.8、Paper 26.3 build 202、Folia 26.1.2 build 8;Paper 26.2 實際為 build 134。 +兩台 Paper 的 hash 已與核心更新紀錄對上,不能再採用建立 metadata 或舊啟動 log 的 build。 +候選 JAR、雙語 messages 及逐台設定提案僅放在本機準備區,沒有部署、啟動、修改帳號或 push。 +既有 B 均已登記,因此全流程重測須先確認資格重設及其資料影響;不是刪除 DB 或世界。 +詳見[完整步驟與部署安排](../testing/command-feedback-human-acceptance.md)及 +[機器可讀 preflight](../testing/evidence/2026-10-18-command-feedback-stage4-preflight.json)。 +下一個可執行項目是停服備份後部署三台與核對當次啟動,再交付集中真人驗收; +Paper 26.2 受影響 adapter 的 Agent 複驗仍未完成,與最新 Folia ALPHA 缺口分別保留。 + +同日後續已取得明確部署/啟動/B reset/Folia 單筆 unlink 授權並完成,詳見 +[部署與啟動證據](../testing/evidence/2026-10-18-command-feedback-stage4-deployment.md)。 +三台目前可進行真人驗收;Spigot 的本台 Java 已核對為 local-8,Paper/Folia 為 local-25。 +Spigot 既有 LuckPerms JSON 寫入限制以不寫該權限的資格測試安排避開,未修復第三方插件。 +下一步是[集中真人清單](../testing/command-feedback-human-acceptance.md),其後核對新資料、還原暫時設定與權限。 +本機文件與測服操作不等於 remote 授權,仍未 push。 + + +## 2026-10-18 真人回饋:分層 help 與權限 Tab + +依使用者批准沿用目前分支修正首頁資訊過量;Agent 測試、三台停服備份/部署/啟動完成。 +沒有重設 B、unlink 或改寫世界。新候選與結果見 +[本輪證據](../testing/evidence/2026-10-18-command-feedback-help-deployment.md), +下一個尚未完成且前置條件已滿足的項目是第四階段真人 help 複驗,接續同一份 +[驗收清單](../testing/command-feedback-human-acceptance.md)。沒有 push 或發布。 + + +## 2026-10-18 Help 框線與固定導航回饋 + +依已批准方案沿用分支加入同列 prefix/標題框線及固定三項導航;停用項目沒有互動事件。 +新候選 `fb303e2` 已完成 Java 8/11 與相關回歸驗證,三台備份部署,沒有 push。 +下一個可開始但尚未完成的項目仍為第四階段真人外觀複驗,先完成 +[本輪六項清單](../testing/command-feedback-human-acceptance.md),之後續未完成流程。 + + +## 2026-10-18 僅 Folia 外觀階段 + +使用者要求先只開 Folia 26.1.2,暫不做詳細流程。已回饋多層選單大致正常; +修正首頁 `/ic help` 為直接唯讀導覽,與管理說明一致,其他操作仍只填入。 +後續前置條件已滿足的下一步是 Folia 首頁 help 點擊及外觀局部複驗,不是啟動其他兩台。 +玩家名稱/紀錄選取議題已保存至專案容器 notes 草案,延後到本分支完成後再開發;無 schema 變更。 + + +## 2026-10-18 框線與父頁返回修正 + +本輪修正近似字寬框線補長與權限篩選後的父頁定位,新增命令沿用共用規則。 +下一步仍僅是 Folia 的框線/第 2 頁返回局部驗收,見最新真人清單;其他兩台不啟動。 +真人通過後再討論詳細測試,玩家導向管理草案仍延後,不混入目前分支。沒有 push。 + + +## 2026-10-18 Folia 局部真人驗收通過 + +使用者確認 `760c51a` 在 Folia 26.1.2 的框線可接受,reload/doctor/storage 返回第 2 頁正常。 +[真人證據](../testing/evidence/2026-10-18-folia-help-partial-human-acceptance.json) 記錄精確範圍; +不推定其他核心或完整第四階段通過,不重做這四項。 +下一個前置條件已滿足的項目為 Folia 剩餘指令面板/基本訊息(首頁點擊、停用按鈕、權限 Tab、 +status/stats、複製及 console),原因是可以沿現有候選繼續驗收且無需變更登記/獎勵資料。 +之後再安排雙語 reload、兩帳號確認/補發/重啟;開始 claim 前需重新核對 B。 +其他兩台仍延後,沒有自動啟動、部署、push 或合併。 + + +## 2026-10-18 Console 與密集資訊排版 + +Console 的逐行 log 標頭、一般回覆每行 prefix、後台 help 去重/標題/文字導航已實作。 +doctor/inspect/離線工具及中英文可見分號拆行,玩家報告只加一次標題 prefix。 +Java 8/11 及 Agent 檢查完成,僅 Folia 部署;下一步為最新清單的 Console 與玩家報告外觀驗收。 +前版局部通過保留,其他未測不推定通過;不啟動其他測服、不混入玩家紀錄導覽草案、不 push。 + + +## 2026-10-29 排版真人驗收與 doctor 翻譯配色討論 + +Folia 的53893c4 Console/玩家報告排版由使用者確認通過,詳見 +[驗收證據](../testing/evidence/2026-10-29-folia-console-player-acceptance.json)。 +不推定完整流程或其他核心通過。下一步先確認健康檢查的語系值與配色提案, +原因是使用者明確要求非布林狀態顏色先討論;未取得此設計決定前不實作配色。 +true綠/false紅是明確偏好,其他狀態、數量與專有名詞保留方式仍是提案。 +此輪只記錄及討論,沒有插件或測服變更、push、merge。 + + +## 2026-10-29 doctor 翻譯配色實作與下一步 + +使用者核准後已沿原分支完成語意值翻譯、配色與回歸,來源 1a83b73。Java 8/11、JAR 與四項新增回歸通過;僅 Folia 備份部署並核對 ready run、13 行翻譯與 log 標頭。330 項中 306 通過、24 MySQL 條件跳過,沒有失敗。 +下一個前置條件已滿足的項目是最新真人清單的 Folia doctor 局部翻譯/顏色驗收;已有候選與保留資料的測服。之後回到第四階段剩餘項目,不推定其他核心或完整流程通過。Git/編譯時間需求另存 notes/build-provenance-draft.md,未改建置機制、未開分支或 Issue,待本分支完成。沒有 push/merge。 + + +## 2026-10-29 doctor 顯示驗收通過與下一步 + +使用者回報 1a83b73 本次更改通過;證據見 ../testing/evidence/2026-10-29-doctor-human-acceptance.json。範圍限 Folia doctor 顯示,未逐項確認英文或其他核心。使用者已停止測服,本輪不重啟、不部署。 +下一個前置條件已具備的驗收項目為第四階段 Folia 剩餘指令面板(首頁點擊/停用、權限 Tab、status/stats 與複製、Console Tab),不需先重設 B 或建立邀請。實際執行前由使用者開啟 Folia 或授權啟動,再核對候選;其他核心及完整兩帳號流程仍待後續。沒有 push/merge。 + + +## 2026-10-30 Folia 指令面板四項通過 + +使用者確認首頁/停用導航、權限與 Tab、status/stats/碼 hover 複製、Console Tab 通過,對應 1a83b73;見 ../testing/evidence/2026-10-30-folia-command-panel-human-acceptance.json。不重做已通過項目。 +下一個前置條件已具備的項目為第四階段雙語與 messages reload(真人清單本日最新章節)。先核對候選、語系政策與備份,再由 Agent 準備暫改 prefix、有效/失敗 reload、完整還原;玩家核對繁英與可見回覆。本輪尚未執行任何設定/伺服器操作。之後仍待兩帳號流程、重啟還原及其他核心驗收,不代表分支完整通過或取得 push/merge 授權。 + + +## 2026-10-30 語系驗收補充與 reload 證據界線 + +使用者確認繁英顯示、Console 預設繁中正常,實際只更改 use-client-locale 並還原。證據見 ../testing/evidence/2026-10-30-folia-locale-human-acceptance.json。prefix 模板未修改,故有效 prefix reload、錯誤型別拒絕保留快照及該情境的 prefix 還原仍未驗證,不算失敗。下一步建議由 Agent 先核對目標與備份,再補這三個案例及完整還原;這輪只有文件記錄,沒有開始操作。其後仍按第四階段安排兩帳號、重啟與其他核心。 + + +## 2026-10-30 reload 補充確認通過 + +使用者確認有效 reload、新回覆及各語言 prefix、use-client-locale true/false,以及錯誤 config 拒絕並保留上一有效快照均正常;先前還原回報保留。見 ../testing/evidence/2026-10-30-folia-reload-human-acceptance.json。這滿足雙語與 reload 真人門檻,不要求重做先前數字 prefix 範例;不宣稱該具體錯誤型別已測。前輪未測判定已由補充證據取代。 +下一步建議為第四階段兩帳號流程準備,第一個動作是唯讀核對候選、B 登記期限/角色/現有邀請與待處理獎勵。核對完成前不要求玩家 claim,也不自動重設/unlink;需資料變更時精確列出另行確認。之後依序做確認互動、資格與離線補發、重啟還原、其他核心驗收。本輪沒有 live server 操作或 remote write。 + + +## 2026-10-30 兩帳號唯讀 preflight 完成 + +依使用者核准完成第 1/3 階段:Folia 實際 JAR 仍為 1a83b73、hash 與核心身份一致,Listening/Managed;設定還原。B 無目前代次邀請/碼/獎勵,但 24h 視窗於 10 月 19 日 14:38 台灣時間已過期。測試資格 false,舊 UNLINKED 不需重做 unlink。來源 ../testing/evidence/2026-10-30-folia-two-account-preflight.json。 +下一步需先核准精確的 B-only reset:備份後僅更新登記起點、generation 1→2、加一稽核,其他歷史/A/碼/獎勵保留;尚未執行。第 2/3 階段為核准後備份與 reset,第 3/3 階段為兩帳號確認及離線補發真人驗收與唯讀資料核對。流程已準備但未就緒,不要求現在 claim;之後仍有重啟還原及其他核心驗收。沒有啟停、部署、資料或 remote write。 + + +## 2026-10-30 B-only reset 核准後完成,待兩帳號真人流程 + +第 2/3 階段完成:使用者先停服並核准;20 檔停止備份與 hash/SQLite quick_check 通過,只啟動 Folia 執行一次 reset。B generation 1→2,登記期限至台灣時間 10 月 31 日 01:47;僅 B 起點/代次及一筆稽核改變,A/碼/歷史/獎勵/設定/key/權限保留。來源 ../testing/evidence/2026-10-30-folia-b-reset-ready.json。 +第 3/3 階段下一步為本日最新真人清單的 1–5:取消、不同意、逾時、最後同意。既有伺服器/候選與測試資格 false 均已備妥;第 5 步回報後由 Agent 先核對資料,再讓管理員設定測試資格 true 並測離線補發。lobby 未開,A 直接斷線代替回 lobby。之後正常重啟保留、還原 ALLOW/測試權限與其他核心仍未完成。本輪沒有真人 claim 或 remote write,沒有 push/merge。 + + +## 2026-10-30 claim 四項 UI 修正與登記完成 + +沿原分支完成候選 5702e91;見 ../testing/evidence/2026-10-30-claim-ux-fixes.json。Java 8/11 check shadowJar、JAR/bytecode 通過,314 pass/24 MySQL skip/0 fail;獨立 review 無具體 High/Critical。修正單一主要 status 理由、17 雙語鍵、輸入框期限邊界與早觸發重排/原子逾時提交。原生客戶端尚未複驗,沒有新 production dependency、schema 或領域資格規則變更。 +使用者報告登記完成,唯讀確認目前 generation 2 一筆 CLAIMED、舊 UNLINKED 保留、獎勵 0;UI 缺陷不混算通過。使用者選先完成既有資格/離線補發,再停服部署;故本輪不動 Human runtime 或 B。下一個前置條件已滿足的是真人清單最新節的資格/離線補發,先由 A 斷線、管理員在約定步驟設測試資格 true。回報後再唯讀核對交付,接停服備份部署/新候選 UI/重啟還原與其他核心。/ic claim 多原因回覆仍列原文待討論,沒有 push/merge。 + + +## 2026-10-30 資格補發驗收與新候選部署完成 + +使用者確認舊候選的資格/離線補發/重入不重複;資料核對一筆 generation 2 QUALIFIED、單一 delivery 與 A/B 兩個 MESSAGE actions 均 DELIVERED,舊 UNLINKED 保留。依已選定順序正常停服、21 檔備份後更新 Folia 到 5702e91,驗證 ready run、doctor/錯誤句、逐表保留;B 測試權限單 node 還原 false,資格與交付不倒退。證據 ../testing/evidence/2026-10-30-claim-ux-folia-deployment.json。其他測服停止,沒有 push/merge。 +下一個前置條件已滿足的項目為本日最新真人清單的 A status/help 錯誤色彩與重啟資料保留局部驗收:候選、核心、入口與既有帳號均已就緒,不需要再 claim。原生輸入框複驗需合資格帳號,A/B 目前皆不符合,先保留缺口,不自行 reset。其後仍需其餘臨時設定還原及其他核心,不能把部署/smoke 當作整個分支真人通過。 + + +## 2026-10-30 5702e91 三項局部真人複驗通過 + +使用者確認 status 主要理由、單句紅色、資料保留皆正常。唯讀重核候選與 JAR、B generation 2 的 QUALIFIED、兩個 DELIVERED 保留。證據 ../testing/evidence/2026-10-30-folia-ux-three-checks-human-acceptance.json。沒有新增 runtime 變更。 +下一項為原生輸入框標籤/60 秒關閉與提示;A/B 現在都不可 claim。第一步需取得合資格帳號:建議先備份,再僅重設 Folia B generation 2→3、起點更新與一筆稽核,保留歷史及獎勵;這是新的資料變更,尚未核准,不沿用上次單次 reset 授權。完整條件及最小清單已列真人文件最新節;不建立新邀請/獎勵。該項通過後仍有其餘暫設還原與其他核心,沒有 push/merge。 + + +## 2026-10-30 輸入框用 B-only reset 已核准並完成 + +正常停服後備份 20 檔並驗 hash/quick_check,只啟動原 Folia 候選 5702e91 執行一次 reset。B generation 2→3、起點更新與一筆稽核,舊 UNLINKED/QUALIFIED 與兩個 DELIVERED 保留;A/碼/設定/key/權限不變,沒有新邀請。期限至台灣時間 10 月 31 日 03:25。證據 ../testing/evidence/2026-10-30-folia-input-dialog-reset-ready.json。 +下一個前置條件已滿足的項目為最新真人清單的輸入框標籤、60 秒自動關閉與紅色提示、格式錯誤及取消:候選、入口與可 claim 的 B 已備妥。只輸入/取消,禁止按同意,不重做獎勵。回報後唯讀核對 generation 3 無新邀請與歷史保留;其後仍需其餘暫設還原與其他核心,沒有 push/merge。 + + +## 2026-10-30 輸入框五項真人複驗通過與下一步 + +使用者確認 5702e91 的標籤、逾時關閉、逾時提示、格式錯誤、取消全通過。唯讀核對 generation 3 無新邀請、舊 UNLINKED/QUALIFIED 及兩個 DELIVERED 保留,B 測試權限 false。證據 ../testing/evidence/2026-10-30-folia-input-dialog-human-acceptance.json。Folia 已安排的本輪真人項目有對應回報;不推定整個分支或其他核心通過。 +下一個前置條件已滿足的工作是 Folia 暫設收尾:先唯讀核對原備份的 qualification profile/matching-ip-action,再備份現況並只還原測試差異,reload 核對。現在仍為測試 PERMISSION/ALLOW,尚未執行還原。之後才盤點與安排 Spigot 1.8.8/Paper 26.3 同一候選的驗收;本輪沒有操作其他測服。最新 Folia ALPHA 與 Paper 26.2 adapter 缺口保留。沒有 push/PR/merge。 + + +## 2026-10-30 Folia 收尾與兩核心準備完成 + +Folia 原備份 hash 核對後,已備份並精確還原 30m+2 日資格與同網路 DENY,reload/doctor/逐表保留通過,正常退出後關閉。Spigot 1.8.8/Paper 26.3 build202 已各備份、部署 5702e91、實際 Java8/25 啟動,指令與無效 reload 原快照保留/原檔還原核對通過。使用者另明確核准兩台 B 各一次 gen1→2 reset,時間/代次/稽核以外資料保留,期限到台灣時間10月31日04:03。證據 ../testing/evidence/2026-10-30-folia-closeout-crosscore-preparation.json。 +下一個前置條件已滿足的項目為 ../testing/command-feedback-crosscore-human-acceptance.md 的兩台真人完整流程;先 Spigot 聊天,再 Paper 原生Dialog。Spigot 既有 LP Gson 寫入限制未修,不能 lp set,A 最後同意前就離線;Paper 登記後 A 離線再由主控台 true 達資格。不要把舊 gen0 已完成邀請算新 gen2結果。回報後資料核對、暫設還原、關閉不用服務及剩餘 gate,再整理交付;沒有 push/PR/merge。 diff --git a/docs/plans/command-feedback-messages-en-US.draft.yml b/docs/plans/command-feedback-messages-en-US.draft.yml new file mode 100644 index 0000000..c173a1d --- /dev/null +++ b/docs/plans/command-feedback-messages-en-US.draft.yml @@ -0,0 +1,138 @@ +# Wording reference applied in stage 2; runtime authority is invitecode-plugin/src/main/resources/config/messages/en_US.yml. +# Do not overwrite existing custom catalogs with this reference. +# The renderer adds the prefix to each complete reply, not to values or UI labels. +messages-version: 1 +presentation: + prefix: "&7[&6InviteCode&7]&r" +runtime: + raw-output: "{text}" + help-row: "&e{usage} &7— &f{description}" + usage: "&cInvalid command usage. &fUse /{label} help for instructions." + no-permission: "&cYou do not have permission to use this command." + player-only: "&eOnly a player can run this command." + unavailable: "&cThis operation is currently unavailable: {detail}" + help-header: "&fCommand help" + help-player-section: "&6Player commands" + help-admin-section: "&6Administration" + help-description: + help: "View command help" + code: "View or create your Invite Code" + claim: "Use someone else's Invite Code" + confirm: "Accept the current invitation confirmation" + cancel: "Cancel code input or confirmation" + status: "View your invitation status" + stats: "View your referral statistics" + inspect-player: "Inspect a player record" + inspect-invitation: "Inspect an invitation" + inspect-reward: "Inspect a reward action" + unlink: "Unlink an invitation" + transfer: "Transfer an invitation" + force-qualify: "Force an invitation to qualify" + reset-eligibility: "Reset a player's claim eligibility" + retry-reward: "Retry a reward action" + mark-delivered: "Mark a reward action as delivered" + rotate-code: "Rotate a player's Invite Code" + migrate-storage: "Update the storage schema" + reload: "Reload configuration and messages" + doctor: "Check runtime and storage health" +command: + code: + value: "&fYour Invite Code: {code}" + copy: "Click to copy to clipboard" + select: "Click to insert into chat, then copy manually" + claim: + command-only: "&fUse /invitecode claim ." + chat-started: |- + &fEnter the Invite Code in chat within {seconds} seconds. It will not be public. + &7Type cancel to stop. + chat-timeout: "&eCode input has expired. &fRun /invitecode claim again." + dialog-title: "Enter Invite Code" + dialog-label: "Six-character Invite Code" + dialog-confirm: "Continue" + dialog-cancel: "Cancel" + dialog-timeout: "&eCode input has expired. &fRun /invitecode claim again." + invalid-code: "&cInvalid Invite Code format. &fCheck the code and enter it again." + unavailable: "&cThis Invite Code does not exist or is no longer active. &fAsk the inviter for their current code." + self: "&cYou cannot use your own Invite Code." + # The renderer adds the prefix as line 1 and the action buttons as line 7. + confirmation: |- + &fConfirm Invite Code + &7Inviter: &f{inviter} + &7Invite Code: {code} + &fUse this Invite Code? + &7Choose within {seconds} seconds + confirmation-title: "Confirm Invite Code" + confirmation-inviter: "&7Inviter: &f{inviter}" + confirmation-code-label: "&7Invite Code: " + confirmation-question: "Use this Invite Code?" + confirmation-prompt: "&7Choose within {seconds} seconds" + agree: "&aAgree" + disagree: "&cDisagree" + agree-hover: "Click to agree and use this Invite Code" + disagree-hover: "Click to disagree and cancel" + confirmation-timeout: "&eInvitation confirmation has expired. &fRun /invitecode claim again." + no-confirmation: "&eThere is no invitation to confirm, or it has expired. &fRun /invitecode claim again." + claimed: |- + &aYour invitation has been registered. + &7View your status: /ic status + matching-network-warning: "&eYou and the inviter recently used the same network. This claim was allowed but may be reviewed by an administrator." + matching-network-denied: "&cServer rules prevent this claim because you and the inviter recently used the same network. &fContact an administrator if you need help." + ineligible: "&cYou cannot use an Invite Code: {reasons}." + reason: + already_inviter: "you have already created your own Invite Code" + already_invitee: "you already have an invitation" + claim_window_expired: "the claim period has ended" + cancelled: "&fInvite Code input or confirmation cancelled." + nothing-to-cancel: "&7There is no active Invite Code input or confirmation." + status: + ineligible-reason: "&7Cannot register: &f{reasons}" + summary: |- + &fMy invitation status + &7Can use an Invite Code: &f{eligible} + &7Invitation: &f{invitation} + &7Pending rewards: &f{pending_rewards} + stats: + summary: |- + &fMy referral statistics + &7Awaiting qualification: &f{claimed} + &7Qualified: &f{qualified} + error: "&cThe operation failed. &fContact an administrator to check the server log." + stopping: "&eThe plugin is stopping and cannot accept operations. &fTry again later." +value: + reason-separator: "; " + 'yes': "yes" + 'no': "no" + invitation: + none: "not registered" + claimed: "awaiting qualification" + qualified: "qualified" + unlinked: "unlinked" +admin: + invitation-unlinked: "&aInvitation {invitation} unlinked." + invitation-transferred: "&aInvitation {invitation} transferred to inviter {inviter}." + invitation-force-qualified: "&aInvitation {invitation} marked as qualified; {rewards} reward delivery records created." + eligibility-reset: "&aClaim eligibility reset for player {player}." + reward-resolved: "&aReward action {action} resolved as {status}." + code-rotated: "&aPlayer {player}'s Invite Code rotated from {previous} to {current}." + error: "&cThe administrative operation failed. &fCheck the server log." + stopping: "&eThe plugin is stopping and cannot accept administrative operations." + reload-stopping: "&eThe plugin is stopping and cannot reload configuration." + reload-success: "&aConfiguration and messages validated and applied." + reload-storage-restart: "&estorage.yml changes were not applied. &fFollow the storage cutover procedure, then restart the server." + reload-failed: "&cReload failed. The previous configuration remains active. &fCheck the server log and fix the configuration." + storage-unsupported: "&cThe migration target must match the configured SQLITE or MYSQL storage backend." + storage-config-unavailable: "&cConfiguration is not loaded, so the storage location is unknown. &fCheck the server log." + storage-stopping: "&eThe plugin is stopping and cannot update the storage schema." + storage-success: "&aStorage schema updated to version {version}." + storage-failed: "&cStorage schema update failed. &fCheck the server log." + doctor-runtime: "&fRuntime: {phase}; configuration generation: {generation}; executor: {executor}." + doctor-integrations: "&fIntegrations: PlaceholderAPI={placeholder}; Vault Economy={vault}; Dialog={dialog}; RGB={rgb}." + doctor-maintenance: "&eMaintenance reason: {reason}" + doctor-storage-offline: "&eStorage is offline. This check did not create or modify data." + doctor-storage: "&fStorage: {backend}; schema: {schema}; reward actions: PENDING={pending}, PROCESSING={processing}, UNCERTAIN={uncertain}." + doctor-storage-failed: "&cThe storage health check failed. &fCheck the server log." + doctor-executor-stopping: "&eThe executor is stopping and cannot query pending reward actions." +invite: + qualified: + inviter: "&aA player you invited has qualified." + invitee: "&aYou have met the invitation qualification requirements." diff --git a/docs/plans/command-feedback-messages-zh-TW.draft.yml b/docs/plans/command-feedback-messages-zh-TW.draft.yml new file mode 100644 index 0000000..b909a03 --- /dev/null +++ b/docs/plans/command-feedback-messages-zh-TW.draft.yml @@ -0,0 +1,139 @@ +# 文案設計參考,第二階段已套用;執行期權威為 invitecode-plugin/src/main/resources/config/messages/zh_TW.yml。 +# 不要直接覆蓋伺服器 messages;已有自訂檔案保留。 +# prefix 自動套用;值、欄位、hover 與按鈕不各自加 prefix。 +messages-version: 1 +presentation: + prefix: "&7[&6InviteCode&7]&r" +runtime: + raw-output: "{text}" + help-row: "&e{usage} &7— &f{description}" + usage: "&c指令用法不正確。&f請使用 /{label} help 查看說明。" + no-permission: "&c你沒有使用此指令的權限。" + player-only: "&e此指令只能由玩家執行。" + unavailable: "&c目前無法執行此操作:{detail}" + help-header: "&f指令說明" + help-player-section: "&6玩家操作" + help-admin-section: "&6管理操作" + help-description: + help: "查看指令說明" + code: "查看或建立自己的邀請碼" + claim: "使用別人的邀請碼" + confirm: "同意目前的邀請確認" + cancel: "取消輸入或確認" + status: "查看自己的邀請狀態" + stats: "查看自己的邀請統計" + inspect-player: "查詢玩家紀錄" + inspect-invitation: "查詢邀請關係" + inspect-reward: "查詢獎勵動作" + unlink: "解除邀請關係" + transfer: "轉移邀請關係" + force-qualify: "強制達成邀請資格" + reset-eligibility: "重設玩家登記資格" + retry-reward: "重試獎勵動作" + mark-delivered: "標記獎勵動作已交付" + rotate-code: "輪替玩家邀請碼" + migrate-storage: "更新儲存結構版本" + reload: "重新載入設定與訊息" + doctor: "檢查執行狀態與儲存健康" +command: + code: + value: "&f你的邀請碼:{code}" + copy: "點擊複製到剪貼簿" + select: "點擊填入聊天列,再手動複製" + claim: + command-only: "&f請使用 /invitecode claim <邀請碼>。" + chat-started: |- + &f請在 {seconds} 秒內於聊天輸入邀請碼,內容不會公開。 + &7輸入 cancel 可取消。 + chat-timeout: "&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。" + dialog-title: "輸入邀請碼" + dialog-label: "六位邀請碼" + dialog-confirm: "繼續" + dialog-cancel: "取消" + dialog-timeout: "&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。" + invalid-code: "&c邀請碼格式不正確。&f請檢查後重新輸入。" + unavailable: "&c這組邀請碼不存在或已失效。&f請向邀請人確認目前的邀請碼。" + self: "&c你不能使用自己的邀請碼。" + # 聊天 renderer 先單獨輸出 prefix,下列為第 2–6 行;互動按鈕為第 7 行。 + # Dialog 以 prefix 為標題,其他欄位使用等價內容。 + confirmation: |- + &f確認邀請碼 + &7邀請人:&f{inviter} + &7邀請碼:{code} + &f是否使用這組邀請碼? + &7請在 {seconds} 秒內選擇 + confirmation-title: "確認邀請碼" + confirmation-inviter: "&7邀請人:&f{inviter}" + confirmation-code-label: "&7邀請碼:" + confirmation-question: "是否使用這組邀請碼?" + confirmation-prompt: "&7請在 {seconds} 秒內選擇" + agree: "&a同意" + disagree: "&c不同意" + agree-hover: "點擊同意並使用邀請碼" + disagree-hover: "點擊不同意並取消" + confirmation-timeout: "&e邀請確認已逾時。&f請重新執行 /invitecode claim。" + no-confirmation: "&e目前沒有可確認的邀請,或確認已逾時。&f請重新執行 /invitecode claim。" + claimed: |- + &a邀請關係已建立。 + &7查看目前狀態:/ic status + matching-network-warning: "&e你與邀請人近期使用相同網路。本次登記已允許,但可能由管理員檢查。" + matching-network-denied: "&c你與邀請人近期使用相同網路,依伺服器規則無法登記。&f如需協助,請聯絡管理員。" + ineligible: "&c目前無法使用邀請碼:{reasons}。" + reason: + already_inviter: "你已建立自己的邀請碼" + already_invitee: "你已有邀請關係" + claim_window_expired: "可登記期間已結束" + cancelled: "&f已取消邀請碼輸入或確認。" + nothing-to-cancel: "&7目前沒有進行中的邀請碼輸入或確認。" + status: + ineligible-reason: "&7無法登記原因:&f{reasons}" + summary: |- + &f我的邀請狀態 + &7可使用邀請碼:&f{eligible} + &7邀請關係:&f{invitation} + &7待補發獎勵:&f{pending_rewards} 筆 + stats: + summary: |- + &f我的邀請統計 + &7等待達成資格:&f{claimed} 人 + &7已達成資格:&f{qualified} 人 + error: "&c操作失敗。&f請聯絡管理員檢查伺服器紀錄。" + stopping: "&e插件正在停止,暫時無法操作。&f請稍後再試。" +value: + reason-separator: "、" + 'yes': "是" + 'no': "否" + invitation: + none: "尚未登記" + claimed: "等待達成資格" + qualified: "已達成資格" + unlinked: "已解除連結" +admin: + invitation-unlinked: "&a已解除邀請關係 {invitation}。" + invitation-transferred: "&a已將邀請關係 {invitation} 轉移至邀請人 {inviter}。" + invitation-force-qualified: "&a已將邀請關係 {invitation} 設為達成資格,並建立 {rewards} 筆獎勵交付紀錄。" + eligibility-reset: "&a已重設玩家 {player} 的邀請碼登記資格。" + reward-resolved: "&a已將獎勵動作 {action} 處理為 {status}。" + code-rotated: "&a玩家 {player} 的邀請碼已由 {previous} 輪替為 {current}。" + error: "&c管理操作失敗。&f請檢查伺服器紀錄。" + stopping: "&e插件正在停止,無法執行管理操作。" + reload-stopping: "&e插件正在停止,無法重新載入設定。" + reload-success: "&a設定與訊息已通過驗證並套用。" + reload-storage-restart: "&estorage.yml 的變更尚未套用。&f請依儲存切換流程操作,再重新啟動伺服器。" + reload-failed: "&c重新載入失敗,仍使用上一份有效設定。&f請檢查伺服器紀錄並修正設定。" + storage-unsupported: "&c遷移目標必須與目前設定的 SQLITE 或 MYSQL 儲存類型相同。" + storage-config-unavailable: "&c設定尚未成功載入,無法判定儲存位置。&f請檢查伺服器紀錄。" + storage-stopping: "&e插件正在停止,無法更新儲存結構。" + storage-success: "&a儲存結構更新完成,目前版本為 {version}。" + storage-failed: "&c儲存結構更新失敗。&f請檢查伺服器紀錄。" + doctor-runtime: "&f執行階段:{phase};設定世代:{generation};executor:{executor}。" + doctor-integrations: "&f整合狀態:PlaceholderAPI={placeholder};Vault Economy={vault};Dialog={dialog};RGB={rgb}。" + doctor-maintenance: "&e維護原因:{reason}" + doctor-storage-offline: "&e儲存尚未連線;本次檢查未建立或修改資料。" + doctor-storage: "&f儲存類型:{backend};結構版本:{schema};獎勵動作:PENDING={pending}、PROCESSING={processing}、UNCERTAIN={uncertain}。" + doctor-storage-failed: "&c儲存健康檢查失敗。&f請檢查伺服器紀錄。" + doctor-executor-stopping: "&eExecutor 正在停止,無法查詢待處理的獎勵動作。" +invite: + qualified: + inviter: "&a你邀請的玩家已達成資格。" + invitee: "&a你已達成邀請資格。" diff --git a/docs/testing/command-feedback-crosscore-human-acceptance.md b/docs/testing/command-feedback-crosscore-human-acceptance.md new file mode 100644 index 0000000..87c8d91 --- /dev/null +++ b/docs/testing/command-feedback-crosscore-human-acceptance.md @@ -0,0 +1,251 @@ +# Spigot 1.8.8/Paper 26.3 真人驗收流程 + +2026-10-30。候選 `5702e91` 已部署兩台並啟動,來源及同一 JAR hash 已核對;沒有更新核心或建立新世界。 +[準備與備份證據](evidence/2026-10-30-folia-closeout-crosscore-preparation.json)。Folia 已還原原資格(30m+2 登入日)與同網路 DENY,核對後正常停止;不用重測 Folia。 + +## 開始前先讀 + +資格代次是每次重開登記資格的批次;不是 SQLite schema 或插件版號。舊紀錄保留,本輪會另外核對新關係。 + +- 兩台各自 B 已核准重設為 generation 2,期限到 **2026-10-31 04:03(台灣時間)**;兩台資料獨立,各測一次,不共用登記結果。 +- A=Command1(已核對為 OP);B=Taiwan_PingLord(非 OP)。B 不用 code;A 每換核心都重取該台碼。 +- 入口都是 localhost:25565,不直連後端。Spigot route 對應 10101/Java 8;Paper route 對應 20102/Java 25。 +- 原生客戶端建議分別用 1.8.8/26.3。Proxy 雖有轉版插件,實際連線仍須真人確認,不將 JAR 存在當成可登入證據。 +- **Spigot:A 必須最後同意前就離線,不可執行 lp permission set。Paper:先登記,A 離線後才設測試資格 true。** +- 同網路目前 ALLOW 是為同機兩帳號測試;qualification profile 也是暫設,測後由 Agent 依各台原備份還原,不手動清空或回灌 DB。 +- 兩台各自保留 generation 0 的 QUALIFIED 與兩個 DELIVERED;這不是本輪新結果。Agent 將核對本輪 generation 2 的新關係,並保留全部歷史。 +- 沒有 push/PR/merge/發布。此文件與入口 port 是準備證據,真人結果仍待回報。 + +## Spigot 1.8.8:完整一輪 + +### 1. 連線與帳號 + +兩個帳號都連 `localhost:25565`,再各自執行 `/server invitecode-spigot-1.8.8`。A=**Command1**,B=**Taiwan_PingLord**。一次只測一台,先 Spigot 再 Paper。 + +使用建議的原生客戶端 `1.8.8`;Proxy 雖有 ViaVersion/ViaBackwards/ViaRewind,實際登入及切服仍由這一步確認。若不成功先回報,**不要直接連後端 10101/20102**。 + +### 2. 先記基準與取這台的碼 + +A 執行 `/ic code`、`/ic status`、`/ic stats`;B 執行 `/ic status`、`/ic stats`。記下碼與統計。**每換一台都重新取碼,不用 Folia 或上一台的碼。B 全程不執行 `/ic code`。** + +B 的「可使用邀請碼」應為是。看到舊「已達資格」紀錄是保留歷史;本輪代次 2 尚無新關係,並非清空舊資料。A `/ic claim` 應直接因已有自己的碼而拒絕,不開輸入介面。 + +### 3. 主控台與權限 Tab + +在**目前這台**的 InstanceHarbor 原生後台輸入以下指令,不加 `/`: + +```text +ic +ic help +ic help admin 2 +ic admin doctor +ic code +``` + +後台首頁只有一個 help 入口;每個邏輯行有核心時間戳/INFO,doctor 與一般回覆每行有 prefix,16 色可讀。PAPI/Vault 未啟用不是故障。`ic code` 應說只能由玩家執行。doctor 顯示 `無原生介面(NONE)`。 + +A 能看管理 help,B 看不到管理入口或管理 Tab。A/B 的 `/ic status `、`/ic stats ` 與超出合法參數的位置按 Tab,不應補出玩家名稱;Console `ic help admin ` 有候選,完整路徑後無多餘補全。 + +### 4. Help、錯誤句與碼互動 + +A `/ic` 點 help 直接開;`/ic help admin 2` 進 reload/doctor/storage 詳細說明後返回應仍是第 2 頁。玩家上一頁/返回/下一頁固定顯示,停用為灰、點擊無動作;Console 用可輸入的導航命令。框線大致對齊,窄聊天視窗或自訂字型可能自然折行。 + +`/ic help not-a-topic` 的錯誤與指引同句紅色;A status 只列主要拒絕原因。碼的互動:點六碼本身應填入聊天列,再手動全選/複製;貼到本機記事本只有原碼。1.8.8 不要求原生剪貼簿動作,顏色為接近的 16 色。**不要按 Enter 把已填入聊天列的碼送到公開聊天。** + +### 5. 繁中/英文 + +A、B 將客戶端語言改 English (US),查看 `/ic help`、`/ic status`、`/ic stats`;A 另看 `/ic admin doctor`。文字與該語系 prefix 正確、沒有缺鍵或色碼外洩,Console 仍用預設繁中。 + +改回繁中再看一次。若客戶端語系暫未同步,先重新登入/切入同一台並記錄;不需要修改 config 或 prefix。 + +### 6. 輸入:取消、逾時、格式錯誤 + +使用聊天輸入,**不是 Dialog**。B `/ic claim` 後在聊天輸入 `cancel`(不加斜線),應私密取消;A 看不到這段輸入。 + +**每次取消、逾時或格式錯誤後,都重新執行 `/ic claim` 才開始下一次輸入。**先取消一次,再重新開啟並等超過 60 秒,應收到紅色輸入逾時提示;重開後輸入 `!`,應是整句紅色格式錯誤。 + +可切英文重開一次看輸入文案/標籤與錯誤,再切回繁中;不用為英文重等一次 60 秒。逾時後請先重新 claim,不要直接把碼送到一般公開聊天。 + +### 7. 確認畫面:不同意 + +B 重開 claim,輸入 **A 在本台的碼**。確認文字靠左,prefix 獨立,邀請人/碼/問題/60 秒期限清楚;綠色同意、紅色不同意可點擊並有 hover。 + +按紅色「不同意」,不建立本輪邀請;B 仍可登記。prefix 不重複、不留尾端空格;期限文字最後不應有冒號。 + +### 8. 確認畫面:逾時 + +B 再開 claim、輸入 A 碼,進入**確認畫面之後**等超過 60 秒。這與輸入階段是兩個不同期限。聊天舊訊息不會被刪掉,但確認已失效,應有紅色提示;再點舊同意也不能登記。 + +再執行 `/ic confirm` 應拒絕,不能建立本輪邀請。若有異常先停下回報,不 reset、不連續送同意。 + +### 9. 最後同意與前置拒絕 + +**先讓 A 退出伺服器,B 才能按最後的綠色同意。**本台用 basic 權限測資格,可能在同意後立即達資格,不能等登記後才讓 A 離線。 + +A 已離線後,B 重開 claim、輸入 A 本台碼,在 60 秒內按同意。只建立一次,隨後應達資格。 + +B 再 `/ic claim` 應立即拒絕,不開輸入介面。**成功同意只做一次**,不要重設、不 unlink、不 retry。舊統計不是本輪新結果,後續由 Agent 核對唯一的 generation 2 新關係。 + +### 10. 資格與離線補發 + +**Spigot 不執行任何 `lp user ... permission set` 指令。**既有 LuckPerms 5.4.145 有 Gson JSON 寫入問題,本輪沒有修它。以既有 `invitecode.command.basic` 資格條件完成測試;若尚未達資格,等例行檢查或讓 B 重新入服,A 繼續離線。 + +若出現 LuckPerms JSON 保存錯誤,保存 log 回報,不自行升級、刪權限檔或套用 Paper 的指令。InviteCode 指令若拋出 exception、資格不符或資料結果異常,停在該步。 + +確認 B 達資格後,A 重新登入,再執行 `/server invitecode-spigot-1.8.8`。應收到離線獎勵;A 再退出/回服一次,不應重複補發。A stats 的已達資格數相對本台基準增加 1。**A 離線是退出遊戲伺服器,不是關掉後台伺服器。** + +### 11. 成功 reload + +所有確認流程結束、獎勵已收到後,在目前後台輸入 `ic reload`,應成功並繼續使用目前設定與語系;查看新回覆的 prefix、文字與色彩。 + +不用人手故意改壞設定。Agent 已在這兩台實測:錯誤布林設定遭拒、原快照保留、原檔逐位元組還原、成功 reload。缺檔復位也已有自動證據,不刪設定重測。 + +### 12. 正常重啟與資料保留 + +先記下 A 碼、A stats、B status,兩人退出。InstanceHarbor **只選目前這台 InviteCode 實例**,按停止,等「已停止」,再啟動並等 Done。不要按全部停止/全部重啟,也不要動 Velocity/Play。 + +兩人回到本台:碼、邀請、資格、統計都保留;不應再次補發。如果不方便操作重啟,可明確回報「重啟待 Agent」,其餘先完成;不要猜測通過。 + +### 13. 回報與關閉不用的測服 + +回覆本台核心、實際客戶端版本及結果:`help/權限Tab/複製/雙語/輸入與確認逾時/不同意與同意/資格補發不重複/reload/重啟保留:通過、失敗或未測`。也可說「全項通過」,有未測就另列。失敗附指令、實際結果與截圖。 + +驗完本台,兩帳號離開後,可在 InstanceHarbor 正常停止本台,再換另一台。Agent 最後唯讀核對新關係/reward actions/audit,並依原備份還原各台暫設;不要回灌舊 DB,也不要手動改測試權限或政策來收尾。 + +## Paper 26.3 build 202:完整一輪 + +### 1. 連線與帳號 + +兩個帳號都連 `localhost:25565`,再各自執行 `/server invitecode-paper-26.3`。A=**Command1**,B=**Taiwan_PingLord**。一次只測一台,先 Spigot 再 Paper。 + +使用建議的原生客戶端 `26.3`;Proxy 雖有 ViaVersion/ViaBackwards/ViaRewind,實際登入及切服仍由這一步確認。若不成功先回報,**不要直接連後端 10101/20102**。 + +### 2. 先記基準與取這台的碼 + +A 執行 `/ic code`、`/ic status`、`/ic stats`;B 執行 `/ic status`、`/ic stats`。記下碼與統計。**每換一台都重新取碼,不用 Folia 或上一台的碼。B 全程不執行 `/ic code`。** + +B 的「可使用邀請碼」應為是。看到舊「已達資格」紀錄是保留歷史;本輪代次 2 尚無新關係,並非清空舊資料。A `/ic claim` 應直接因已有自己的碼而拒絕,不開輸入介面。 + +### 3. 主控台與權限 Tab + +在**目前這台**的 InstanceHarbor 原生後台輸入以下指令,不加 `/`: + +```text +ic +ic help +ic help admin 2 +ic admin doctor +ic code +``` + +後台首頁只有一個 help 入口;每個邏輯行有核心時間戳/INFO,doctor 與一般回覆每行有 prefix,16 色可讀。PAPI/Vault 未啟用不是故障。`ic code` 應說只能由玩家執行。doctor 顯示 `Paper 原生介面(PAPER)`。 + +A 能看管理 help,B 看不到管理入口或管理 Tab。A/B 的 `/ic status `、`/ic stats ` 與超出合法參數的位置按 Tab,不應補出玩家名稱;Console `ic help admin ` 有候選,完整路徑後無多餘補全。 + +### 4. Help、錯誤句與碼互動 + +A `/ic` 點 help 直接開;`/ic help admin 2` 進 reload/doctor/storage 詳細說明後返回應仍是第 2 頁。玩家上一頁/返回/下一頁固定顯示,停用為灰、點擊無動作;Console 用可輸入的導航命令。框線大致對齊,窄聊天視窗或自訂字型可能自然折行。 + +`/ic help not-a-topic` 的錯誤與指引同句紅色;A status 只列主要拒絕原因。碼的互動:將滑鼠移到六碼本身看 hover,點擊後貼到本機記事本,只有原碼、沒有 prefix 或額外文字;支援 RGB 色彩。 + +### 5. 繁中/英文 + +A、B 將客戶端語言改 English (US),查看 `/ic help`、`/ic status`、`/ic stats`;A 另看 `/ic admin doctor`。文字與該語系 prefix 正確、沒有缺鍵或色碼外洩,Console 仍用預設繁中。 + +改回繁中再看一次。若客戶端語系暫未同步,先重新登入/切入同一台並記錄;不需要修改 config 或 prefix。 + +### 6. 輸入:取消、逾時、格式錯誤 + +使用 **AUTO 的原生 Dialog**。B `/ic claim`,標籤應只寫「邀請碼」;按取消應結束。 + +**每次取消、逾時或格式錯誤後,都重新執行 `/ic claim` 才開始下一次輸入。**先取消一次,再重新開啟並等超過 60 秒,應收到紅色輸入逾時提示;重開後輸入 `!`,應是整句紅色格式錯誤。 + +可切英文重開一次看輸入文案/標籤與錯誤,再切回繁中;不用為英文重等一次 60 秒。停在原生輸入框超過 60 秒應自動關閉並提示;關閉後無法再點晚提交,相關延遲競態已有回歸測試。本輪不強制切成 CHAT;聊天路徑在 Spigot 實機驗證,不宣稱 Paper 強制 CHAT 已真人通過。 + +### 7. 確認畫面:不同意 + +B 重開 claim,輸入 **A 在本台的碼**。原生 Dialog 置中,prefix 標題無尾端空格,邀請人/碼/問題/期限清楚,按鈕文字同意綠/不同意紅;按鈕背景沿原生樣式,不要求改底色。 + +按紅色「不同意」,不建立本輪邀請;B 仍可登記。prefix 不重複、不留尾端空格;期限文字最後不應有冒號。 + +### 8. 確認畫面:逾時 + +B 再開 claim、輸入 A 碼,進入**確認畫面之後**等超過 60 秒。這與輸入階段是兩個不同期限。原生確認畫面應關閉並有逾時提示。 + +再執行 `/ic confirm` 應拒絕,不能建立本輪邀請。若有異常先停下回報,不 reset、不連續送同意。 + +### 9. 最後同意與前置拒絕 + +A 此時可留在本台。B 重開 claim,輸入 A 本台碼,在 60 秒內按同意。只登記一次,應先等待資格;**若未觸發測試權限就立即達資格,先停下回報。** + +B 再 `/ic claim` 應立即拒絕,不開輸入介面。**成功同意只做一次**,不要重設、不 unlink、不 retry。舊統計不是本輪新結果,後續由 Agent 核對唯一的 generation 2 新關係。 + +### 10. 資格與離線補發 + +先讓 **A 退出伺服器**,B 留在 Paper,再在 **Paper 主控台**輸入(不要在 Spigot 執行): + +```text +lp user Taiwan_PingLord permission set invitecode.test.qualified true +``` + +等待約 60 秒的資格檢查,或讓 B 重新加入同一台。B 應收到資格通知;**在 B 確認達資格以前,A 保持離線**。本台 test.qualified 目前是 false,這個指令只在此步設一次;Agent 驗收後還原。 + +確認 B 達資格後,A 重新登入,再執行 `/server invitecode-paper-26.3`。應收到離線獎勵;A 再退出/回服一次,不應重複補發。A stats 的已達資格數相對本台基準增加 1。**A 離線是退出遊戲伺服器,不是關掉後台伺服器。** + +### 11. 成功 reload + +所有確認流程結束、獎勵已收到後,在目前後台輸入 `ic reload`,應成功並繼續使用目前設定與語系;查看新回覆的 prefix、文字與色彩。 + +不用人手故意改壞設定。Agent 已在這兩台實測:錯誤布林設定遭拒、原快照保留、原檔逐位元組還原、成功 reload。缺檔復位也已有自動證據,不刪設定重測。 + +### 12. 正常重啟與資料保留 + +先記下 A 碼、A stats、B status,兩人退出。InstanceHarbor **只選目前這台 InviteCode 實例**,按停止,等「已停止」,再啟動並等 Done。不要按全部停止/全部重啟,也不要動 Velocity/Play。 + +兩人回到本台:碼、邀請、資格、統計都保留;不應再次補發。如果不方便操作重啟,可明確回報「重啟待 Agent」,其餘先完成;不要猜測通過。 + +### 13. 回報與關閉不用的測服 + +回覆本台核心、實際客戶端版本及結果:`help/權限Tab/複製/雙語/輸入與確認逾時/不同意與同意/資格補發不重複/reload/重啟保留:通過、失敗或未測`。也可說「全項通過」,有未測就另列。失敗附指令、實際結果與截圖。 + +驗完本台,兩帳號離開後,可在 InstanceHarbor 正常停止本台,再換另一台。Agent 最後唯讀核對新關係/reward actions/audit,並依原備份還原各台暫設;不要回灌舊 DB,也不要手動改測試權限或政策來收尾。 + +## 何時先停下回報 + +無法從入口登入/切服、B 一開始不可登記、出現不是預期的介面、輸入或確認未逾時、格式碼/亂碼外洩、提前達資格、邀請或獎勵重複,均停在該步回報,不自行 reset/unlink/reward retry/mark-delivered。期限過期也回報,不修改 DB。 +若正常關服看到既有 `Terminal has been closed`,保留 log 回報,由 Agent 核對退出與儲存;不在本輪自行做隔離測試或重建伺服器。 + +## 回報範本 + +```text +Spigot 1.8.8(客戶端:____):全項通過/部分通過 +未測:____ +問題:步驟____,預期____,實際____ + +Paper 26.3(客戶端:____):全項通過/部分通過 +未測:____ +問題:步驟____,預期____,實際____ +``` + +Agent 接手核對唯一新邀請與代次、歷史保留、Reward Action 的一次性交付與重啟後狀態,再依原備份還原暫設、關閉不用的測服,整理整體驗收與交付狀態。資料核對、真人通過、push、PR、merge 與發布分開,不以這份清單替代任何 gate。最新 Folia ALPHA/Paper 26.2 adapter 的既有缺口仍另列。 + +## 2026-11-03 Spigot 離線補發複驗 + +使用者確認本輪 B 登記成功、A 回服收到補發、第二次回服無重複。唯讀核對 B 第 4 批次為 QUALIFIED,兩筆獎勵動作均為 DELIVERED。第 0 與第 3 批次的 QUALIFIED 紀錄仍保留。重設登記資格保留歷史,因此 A 的累計已達資格數不會因重設而扣除舊筆數。 + +另記錄 B 的 /ic status 顯示問題:新批次無邀請時,仍可能顯示舊批次的已達資格。待本輪驗收後單獨修正,複驗新批次未登記與建立邀請後的狀態。Paper 真人驗收仍待執行。 + +## 2026-11-03 Paper 26.3 離線補發驗收 + +使用者確認 A 第一次回服收到補發、第二次回服沒有重複,已達成資格數增加 1。觸發測試資格後,B 第 3 批次的唯一新邀請由 CLAIMED 轉為 QUALIFIED;當時 A 的獎勵為 PENDING,B 的獎勵為 DELIVERED。使用者回報後唯讀複查,同一筆邀請下 A、B 各有且只有一筆獎勵動作,兩筆均為 DELIVERED。 + +本節記錄本次離線補發與統計驗收。重啟後資料核對與暫設還原另行收尾。B 的 /ic status 舊批次顯示問題仍待單獨修正與複驗。 + +## 2026-11-03 重啟核對與暫設還原 + +兩台停服後各備份 SQLite、config.yml 和 qualifications.yml 至各自的 .invitecode-backups/crosscore-closeout-f1673dcb。重啟後 SQLite quick_check 通過,邀請、獎勵、邀請碼及稽核逐表比對一致,兩台均正常停止。Spigot 還原同網路 DENY 和 30 分鐘且 2 登入日的資格條件。Paper 的政策和同網路設定與本輪前備份一致,僅將 B 測試權限還原為 false。 + +/ic status 修正後以玩家目前登記批次查詢邀請狀態。回歸場景為先建立邀請、重設資格、檢查尚未登記,再建立本批次邀請並檢查待資格。/ic stats 仍累計歷史邀請。 +整合測試在修正前重現錯誤,修正後隨 check shadowJar 通過,含 Java 8 bytecode 與插件 JAR 檢查。MySQL 條件測試略過。修正版待遊戲內驗收。 + +2026-11-03 隔離 Spigot 1.8.8 協定客戶端複驗通過。IcStatusB 第一次登記顯示「等待達成資格」,主控台重設後顯示「尚未登記」,再次登記後顯示「等待達成資格」。SQLite 保留第 0 與第 1 批次的兩筆邀請。使用專用 Agent 實例、獨立 SQLite 與 loopback port 51947,正常停止並核對退出收據。測試涵蓋玩家收到的聊天文字,未進行圖形畫面驗收。 diff --git a/docs/testing/command-feedback-human-acceptance.md b/docs/testing/command-feedback-human-acceptance.md new file mode 100644 index 0000000..b539f52 --- /dev/null +++ b/docs/testing/command-feedback-human-acceptance.md @@ -0,0 +1,760 @@ +# 訊息與 prefix:第四階段真人驗收 + +## 2026-10-30 Folia 收尾完成;Spigot/Paper 已就緒 + +Folia 已核對原備份並還原 qualification profile(PLAY_TIME 30m 且 LOGIN_DAYS 2)與同網路 DENY, +備份、reload/doctor、逐表保留確認通過,再正常停服。B 測試權限保持已還原 false,不重設、不回灌 DB。 + +Spigot 1.8.8、Paper 26.3 build 202 已備份部署同一 `5702e91` 並啟動,實際 JDK 分別為 8/25; +路由與 legacy forwarding 核對,startup/指令 smoke/錯誤 reload 保留快照與還原均通過。 +使用者已核准兩台各 reset B 一次:generation 1→2、各一筆稽核,舊 QUALIFIED/兩個 DELIVERED、A/碼/世界/key 保留。 +目前兩台各自 generation 2 沒有新邀請,期限至台灣時間 **10 月 31 日 04:03**。 +[準備證據](evidence/2026-10-30-folia-closeout-crosscore-preparation.json)。 + +**現在照 [兩核心完整真人流程](command-feedback-crosscore-human-acceptance.md),一次測一台。** +原生版本建議 Spigot 用 1.8.8、Paper 用 26.3,兩者都走 localhost:25565,再切對應 `/server`。 +Proxy 有 ViaVersion/ViaBackwards/ViaRewind,但尚不以 JAR 存在推定實際轉版可用。 +Spigot 只用聊天;既有 LuckPerms Gson JSON 寫入限制保留,不執行 lp permission set,A 必須最終同意前離線。 +Paper 用原生 Dialog,先登記,再讓 A 離線後由 Paper 後台設 test.qualified true。 +每台碼與資料獨立,不用 Folia 碼;B 不用 code。Folia 已通過項目不重測。 + +真人結果尚未回報,不宣稱兩核心通過。回報後由 Agent 逐台資料核對與暫設還原,再整理後續交付;沒有 push/PR/merge。 +以下保留 Folia 與前輪歷史,兩核心操作以新完整流程為準。 + + +## 2026-10-30 輸入框五項真人複驗通過,Folia 進入收尾 + +使用者明確回報:「標籤/逾時關閉/逾時提示/格式錯誤/取消:通過」。 +候選 `5702e91` 的本輪輸入框複驗已通過,不再要求重做。 +[真人回報與唯讀資料核對](evidence/2026-10-30-folia-input-dialog-human-acceptance.json): +B generation 3 沒有新邀請;generation 0 的 UNLINKED、generation 2 的 QUALIFIED 與兩個 DELIVERED 保留, +測試資格權限仍 false。本輪沒有新 reset、設定或 runtime 變更。 + +結合前輪,Folia 已安排的顯示/help/權限 Tab、雙語與 reload、登記確認、資格與離線補發、 +重入不重複、重啟資料保留,以及本次輸入框檢查都有各自回報與證據;這不推定其他核心或整個分支通過。 + +下一步建議先完成 Folia 的暫設收尾,再準備其他核心,避免同時擴大測試: +1. 從已驗證的原備份核對 qualification profile 與 matching-ip-action 的原值。 + 目前仍是 manual-human-test PERMISSION 與同網路 ALLOW;尚未還原,不猜測或整份覆寫自訂 config。 +2. 先備份現況,只還原約定的測試差異,reload/重新核對,保留 DB/key/世界與所有邀請/獎勵。 + B 測試權限已 false,不需重做;也不重設已完成的帳號資料。 +3. 再盤點既有 Spigot 1.8.8/Paper 26.3 的核心、JAR、設定、資料與路由,提出部署同一候選及分工清單。 + 未經新安排,不自行啟動或部署另外兩台。 + +後續仍有其他核心真人驗收、暫設完整還原、Paper 26.2 adapter 複驗與最新 Folia ALPHA 已知缺口; +不把穩定 Folia 26.1.2 通過等同最新 ALPHA 通過。push/PR/merge/發布都尚未取得本輪授權。 +原生輸入逾時的本輪真人缺口現已補齊。以下保留歷史清單,不代表仍要求重測。 + + +## 2026-10-30 輸入框複驗已準備:B generation 3,僅輸入與取消 + +使用者已核准這次 Folia B-only reset。正常停服/退出 0 與排空確認後,20 檔備份與 hash 通過; +backup DB quick_check=ok,世界保留原處,啟動前標頭一致。JAR/設定/權限未更換。 +啟動後透過插件管理指令僅重設一次,B 起點更新、generation 2 → 3、只新增 1 筆稽核。 +[備份與操作證據](evidence/2026-10-30-folia-input-dialog-reset-ready.json)。 + +目前候選 `5702e91`,Folia 已 Done/Listening、doctor 正常、DB quick_check=ok,入口及路由有效。 +B 的登記期限至 **2026-10-31 03:25(台灣時間)**。generation 0 的 UNLINKED、generation 2 的 QUALIFIED、 +兩筆 DELIVERED 均保留;generation 3 沒有新邀請,沒有任何新獎勵。A 的碼、設定、key 與權限保留。 +測試資格權限維持 false;其他兩台維持停止。本輪未部署新產物,不 push/PR/merge。 + +### 現在只測以下輸入框,不按同意 + +1. B Taiwan_PingLord 連 `localhost:25565`,輸入 `/server invitecode-folia-26.1.2`。 + `/ic status` 的可使用邀請碼應為是;若仍顯示歷史已達資格,那是保留的舊邀請,不代表新代次已登記。 + B 不執行 `/ic code`。 +2. B `/ic claim`:輸入標籤應只有「邀請碼」,不寫六位/6 位。 +3. 停在輸入畫面,不輸入、不按按鈕,等超過 60 秒。應自動關閉並顯示整句紅色逾時提示。 +4. B 再 `/ic claim`,輸入 `!` 並按繼續。應顯示「邀請碼格式不正確,請檢查後重新輸入。」整句紅色。 +5. B 再開 claim,輸入 A 的原碼。到確認畫面後**只按紅色不同意/取消,絕對不要按綠色同意**。 + 不需要重測資格或離線補發,不建立新邀請。A 只在需要時 `/ic code` 提供原碼。 +6. 回覆 `Folia 5702e91:標籤/輸入逾時關閉/逾時提示/格式錯誤/取消:通過、失敗或未測`。 + 由 Agent 唯讀核對 generation 3 仍無新邀請、舊資格與兩筆獎勵保留。 + +自動關閉成功後無法再點擊晚提交;排程稍晚才處理的提交/取消已由自動測試覆蓋,不要求真人製造延遲。 +若 60 秒後未關閉、沒有提示、出現已登記或任何新獎勵,停在該步回報,別 reset/unlink/retry。 +本組通過後仍待其餘臨時設定還原、其他核心驗收及整體交付;先前通過的項目不重做。 +以下是歷史待核准提案,本次已由核准及操作證據取代。 + + +## 2026-10-30 5702e91 三項局部真人複驗通過;輸入框待合資格帳號 + +使用者確認 status 主要原因、同句紅色錯誤、重啟後資料保留三項皆通過,不要求重做。 +[真人回報與唯讀核對](evidence/2026-10-30-folia-ux-three-checks-human-acceptance.json)。 +目前 Folia Listening,來源/JAR hash 仍符合 5702e91;A 有原碼,B generation 2 的 QUALIFIED 保留, +兩個 Reward Actions 仍 DELIVERED。本輪只有唯讀核對與文件更新。 + +下一個尚未完成的項目為新原生輸入框真人複驗;目前 A/B 均會在 claim 前置拒絕。 +建議不增加第三帳號,只在先備份與重新核對後,針對 Folia B 執行新的單次 reset: + +```text +ic admin eligibility reset Taiwan_PingLord claim-input-ui-20261030 +``` + +這次尚未核准/執行。預期 B first_seen_at 更新、generation 2 → 3、新增一筆稽核; +generation 2 的 QUALIFIED、generation 0 的 UNLINKED、原本兩筆 DELIVERED、A/碼/世界/key/設定/權限全部保留。 +本次只開啟 24 小時視窗測輸入框,不建立或同意新邀請,不重跑資格與獎勵。 +若使用者改選既有合資格的第三帳號,可不用重設 B;目前不假設使用者持有第三帳號。 + +核准及準備完成後的最小清單(目前不要開始): +1. B `/ic claim`,確認標籤是「邀請碼」,沒有固定位數。 +2. 停在輸入框等待超過 60 秒,應自動關閉並顯示整句紅色逾時提示。 +3. B 重開輸入框,輸入不合法字元,格式錯誤與重試提示同句紅色。 +4. B 再輸入 A 的碼,進確認畫面後只選不同意/取消,不能同意;不建立新的邀請。 +5. 回覆「標籤/輸入逾時自動關閉/逾時提示/格式錯誤/取消:通過、失敗或未測」。 + Agent 再唯讀核對 generation 3 沒有新關係,舊資格及兩筆獎勵都保留。 + +自動關閉正常後,已關閉視窗無法再點晚提交;排程延遲的晚提交/取消競態已由可控時鐘回歸覆蓋, +不要求真人製造伺服器延遲。完成後仍需其餘暫設還原與其他核心驗收。 +本輪不啟停、不重設、不改權限或資料,不 push/PR/merge。以下為歷史安排。 + + +## 2026-10-30 補發驗收通過;5702e91 已部署 Folia,待介面局部複驗 + +使用者確認資格、離線補發、再次登入不重複均沒有問題。 +[真人驗收與唯讀核對](evidence/2026-10-30-folia-reward-human-acceptance.json):generation 2 唯一邀請 QUALIFIED, +單一 delivery DELIVERED,A/B 各一個 MESSAGE action DELIVERED,舊 UNLINKED 保留。這組不要求重做。 + +依先前選定順序,已正常停服(退出 0、排空)、21 檔備份驗 hash、僅更新 Folia 至候選 `5702e91` 並啟動核對。 +[部署證據](evidence/2026-10-30-claim-ux-folia-deployment.json)/[步驟摘要](evidence/2026-10-30-claim-ux-folia-deployment.md)。 +重啟後邀請/獎勵逐表保留;config/key/世界保留,無新 reset/claim。doctor 與新錯誤句 smoke 通過。 +B 測試權限已由 true 還原為原 false,只有這個 node 改變,既有 QUALIFIED/DELIVERED 不倒退。 +其他兩台維持停止,沒有 push/PR/merge。 + +### 下一輪先做不改資料的介面核對 + +1. A Command1 連 localhost:25565,再 `/server invitecode-folia-26.1.2`。 +2. A `/ic status`:無法登記原因只顯示「你已建立自己的邀請碼」,不另列期限已結束。 + 不保證窄聊天視窗或自訂字型完全不折行,但程式不再插入第二原因行。 +3. 玩家或主控台執行 `ic help not-a-topic`(玩家加 `/`):錯誤與重試指引是同句紅色。 + 切英文重做可一併檢查雙語,不需要改 config。 +4. A `/ic stats`、B `/ic status` 確認重啟後本輪結果仍在,沒有再次補發。這是保留核對,不重做資格/claim。 +5. 回覆 `Folia 5702e91:status 主要原因/單句紅色/資料保留:通過、失敗或未測`。 + +新原生輸入框還需真人確認標籤為「邀請碼」、60 秒自動關閉及提示、晚提交/取消回覆。 +目前 A 有自己的碼、B 已登記,兩者都會在 `/ic claim` 前置拒絕;不要用它們重跑輸入框,也不要自行 reset/unlink。 +合資格測試帳號的準備另行安排;本次未因補發通過而擅自再重設 B。 +新候選真人外觀尚未通過。其後還有暫設 qualification profile/同網路 ALLOW 還原與其他核心驗收; +本次 Agent 正常重啟及 DB 保留證據不替代新畫面人眼驗收。 +以下為歷史未部署安排,以本節為準。 + + +## 2026-10-30 登記核對通過;四項介面修正候選尚未部署 + +B 已回報「登記完成」。[真人回報與唯讀核對](evidence/2026-10-30-folia-claim-human-acceptance.json) 確認 A→B 只有一筆 +目前 generation 2 的 CLAIMED,舊 UNLINKED 保留,沒有獎勵動作。這是登記資料核對通過;使用者指出的四項 UI 缺陷另行修正,不能當成新候選已通過。 + +修正候選 `5702e91` 已完成:status 單一主要原因、17 個雙語文案鍵(錯誤+重試指引單句紅/邀請碼標籤不綁定位數)、 +到期即關閉/提示、提早 tick 重排與逾時提交原子判定。Java 8/11 完整檢查通過,338 項中 314 通過、24 MySQL 條件跳過,0 失敗/錯誤。 +[完整變更與測試證據](evidence/2026-10-30-claim-ux-fixes.json)/[文案前後與討論項](evidence/2026-10-30-claim-ux-fixes.md)。 + +使用者已選定:**先以 Folia 現有 `1a83b73` 完成資格/離線補發,再停服更新新候選。** +Folia 本輪未部署、啟停、改設定/權限或 DB;不重設 B,不重做 claim。新輸入框真人複驗留待合適帳號/後續安排。 +目前下一步就是下方原步驟 6–7: + +1. A Command1 先退出伺服器;B Taiwan_PingLord 留在 Folia。 +2. Folia 主控台輸入(不加斜線): + + ```text + lp user Taiwan_PingLord permission set invitecode.test.qualified true + ``` + +3. 等約 60 秒的資格檢查,或 B 退出/再切入 Folia。B 應收到資格通知。 +4. A 重新登入並 `/server invitecode-folia-26.1.2`,檢查離線獎勵,再退出/加入一次,不重複。 +5. 回覆「資格/離線補發/再次登入不重複:通過、失敗或未測」。由 Agent 唯讀核對交付,再處理還原及停服部署。 + +若已提前達資格或出現非預期獎勵,先回報,不自行 retry/mark-delivered/reset。 +之後仍需新候選外觀、正常重啟保留、臨時設定/權限還原及其他核心驗收。沒有 push/PR/merge。 +以下為既有登記準備與歷史紀錄。 + + +## 2026-10-30 兩帳號流程已就緒:先做到「同意登記」再回報 + +使用者已明確核准備份及 B-only reset,並先停止測服。Agent 核對正常退出/排空、程序與 port 釋放, +在管理鎖內備份 20 個檔案並逐一驗 hash,backup DB quick_check=ok;世界在原處保留,啟動前標頭未變。 +僅啟動 Folia,使用插件管理指令執行一次 B reset,沒有直接修改 SQL。 +[備份、重設及 runtime 證據](evidence/2026-10-30-folia-b-reset-ready.json)。 + +B Taiwan_PingLord:generation 1 → 2,first_seen_at 更新,新增 1 筆 ELIGIBILITY_RESET 稽核; +新登記期限至 **2026-10-31 01:47(台灣時間)**。A、原碼、舊 UNLINKED 邀請、獎勵均保留, +其他資料表核對無額外變化;設定、key 與權限逐位元組保留。沒有 unlink、輪替碼或代玩家 claim。 +Folia 已到 Done/Listening,doctor 正常,資格權限 false,沒有啟動錯誤;另外兩台 InviteCode 測服仍停止。 +同網路 ALLOW 保留以支援同機兩帳號;待本輪結束還原原 DENY,不在流程中途關閉。 + +### 現在先做 1–5,完成後回覆「登記完成」 + +候選 `1a83b73`,只測 Folia 26.1.2。A=Command1(邀請人);B=Taiwan_PingLord(受邀人)。 +兩人先連 `localhost:25565`,各輸入 `/server invitecode-folia-26.1.2`。 +入口與 Play fallback 有監聽,Folia 路由已核對;lobby 沒開,本輪離線步驟直接退出伺服器,不依賴 lobby。 + +1. **A:**`/ic code` 取得原邀請碼。**B:**`/ic status` 確認可登記;不要執行 `/ic code`。 +2. **B:**`/ic claim` 後在原生輸入框按取消。再看 status,仍可登記;沒有新關係。 +3. **B:**重開 `/ic claim`,輸入 A 的碼,進入確認畫面後按「不同意」。仍可登記。 +4. **B:**再進確認畫面,等超過 60 秒才按同意,或用 `/ic confirm` 確認已逾時。 + 預期過期拒絕、沒有登記。這 60 秒從進入確認畫面開始,不是等待輸入的畫面。 +5. **B:**最後重開 claim、輸入 A 碼,在期限內同意。預期只成功一次,status 顯示等待資格。 + 再 `/ic claim` 應立即拒絕、不開輸入框。回覆「登記完成」,先由 Agent 唯讀核對唯一新關係、generation 2 與舊資料。 + +步驟 2–5 看畫面:Dialog 置中、prefix 獨立且無尾端空格;同意綠/不同意紅,期限最後無冒號。 +原生框正常時不強制切聊天模式;舊版 cancel 在 Spigot 另驗。 +若 B 一開始不可登記、提前達資格、出現非預期獎勵或新錯誤,停在該步回報,不重設、不重送。 +期限到期也先回報,不自行繞過期限。 + +### Agent 核對第 5 步後,再做 6–7 + +6. **A:**退出伺服器,確保在 Folia 離線。**B:**留在 Folia。 + **Folia 主控台(不加斜線):** + + ```text + lp user Taiwan_PingLord permission set invitecode.test.qualified true + ``` + + 這是後續真人測試時由管理員執行的資格變更,目前 Agent 尚未設定 true。 + 等資格檢查約 60 秒,或 B 退出再加入 Folia;B 應收到資格通知。 +7. **A:**重新登入並切回 Folia,應補發離線獎勵;再退出/加入,不應重複補發。 + A `/ic stats` 應有本輪的新達資格邀請。回報後由 Agent 核對獎勵交付,最後將 B 測試權限還原原本 false。 + +回覆 `Folia 1a83b73:取消/不同意/逾時/同意/資格/離線補發/再次登入不重複:通過、失敗或未測`, +若失敗附指令、實際結果與截圖,不貼 key 或網路資料。 +第 2/3 階段準備完成、第 3/3 階段真人流程待驗收;本組之後仍需正常重啟保留、臨時設定/權限還原及其他核心驗收。 +沒有 push/PR/merge。下方為歷史未就緒提案,目前已由本節備份與操作證據取代。 + + +## 2026-10-30 兩帳號準備:唯讀核對完成,B 期限已過 + +候選仍為 `1a83b73`,Folia 26.1.2 stable build 8 的核心 hash 與前次核對一致,port 30101、 +已登記 Velocity 路由。當次管理器顯示 Listening/Managed;未啟停、未部署。 +[唯讀 preflight](evidence/2026-10-30-folia-two-account-preflight.json) 是本次準備的狀態來源。 + +B Taiwan_PingLord 的 generation 為 1,登記期限已於台灣時間 2026-10-19 14:38 到期。 +目前沒有有效邀請碼、目前代次邀請或獎勵動作;舊 generation 0 的 UNLINKED 邀請保留。 +線上與持久化的 `invitecode.test.qualified` 均為 false,適合先登記再手動達資格。 +同網路測試仍為 ALLOW;default zh_TW/use-client-locale true,確認與聊天輸入期限各 60 秒。 +A Command1 的有效碼保留。沒有新邀請或獎勵由 Agent 建立。 + +### 尚待核准的精確操作 + +先以一致性 SQLite 備份與設定/key/權限快照保存現況,重新核對 B 的狀態及在線人數後, +僅對這台 Folia 執行一次: + +```text +ic admin eligibility reset Taiwan_PingLord command-feedback-human-20261030 +``` + +預期只更新 B 的登記起點至執行當下、generation 1 → 2,以及新增 1 筆稽核; +重新開啟原設定的 24 小時登記視窗。A、碼、舊邀請、獎勵、世界、設定與權限不變。 +不需 unlink,不直接編輯 SQL、不回灌舊 DB;結果不明時先核對,不重送。 +這個資料變更尚未取得本次精確授權,尚未執行;現在不要開始 claim。 + +### 重設完成並核對後使用的簡單清單(目前未就緒) + +只測 Folia,不重做已通過的 help/語系/reload。A、B 經 localhost:25565,輸入 +`/server invitecode-folia-26.1.2`;A 是 Command1,B 是 Taiwan_PingLord。 + +1. A `/ic code` 查看原碼;B `/ic status` 應可登記。B 不執行 `/ic code`。 +2. B `/ic claim` 後取消輸入,應不建立關係。 +3. B 重開 claim,輸入 A 的碼,在確認畫面按不同意,應仍可登記。 +4. B 再次進入確認畫面,等超過 60 秒再同意,應拒絕過期操作,沒有登記。 +5. B 最後重做並在期限內同意,應只建立一筆新關係,等待資格;再 claim 應立即拒絕。 + 回報「登記完成」後先由 Agent 唯讀核對新關係/generation/舊資料保留。 +6. A 先退出伺服器(不依賴 lobby 開服),B 留在 Folia。管理員在約定步驟用後台 + `lp user Taiwan_PingLord permission set invitecode.test.qualified true` 達成測試資格。 + 這是後續測試權限操作,尚未由 Agent 執行;記錄並在最後還原目前 false。 +7. 等待資格檢查,或讓 B 重新進入 Folia。B 應達資格;A 回服收到離線獎勵,再退出/回服不重複。 + 由 Agent 唯讀核對每筆交付狀態,不能只靠聊天畫面推定一次性正確。 + +畫面預期:Dialog 置中、prefix 獨立且無尾端空格;同意綠/不同意紅,期限末尾無冒號。 +AUTO 使用原生介面時不要求本輪重測舊版聊天 cancel;該路徑隨 Spigot 版本另驗。 +已登記、視窗到期、原生介面失敗或出現非預期獎勵時停在該步回報,不連續重試或 reset。 +回覆 `Folia 1a83b73:取消/不同意/逾時/同意/資格/離線補發/再次登入不重複:通過、失敗或未測`。 +通過後仍待正常重啟保留、臨時設定還原與其他核心;沒有 push/PR/merge。 +以下為歷史驗收安排,以本輪 preflight 的未就緒狀態為準。 + + +## 2026-10-30 最新確認:雙語與 reload 真人驗收通過 + +使用者補充確認:reload 後回覆即生效,各語言 prefix 正確;`use-client-locale` 的 true/false 都測過並正確套用。 +其後刻意改壞 config,reload 明確拒絕並保留上一份有效設定,沒有回落到預設 true。 +結合先前已還原設定的回報,記錄雙語/有效 reload/失敗保留與還原這組真人驗收通過。 +[完整回報](evidence/2026-10-30-folia-reload-human-acceptance.json) 取代前輪因資訊不足保留的未測判定。 +使用者的錯誤案例是 config 語系設定,不宣稱測過數字 prefix;不要求為重做文件範例再破壞設定。 + +下一步為第四階段兩帳號流程的準備:先由 Agent 唯讀核對 Folia 候選、設定、B 的登記期限/角色/既有邀請及獎勵。 +如果 B 仍符合條件,再交付 A/B 的簡單步驟,依序測取消、不同意、逾時、最後同意,再測資格與離線只補發一次。 +如需額外重設資格或解除關係,先列精確變更與保留資料,不擅自套用舊的單次授權。 +之後安排正常重啟保留、臨時設定還原及其他核心驗收;Folia 本輪通過不推定其他核心通過。 +本輪只記錄文件,沒有核對或改動 live server、設定、DB、世界;沒有 push/PR/merge。 +以下為歷史判定,以本次補充回報為準;已通過項目不重做。 + + +## 2026-10-30 歷史補充:當時 reload 案例資訊不足(已由上方回報補齊) + +使用者回報四項通過,並補充實際僅改動 `config.yml` 的 `use-client-locale`,其後已還原; +Console 跟隨預設繁中正常。據此記錄繁英顯示、Console 預設語系、語系設定切換及還原通過。 +[完整回報與證據界線](evidence/2026-10-30-folia-locale-human-acceptance.json)。 +當時僅已知 use-client-locale 改動與還原,尚未收到錯誤設定測試細節,故暫保留 reload 案例;此判定已由最新回報取代。 + +下一步建議由 Agent 核對並備份後,補以下一組設定驗證,避免使用者手動修改錯誤設定: +1. 暫改繁中 `presentation.prefix` 為 `[IC TEST]`,執行 `ic reload`,核對新回覆立即使用新值。 +2. 暫改同鍵為數字 `123`,reload 應拒絕,新回覆繼續使用上一步有效值。 +3. 無論驗證結果如何都還原原檔,再 reload 確認原 prefix 正常;保留結果與最小證據。 +此組尚未執行;準備前需核對目標狀態與候選,不假設伺服器目前已啟動。 +不改 DB、key、邀請關係或 B 資格,不要求重做已通過的語系與指令面板。 +之後仍待兩帳號流程、重啟保留/臨時設定還原及其他核心驗收。 +本輪僅更新本機文件,沒有設定、測服或 remote 操作。以下為歷史安排。 + + +## 2026-10-30 最新真人回報:Folia 指令面板四項通過 + +使用者確認前輪列出的四項皆已測試,基本沒有問題。對應產品候選 `1a83b73`, +記錄為首頁 help/停用導航、A/B 權限與 Tab、status/stats/邀請碼 hover 與複製、Console Tab 通過。 +[真人回報](evidence/2026-10-30-folia-command-panel-human-acceptance.json)。既有 doctor、報告排版與框線驗收保留,不重做。 +本輪只更新證據與計畫;沒有啟停、部署、修改測服設定或資料,未重新確認目前執行狀態。 + +下一個前置條件已滿足的項目為第四階段「雙語與 messages reload」: + +1. A、B 將客戶端改 English (US),執行 `/ic help`、`/ic status`、`/ic stats`;A 另看 `/ic help admin` 與 `/ic admin doctor`。 + 確認英文完整、prefix 一致、無缺鍵/色碼外洩,再改回繁中重做。 +2. Agent 先核對候選與設定、備份繁中 messages,再暫改 `presentation.prefix` 為字串 `[IC TEST]`。 + Console `ic reload` 後,玩家及 Console 的新回覆應使用新 prefix,且不重複。 +3. Agent 將同一 prefix 暫改為數字 `123`,Console `ic reload` 應明確拒絕;新回覆仍用上一步有效的 `[IC TEST]`,不可半套更新。 +4. Agent 立即恢復原始檔案並執行 `ic reload`;確認成功且回復原 prefix。設定備份/暫改/還原由 Agent 準備,尚未執行。 + +回覆方式:`Folia 1a83b73:英文/繁中/reload 生效/錯誤設定保留/還原:通過、失敗或未測`。 +不要求刪除檔案,缺檔復位已有 Agent 證據;不修改 storage、DB、key 或重設 B。 +本組完成後才安排兩帳號確認/資格/離線補發/重啟,開始前重核 B 的資格與現有關係。 +其他核心保持未驗收,待 Folia 完整流程通過後再部署同一候選並安排驗收。沒有 push/PR/merge。 +以下為歷史紀錄;舊的「待驗收」以本節與對應證據為準。 + + +## 2026-10-29 最新真人回報:doctor 顯示通過,測服已由使用者停止 + +使用者確認候選 `1a83b73` 本次更改可算通過,記錄為 Folia 健康檢查顯示驗收通過。 +[原始回報與範圍](evidence/2026-10-29-doctor-human-acceptance.json)。未逐項確認英文語系、正數獎勵顏色, +不推定其他核心或完整第四階段通過。使用者另回報已停止伺服器;本輪不啟動、不部署、不改資料。 + +下一輪先只安排 Folia 的剩餘指令面板驗收(下方「剩餘驗收」第 1–4 項): +首頁 help 點擊/停用按鈕、A/B 權限與 Tab、status/stats/邀請碼 hover 與複製、Console Tab。 +已通過的 doctor 顯示、Console/玩家報告排版、框線及第 2 頁返回不要求重做。 +B 僅測一般權限與 status/stats,不執行 code 或 claim;不修改登記資格與邀請歷史。 +之後才安排 messages reload/雙語與兩帳號完整流程;涉及設定、重啟或 B 資格準備時另依既有授權核對, +不可憑舊準備紀錄假設仍可登記。Folia 完整通過後才安排其他核心。 +以下為歷史候選清單,不代表目前仍待 doctor 顯示驗收或測服仍在執行。 + + +## 2026-10-29 健康檢查候選:Agent 驗證完成,待局部真人驗收 + +來源 `1a83b73`。僅更新並啟動 Folia 26.1.2;Paper/Spigot 維持停止。 +[Agent 證據](evidence/2026-10-29-doctor-localization.json) 保留 hash、run、備份及檢查結果。 +既有世界與資料保留。前版 Console/玩家報告排版驗收仍有效;本次複驗新翻譯與配色。 + +1. 主控台輸入 `ic admin doctor`:每行有時間戳、INFO、prefix;一般欄位與狀態使用繁中,專有名詞保留。 +2. A 帳號連線 `localhost:25565`,輸入 `/server invitecode-folia-26.1.2`,再輸入 `/ic admin doctor`。 + 不需要 B 帳號,不執行 claim/reset/unlink。玩家標題 prefix 一次,後續一行一欄。 +3. 檢查「運作中」「接受新工作」「支援」為綠;「未啟用」「不可用」為紅;三項獎勵數量 0 為灰。 + 選配整合不可用不等於故障。健康檢查不應露出 ACTIVE/ACCEPTING 或布林原碼。 +4. 將客戶端語言切英文後重跑,應顯示英文欄位及語意狀態;改回繁中後重跑確認。若設定關閉客戶端語系,應跟隨預設語言。 +5. 回覆「Folia 1a83b73:Console 翻譯/玩家翻譯/布林色/零值/雙語:通過、失敗或未測」,失敗附截圖。 + +目前固定測服的三項獎勵數量皆為 0;正數待執行黃、執行中青、結果待確認金已由測試 fixture 驗證, +不為外觀製造獎勵或故障資料。畫面尚未真人通過;其他核心與完整兩帳號流程仍另行安排。 +Velocity 現行路由指向 30101,入口有監聽;fallback Play 20401 有監聽、lobby 10001 未監聽, +未變更共用服務或路由。設定及 port 不代替客戶端切服驗收。 + +Git commit/編譯時間目前未嵌入 JAR;已記錄容器 notes/build-provenance-draft.md,待本分支完成後另行評估。 +完成本次局部驗收後,依第四階段清單補尚未通過的 help/權限 Tab、雙語 reload 與兩帳號流程;開始 claim 前重核 B 資格。 +沒有 push。以下為歷史紀錄,不代表目前仍在討論階段。 + + + + +## 2026-10-29 歷史回報:Console/玩家報告排版通過,當時 doctor 翻譯配色待討論 + +使用者確認目前交付的 `53893c4` 在 Folia:Console 通過、玩家報告通過。 +[驗收與後續要求](evidence/2026-10-29-folia-console-player-acceptance.json) 及 +[使用者截圖](evidence/2026-10-29-folia-doctor-localization-feedback.png) 已保存。 +本次通過範圍為排版,不推定英文語系、其他核心、完整互動/獎勵/重啟或整個分支通過。 +不重做已通過排版。新增 doctor 的翻譯/配色要求另列:true 綠、false 紅;其他顏色先討論。 +本輪只記錄與提案,不修改插件、建置、部署或啟停,沒有 push/merge。 + +建議下一步是確認 doctor 的狀態翻譯與配色語意,再沿目前分支實作及局部複驗。 +語系建議沿 config 的既有選擇規則(use-client-locale 啟用時玩家用客戶端語系,否則預設語系;Console 用預設), +不趁此更改語系選擇或資料庫。詳細提案見同一 HTML 的 help-update;尚非定稿規格。 + + +## 最新待驗收:Console 逐行與報告排版(只測 Folia) + +候選 `53893c475fdeaf631ca5b174493f33754660e0ad`,SHA-256 `6E7EB72D59896AF141FE17029FDAD5A0322EADA7F019929F5E78D11C20C8664E`。只更新 Folia 26.1.2;另兩台保持停止。 +前版 `760c51a` 的框線與返回第 2 頁通過紀錄保留,但不推定新版 Console/報告外觀已通過。 + +1. 打開 Folia 原生後台,輸入 `ic`:只有一個 help 入口,沒有重複 help admin。 +2. 輸入 `ic help`、`ic help admin 2`、`ic help admin reload`:索引標示後台用途。 + 每行都有核心產生的時間戳/INFO;頁尾只列可輸入的有效導航命令,不再模仿按鈕或顯示停用項目。 +3. 輸入 `ic admin doctor`:標題與狀態逐欄,每行都有時間戳/INFO 及一次 prefix; + backend、schema、各獎勵狀態不再擠在同一行。沒有分號或色碼外洩。 +4. 輸入 `ic admin inspect player Command1`:逐欄顯示,名稱與 UUID、布林狀態容易辨認。 + 不需查詢其他私人玩家;Invitation/Reward Action 的模板已有回歸檢查,可待後續方便取得 ID 再看外觀。 +5. A 經 localhost:25565 與 `/server invitecode-folia-26.1.2`,輸入 `/ic admin doctor`、 + `/ic admin inspect player Command1`:每份報告只有頂端標題加一次 prefix,其餘逐欄。 + 玩家 help 固定三按鈕、停用無反應、首頁 help 直接開啟與第 2 頁返回仍正常。 +6. 若方便,切 English (US) 重做 help/doctor,確認雙語與 prefix;最後回覆 + `Folia 53893c4:每行時間戳、後台 help 去重、文字導航、doctor、inspect、玩家 prefix、雙語:通過/失敗/未測`。 + 失敗附指令與截圖,不貼 DB、key 或原始網路資料。 + +只測顯示,不執行 reset/unlink/retry/migration,也不用現在重跑雙帳號登記。未測項目保持未測。 +測完仍待完整訊息/互動驗收與臨時設定還原,沒有 push/PR/merge 授權。 +離線匿名化/跨 backend 工具只有輸出格式調整,測試用隔離資料已驗證,不在 Human DB 執行。 + + +## 已通過:Folia 框線與第 2 頁返回(局部真人驗收) + +2026-10-18 使用者明確回報候選 `760c51a` 在 Folia 26.1.2:框線顯示可接受, +reload、doctor、storage 返回管理員第 2 頁均正常。這四項已通過,不要求重做。 +客戶端版本/資源包未回報,不推定其他字型或核心也通過。完整證據: +[真人回報紀錄](evidence/2026-10-18-folia-help-partial-human-acceptance.json)。 +這是局部驗收,沒有推定首頁點擊、其他 UI、整個第四階段或合併已通過。 + +## 剩餘驗收:先 Folia,再安排其他核心 + +目前仍只使用 Folia;本輪只更新文件,不啟停、部署、改設定或改資料。 +以下沒有明確真人回報的項目保持待確認,不把 Agent 測試當作人眼驗收。 + +| 順序 | 項目 | 簡單操作與預期 | 執行者 | +| --- | --- | --- | --- | +| 1 | 首頁點擊與停用按鈕 | `/ic` 點 help 直接開說明;其他操作只填入。點深灰導航無反應,黃色可用 | A | +| 2 | 權限與 Tab | A 看管理分類;B 不見管理入口/管理 Tab。`/ic status `、`/ic stats ` 與多餘參數的 Tab 不冒玩家名 | A、B | +| 3 | status/stats 與邀請碼 | `/ic status`、`/ic stats` 的 prefix 一次、無亂碼。A `/ic code`,六碼 hover 清楚、複製只有原碼;B 不執行 code | A、B | +| 4 | Console 外觀與 Tab | `ic help admin`、`ic help admin 2`,文字及 16 色可讀;`ic help admin ` Tab 有候選,完成路徑 Tab 無玩家名 | Console | +| 5 | 雙語與 messages reload | 切英文/繁中,help/status/stats 完整。備份後暫改 prefix、reload 生效;錯誤型別 reload 失敗保留舊快照,恢復後 reload | A、B、管理員 | +| 6 | Claim 與確認畫面 | 先核對 B 仍可登記;輸入取消、不同意、60 秒逾時、最後同意;Dialog/聊天 prefix、綠紅按鈕與文字位置正確 | A、B | +| 7 | 資格與離線補發 | A 回 Lobby,B 達資格;A 回服只補發一次,再進不重複。由 Agent 核對新關係與獎勵,不只看畫面 | A、B、Agent | +| 8 | 重啟與還原 | 正常關服再開,碼/status/stats 保留、不重複補發;Agent 還原本輪臨時設定與權限,不回灌舊 DB | 管理員、Agent | + +建議下一步只做第 1–4 項,先完成 Folia 指令面板與基本訊息;不用立即做雙帳號 claim 全流程。 +第 1、3、4 項主要可先用 A 與主控台;第 2 項需要 B 的一般權限視角。 +兩帳號流程前必須重新唯讀核對 B 的登記視窗、generation、目前邀請與資格設定; +不能因舊文件曾準備完成就直接假設今天仍可開始,不自動重設或 unlink。 +第 5–8 項沿用下方 12 步完整清單;有先前操作成果則先核對,不盲目重做已完成的登記/補發。 + +Folia 尚未完整通過前,不自動啟動其他兩台。之後 Spigot 1.8.8/Paper 26.3 +須先部署同一驗收候選,再驗證舊版聊天/新版 Dialog、權限 Tab、雙語與 console; +本輪 Folia 通過項目不能直接算作它們通過。Paper 26.2 adapter 的 Agent 複驗及最新 Folia ALPHA 缺口另列。 +玩家名稱導向管理草案仍延後,關服 JLine 問題仍暫緩,不列為本輪要求真人重現的測項。 + +回報方式:`Folia 760c51a:首頁/停用按鈕/權限 Tab/status-stats/複製/console:通過、失敗或未測`。 +失敗附指令、實際結果與截圖。全部相關驗收完成後才整理還原與交付;push/PR/merge 尚未授權。 + +## 前輪操作與部署紀錄(保留歷史,以下待驗收敘述以最上方狀態為準) + +## 最新局部複驗:Folia 框線長度與返回頁 + +候選 `760c51a8b3ae50e172cda8218f62aa5c8b4b9de7`,JAR SHA-256 `D2669D283F5ACD0FB7AB1A9B45C398371E88EE9B0B1795A29DCCB429E1A3A012`。只更新 Folia 26.1.2,其他兩台保持停止。 +本輪沒有更改 messages、資料庫結構、帳號資格或邀請歷史;框線補長與返回頁由共用 renderer/help 樹決定。 + +1. 經 `localhost:25565`,輸入 `/server invitecode-folia-26.1.2`,使用管理員帳號。 +2. 輸入 `/ic`、`/ic help admin`、`/ic help admin 2`,比較標題線與底線右端,應比前版接近。 + 預設字型只有近似估算;請記錄客戶端版本、字型/資源包及聊天視窗大小,必要時附截圖。 +3. 在管理員第 2 頁點 reload 或 doctor 詳細說明,再按返回,應回 2/2,不能回 1/2。 +4. 第 2 頁點 storage,再進 migrate 詳細說明,按返回先回 storage,再返回管理索引 2/2。 + **只瀏覽 help,不執行 migrate/reload 等操作。** 管理索引本身返回 `/ic` 首頁。 +5. 首頁點 `/ic help` 應仍直接開啟;固定三項導航、停用無反應與權限規則保留。 +6. 回覆「Folia 760c51a:框線大致對齊/仍有差距;reload/doctor 返回 2/2、storage 返回 2/2:通過/失敗」。 + 失敗附指令與截圖。先不要求詳細流程;通過後再決定何時進行原本其餘驗收。 + +新增命令必須沿用這套共用框線及權限過濾後的父頁定位;已有全分類不變式與 runtime 回歸測試。 +下方為前輪局部測試及歷史三台流程,保留參考,不代表要求立即啟動其他測服。 + +## 最新安排:只測 Folia 26.1.2 的首頁 help 點擊 + +候選 `656f416df8a7042e42286acef2d5e4f0b100be66`,JAR SHA-256 `4D6E9B8BB5E36D7CD2FE6337899008232F7E2E1E871275A867FDE2D52772D1EA`。 +本輪只更新 Folia 26.1.2;Spigot 1.8.8/Paper 26.3 保持停止及前一版產物,不自動啟動。 +使用者已回饋多層 help 顯示大致正常,這是局部回饋,不是三台完整真人驗收通過。 + +經 localhost:25565 輸入 `/server invitecode-folia-26.1.2`,再輸入 `/ic`: +點首頁 `/ic help` 應直接開啟玩家說明,與 `/ic help admin` 導覽一致;其他四個操作仍只填入聊天列。 +請回覆「Folia 首頁 help 點擊通過/失敗」,失敗附操作與截圖。先看外觀,不要求立即重跑詳細流程。 + +管理指令的玩家名稱/紀錄選取改善另存本機草案,未實作、未改資料庫、未建分支或 Issue。 +待目前 help 分支驗收及合併後再確認規格、從當時 develop 建立新分支,不提前混入本輪。 +以下內容為前次三台清單及歷史部署紀錄,保留作後續詳細驗收參考。 + +## 目前狀態:help 框線與固定導航已部署,待真人複驗 + +2026-10-18 原準備已依使用者授權完成三台部署、B 資格重設及 Folia 單筆舊關係解除;本輪只更新 help,不重做帳號操作。 +三台當次 `Done`、InviteCode ACTIVE、help/doctor/玩家專用拒絕/reload、UTF-8 log、實際 JDK 與 port 均已核對。 +世界原位保留;DB、密鑰與歷史未清空。原部署後因首頁資訊過量重建候選,三台已更新為下列新版;沒有 push。 + +- 程式來源:`fb303e23bb6acca4e6d97aa9686bc89475ff0166`。 +- 已裝 JAR:`InviteCode-0.1.0-SNAPSHOT.jar`,19,914,359 bytes。 +- SHA-256:`E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA`。 +- [本輪部署與當次啟動證據](evidence/2026-10-18-command-feedback-help-frame-deployment.json);[原帳號準備與部署證據](evidence/2026-10-18-command-feedback-stage4-deployment.json)。 + +**現在直接從步驟 1 開始;不要再次 reset、unlink 或建立 B 的邀請碼。** +B 的本輪視窗最早在 **2026-10-19 14:38(臺灣時間)** 到期。若來不及,先回報,由 Agent 重新核對後安排。 + +## 本輪先驗收:框線、同列標題與固定導航 + +三台使用相同新候選,沒有再次 reset/unlink。每台經原本 `localhost:25565` 與同名 `/server` 路由進入。 +A 使用管理員帳號 Command1,B 使用一般帳號 Taiwan_PingLord;B 不執行 `/ic code`。 + +1. A、B 輸入 `/ic`:prefix 與「常用指令」在同一條標題線,只出現一次;內容下方有結尾線。 + 底部固定 `[上一頁] [返回] [下一頁]`,首頁三項皆深灰,點擊不反應、沒有操作 hover。 +2. A 輸入 `/ic help admin`:第一頁上一頁深灰,返回/下一頁黃色。點下一頁到 2/2, + 下一頁改深灰,上一頁仍黃色可回 1/2。點停用項目不新增 help,也不填入聊天列。 +3. A 輸入 `/ic help admin invitation transfer`:前後線清楚,三項導航完整,只有返回黃色可用; + 點操作用法仍只填入聊天列,**不要按 Enter 執行管理指令**。 +4. B 輸入 `/ic help`,確認同樣框線與三項導航;`/ic help admin` 仍不得顯示管理用法。 + 各自按既有 Tab 清單確認權限與空集合行為未回歸。 +5. 原生主控台輸入 `ic`、`ic help admin`、`ic help admin 2`、`ic help admin invitation transfer`: + prefix 同列、前後線與三項導航都顯示,可用項目帶導航命令。Console 仍使用可讀 16 色、不額外粗體; + 深灰在 console 可依可讀性降色,不要求與玩家畫面完全相同。 +6. 逐台回覆「核心/客戶端版本;框線與 prefix、固定導航、停用無反應、分頁返回、console:通過/失敗」。 + 失敗附指令、預期/實際及截圖;不需再次 reset。通過後續原先尚未完成的其他訊息/確認/雙語/重啟清單。 + +字型、視窗寬度可能造成換行;不是以空格固定像素對齊。真人未通過前不宣告外觀驗收完成。 +本輪證據見 [部署紀錄](evidence/2026-10-18-command-feedback-help-frame-deployment.json)。 + +## 2026-10-18 分層 help 複驗:先完成這六項 + +本輪為真人回饋修正,沿用原分支/Worktree。只更新插件與雙語訊息,不再次 reset/unlink。 +DB 各資料表在部署前後一致,金鑰、資格設定、權限與世界保留;三台當次啟動及 console 回覆已核對。 +本輪不替使用者宣告真人通過。三台各做一次下列清單,之後繼續先前尚未完成的 12 步流程。 + +1. **連線。** A(Command1,管理員)與 B(Taiwan_PingLord,一般玩家)經 `localhost:25565`, + 各自 `/server invitecode-spigot-1.8.8`、`/server invitecode-paper-26.3` 或 `/server invitecode-folia-26.1.2`。 + 每次只選一台;使用對應客戶端版本,記下版本。不要直接連後端。 +2. **首頁。** A、B 各輸入 `/ic`。B 應只見有權限的 `code`、`claim`、`status`、`stats`、`help`; + A 額外一行 `/ic help admin`。不直接列管理用法、confirm 或 cancel。B 只閱讀首頁,**不要執行 `/ic code`**。 +3. **分層與點擊。** A 依序 `/ic help admin`、`/ic help admin 2`、`/ic help admin invitation`、 + `/ic help admin invitation transfer`。分類每頁最多五項,有頁碼;詳細頁才顯示完整參數與範例。 + 點分類/下一頁/返回應直接開 help;點真正的管理用法應只填入聊天列,**不要按 Enter 執行**。 + B 查 `/ic help admin` 應顯示一般錯誤,不洩漏管理用法。confirm/cancel 只在互動情境提示;明確查其 help 仍有效。 +4. **Tab。** A 輸入 `/ic help admin ` 後按 Tab,應見分類與 `1`、`2`; + `/ic help admin invitation ` 應見三種操作。B 的 `/ic ` 不見 admin/reload,`/ic help admin ` 沒有候選。 + A 的 `/ic admin invitation force-qualify EXAMPLE_INVITATION_UUID ` 應提示設定內的資格 ID, + **只按 Tab,不送出這個假 ID 指令**。`/ic status `、`/ic stats `、`/ic help admin 2 `、 + `/ic help admin invitation transfer ` 及任意超長路徑的 Tab 都應為空,不冒出玩家名稱。 +5. **Console 與錯誤。** 在各台原生主控台輸入 `ic`、`ic help admin`、`ic help admin 2`、 + `ic help admin invitation transfer`、`ic help typo`、`ic help admin 999`。console 只見適用項目, + 分頁列出可輸入的導航命令,錯誤清楚;16 色可讀、不額外粗體、沒有原始色碼。 + 也請在原生主控台鍵入 `ic help admin ` 後按 Tab(不按 Enter),確認有分類/頁碼, + `ic status ` 的 Tab 不回退玩家名稱。原生終端的實際 Tab 行為仍待這項真人驗收。 +6. **回報。** 逐台回覆「核心/客戶端版本;首頁、權限、分頁點擊、玩家 Tab、console Tab、顏色:通過/失敗」。 + 失敗附操作、預期/實際與截圖。通過後再繼續原清單未完成的確認、雙語、獎勵與重啟驗收。 + +已知限制:最新 Folia ALPHA 未驗證;本輪沿用 stable 26.1.2。Spigot 的 LuckPerms JSON 寫入問題仍保留, +本清單不修改權限。關服 JLine 問題維持暫緩;本輪正常停止三台皆有成功退出紀錄。 +相關:[本輪部署證據](evidence/2026-10-18-command-feedback-help-deployment.json)。 + +## 選用三台,逐台完成 + +下表的核心、build 與 JDK 已依實際 JAR、當次啟動 log 及 Java 程序核對。 + +| 測服/同名 `/server` 路由 | 核心 | JDK alias | Port | 本輪用途 | +| --- | --- | --- | --- | --- | +| `invitecode-spigot-1.8.8` | Spigot `git-Spigot-3c60ece-741a1bd` | local-8 | 10101 | 舊版聊天與填入邀請碼 | +| `invitecode-paper-26.3` | Paper 26.3 build 202 | local-25 | 20102 | 新版 Dialog、複製、完整流程 | +| `invitecode-folia-26.1.2` | Folia 26.1.2 build 8 | local-25 | 30101 | 實驗性平台互動與排程 | +| `invitecode-paper-26.2` | Paper 26.2 build 134 | local-25 | 20101 | 保留;受影響 adapter 的 Agent 複驗尚待執行 | + +實例根目錄:`D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\`。 +沒有新增實例、更新核心或搬移世界。三台現在為 Managed/Listening/ConPTY,可在既有 InstanceHarbor GUI +按該台的原生後台按鈕開啟主控台。共用 Velocity 25565 與 Lobby 10001 的既有 run 保留。 +Paper 26.2 不在本輪部署、reset 或 unlink 範圍,保持停止。 + +## 已完成的部署與備份 + +每台先持有管理鎖、確認停止及核心 hash,再備份並逐檔核對:舊 JAR、整個 InviteCode 設定/DB/key、 +LuckPerms JSON 權限資料、metadata 與 ops。備份在各實例 `.invitecode-backups/command-feedback-20261018-*/`; +精確路徑見部署 JSON。本備份不包含完整世界,世界原位保留,部署期間 `level.dat` 未變。 + +部署三台的唯一候選 JAR、完整 zh_TW/en_US 文案及測試資格設定;storage/rewards 與 key 不變。 +同網路暫用 ALLOW;測完還原 Spigot/Folia 原 DENY,Paper 26.3 原本就是 ALLOW。 + +Spigot 原先繼承全域 Java 25,已備份本台管理設定並改為 mise local-8,正常停服/退出後重啟驗證; +其他測服與全域 Java 設定未改。Paper/Folia 實際為 local-25。 + +**Spigot 的資格測試方式不同:**既有 LuckPerms 5.4.145 在寫 JSON 權限時發生 Gson 相容性錯誤。 +這次新建而失敗的 B 權限檔已在停服後移入備份保留證據,原本的權限檔沒有覆寫。 +本輪改用 `invitecode.command.basic` 資格條件,B 最後同意後立即達資格; +A 必須在 B 最後同意前回 Lobby。**Spigot 不執行本清單的 LuckPerms 權限寫入指令。** +Paper/Folia 仍用 `invitecode.test.qualified`,已設為 false 並核對持久化與實際檢查結果。 + +## 兩帳號與既有資料 + +- **A:Command1**,邀請人,原邀請碼保持不變。A 不 reset、不輪替邀請碼。 +- **B:Taiwan_PingLord**,受邀人,三台都已由 Agent 重設為新的登記資格,generation 0 → 1。 + B 沒有自己的有效邀請碼,請不要執行 `/ic code`。 + +Spigot/Paper 26.3 的舊 QUALIFIED 保留;Folia 指定的那一筆舊 CLAIMED 已成為 UNLINKED, +原列與歷史仍在。三台分別新增 1/1/2 筆稽核,A、原邀請碼、舊 Reward 均未變。 +現在沒有替真人建立新的 Invitation,也沒有新的待補發獎勵。SQLite 均為 schema 9,quick_check=ok。 + +Paper 26.3 的 B 原本有直接 `* = true` 與測試資格 true;為驗收一般玩家 help,已暫時移除該 wildcard 並設資格 false。 +原權限已備份,驗收後還原。三台 B 都不是 OP。 + +## 簡單完整步驟(現在可以開始) + +三台已啟動;一次測一台,做完切回 Lobby 再換下一台。後端主控台指令**不加 `/`**;玩家聊天指令加 `/`。 +測試帳號、語言及客戶端版本記在回報中;不要提供密碼或 key。 + +### 1. 啟動與切服 + +在既有 InstanceHarbor GUI 依名稱選擇目標,開「原生後台」。三台目前已啟動,不必重複按啟動。 +在目前後端主控台依序輸入: + +```text +ic admin doctor +ic help +ic code +``` + +預期 doctor 正常;Paper/Folia 若具 Dialog 能力應回報 PAPER,Spigot 1.8.8 為 NONE。 +help 有管理用法;console 的 `ic code` 明確說只能由玩家執行。 +使用 16 色、不額外粗體,文字可讀、沒有原始 `&`/HEX 格式碼外洩。 +本輪原生後台視覺色彩仍待人眼確認。 + +A、B 都連到 `localhost:25565`,然後各自輸入**目前這一台**: + +```text +/server invitecode-spigot-1.8.8 +/server invitecode-paper-26.3 +/server invitecode-folia-26.1.2 +``` + +Spigot 用 1.8.8 客戶端驗收舊版行為;Paper 用 26.3,Folia 用原生 26.1.2 或已核對的代理相容客戶端, +記錄實際版本。若無 Dialog 或切服失敗,先回報,不直接連離線模式後端。 + +### 2. 先測現有資格拒絕 + +A 輸入 `/ic claim`,預期因 Inviter 身分直接拒絕,不開輸入框。 +A、B 各輸入 `/ic status`、`/ic stats` 並記下數量;B 目前應顯示可登記。 +若 status 同時顯示舊 QUALIFIED/UNLINKED,那是保留的歷史;本輪可登記與後續新關係另外核對。 +B 的「已有登記」前置拒絕要在步驟 8 成功後再測。 + +### 3. help、Tab 與邀請碼(改以上方六項複驗為準) + +A、B 先依上方六項複驗首頁、分層說明及 Tab。首頁與詳細頁的操作用法只填入聊天列;分類/分頁直接開啟唯讀 help。 +A 以 `/ic help admin` 查看其權限允許的分類;B 須先確認為一般玩家(沒有 OP/管理權限),只看到允許的項目。 +在 `/ic status `、`/ic stats ` 和超出語法長度的位置按 Tab,應沒有線上玩家名稱補全。 + +A 輸入 `/ic code`。將滑鼠移到**六碼本身**,檢查 hover。 +Paper/Folia 點擊後貼到本機記事本,應只有六碼;1.8.8 應填入聊天列,再手動選取複製,勿送到公開聊天。 +檢查 HEX 顏色、繁體中文與 prefix:一般一份回覆只出現一次。 + +### 4. 確認 B 可開始,勿重做管理操作 + +B 輸入 `/ic status`,確認可登記;不要輸入 `/ic code`。 +Agent 已完成 reset、Folia 精確 unlink、generation 與 audit 核對;這一步不需任何主控台修改。 +若 B 已不符合資格,停止並回報,不自行反覆 reset。 + +### 5. 取消輸入與不公開 + +Spigot:B 執行 `/ic claim`,在聊天輸入 `cancel`。預期私密取消,A 看不到原始輸入。 +Paper/Folia:B 執行 `/ic claim`,先按 Dialog「取消」;預期沒有登記關係變更。 +輸入 Dialog 的標題/內容應清楚,置中、不靠空格補位置。 +聊天路徑的 `cancel` 已由 Spigot 驗收;需要強制測新版聊天時,管理員暫改 input-mode 為 CHAT 並 reload,測完還原 AUTO。 + +### 6. 不同意 + +B 再執行 `/ic claim`,輸入 A 六碼(舊版聊天輸入;新版 Dialog 按繼續)。 +聊天確認依序七區塊:prefix、確認標題、邀請人、邀請碼、問題、期限、按鈕。 +聊天靠左;Dialog 內容置中。prefix 獨立且無尾端空格;期限末尾**沒有冒號**。 +「同意」綠色、「不同意」紅色,hover 清楚,Dialog 底色沿用原生。 +B 按「不同意」,再查 `/ic status`,預期仍可登記。 + +### 7. 逾時 + +B 重複輸入 A 碼進入確認後,等待超過 60 秒,再按同意或執行 `/ic confirm`。 +預期拒絕過期操作、沒有建立登記;重新 `/ic claim` 仍可開始。不要把等待輸入逾時當成確認逾時。 + +### 8. 同意 + +**Spigot:A 先 `/server lobby`,B 才按最後的同意。** +Paper/Folia:A 此時可以留在原服,步驟 9 才回 Lobby。 +B 重開輸入,填 A 碼並在期限內按綠色「同意」。預期成功只登記一次。 +B `/ic status` 可看到新登記,再 `/ic claim` 應在輸入前拒絕。 +Paper/Folia 新登記應先等待資格;Spigot 依本輪設定立即達成資格並通知 B,A 離線獎勵等待補發。 +由 Agent 在回報後唯讀核對只有一筆新的 Invitation UUID,A/B 方向正確, +其 `invitee_eligibility_generation` 等於 B 本輪 generation;舊列與舊 Reward 不被覆寫。 +玩家 status/stats 是外觀驗收,不能代替這項資料判定。 + +### 9. 資格通知與離線補發 + +**Spigot:不執行 lp 指令。**步驟 8 後 B 應已收到一次資格訊息;A 尚在 Lobby,直接做下方 A 回服檢查。 + +**Paper/Folia:**A 先 `/server lobby`,B 留在原服。目前後端主控台輸入: + +```text +lp user Taiwan_PingLord permission set invitecode.test.qualified true +``` + +等待約 60 秒,或讓 B 回 Lobby 再切回本服,預期 B 收到一次資格訊息,A 的 MESSAGE 等待補發。 +若先前已設過 true,不要再重複測本步;保留實際結果。 + +**三台共用:**A 回到正在測的那台,應收到一次資格訊息;A 再回 Lobby、再進來,不應重複。 +A `/ic stats` 的 qualified 數量相對步驟 2 增加一。文字應清楚區分資格與獎勵交付。 +不要執行 reward retry/mark-delivered。 + +### 10. 雙語與 reload + +A、B 將客戶端語言切為 English (US),再執行 help/status/stats,預期英文完整且 prefix 一致。 +再切回繁體中文;若 locale 快取沒有即時更新,重新切入後端並記錄此行為。 + +由管理員先備份 `messages/zh_TW.yml`,將 `presentation.prefix` 暫改為 `[IC TEST]`,主控台 `ic reload`。 +預期後續新回覆使用新 prefix,不重複;恢復檔案後 reload。 +再把同一鍵暫改為數字 `123`(不是字串),執行 `ic reload`,預期明確報錯且舊有效 prefix 繼續使用。 +立即恢復並 reload 成功;不要破壞 storage/DB/key。 +缺檔復位已有 Agent 證據,真人不必刪檔重測。 + +### 11. 重啟與還原 + +記下 A 碼、A stats、B status;兩人切回 lobby,管理員正常 stop 並等待保存完成、退出 receipt/port 釋放。 +重新啟動同一台,兩人切回,預期邀請碼、登記與設定保留,已送獎勵不再補發。 +若遇到已記錄的 JLine 關服例外,保留 log;先核對儲存與退出,不在此輪展開隔離測試或直接重建。 + +測完先依步驟 12 回報,由 Agent 統一還原 B 原權限、原 qualifications 與 matching-ip-action,並核對正常關服。 +不要手動回灌舊 DB,避免覆蓋本輪歷史與稽核;不要刪 key 或世界。共用代理/Lobby 保持原狀。 + +### 12. 回覆方式 + +每台提供:核心 build、兩帳號客戶端版本,以及下列項目的通過/失敗/未測: +切服、help/Tab、六碼 hover/複製、前置拒絕、取消輸入、不同意、確認逾時、同意、 +七區塊與對齊、雙語、console 色彩、reload 失敗保留、資格/離線一次補發、重啟保留、設定還原。 +失敗附畫面及時間即可;不要貼 key、IP 雜湊或完整 DB。 + +## Agent 唯讀資料核對方式 + +先依管理器身分選定本服的 `plugins/InviteCode/invitecode.db`,以 Python sqlite3 +`connect(Path(database).as_uri() + "?mode=ro", uri=True)` 開啟,再執行 `PRAGMA query_only=ON`。 +只做下列參數化 SELECT,結束後關閉 connection;不執行 migration、INSERT、UPDATE 或 DELETE, +不讀 key/網路 hash。帳號參數綁定 `Taiwan_PingLord`;結果保留於本機受限操作紀錄,公開證據只記錄角色與判定。 + +```sql +SELECT player_id, eligibility_generation +FROM invitecode_players WHERE last_known_name = ?; + +SELECT i.invitation_id, i.inviter_id, i.invitee_id, + i.invitee_eligibility_generation, i.status, i.claimed_at +FROM invitecode_invitations i +JOIN invitecode_players p ON p.player_id = i.invitee_id +WHERE p.last_known_name = ? +ORDER BY i.claimed_at, i.invitation_id; +``` + +先確認查到唯一 B,再以同樣的第一個 SELECT、A 的名稱核對 inviter_id。 +reset 前、後與同意後各讀一次;新列須對應當前 generation,歷史列仍在。 +如果服務正在寫入而讀取失敗,保留錯誤並在安全時重讀,不更改 journal mode 或寫入 DB 來解鎖。 + +## 尚餘里程碑與來源 + +目前是「Agent 部署與啟動驗證完成,待使用者驗收」。下一步依上方清單集中完成三台真人外觀與互動; +若通過,Agent 核對新 Invitation generation、獎勵恰一次及還原臨時設定/權限、停止不再使用的後端, +再整理本任務的交付審查。沒有 push 授權,merge、release 與發布也另行處理。 + +Paper 26.2 的隔離 adapter 複驗尚待完成,不使用其 Human 世界作為可重建自動資料。 +Folia 最新 26.3 ALPHA 缺口仍保留;26.1.2 是實驗性測試對象。 + +依據:[四階段計畫,第四階段](../plans/command-feedback-implementation-plan.md#第四階段集中一次的真人外觀驗收)、 +[本輪部署證據](evidence/2026-10-18-command-feedback-stage4-deployment.json)、 +[部署前唯讀證據](evidence/2026-10-18-command-feedback-stage4-preflight.json)。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-console.json b/docs/testing/evidence/2026-10-18-command-feedback-console.json new file mode 100644 index 0000000..d9f051d --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-console.json @@ -0,0 +1,107 @@ +{ + "recordedUtc": "2026-10-18T10:54:07.829304+00:00", + "candidate": { + "sourceCommit": "53893c475fdeaf631ca5b174493f33754660e0ad", + "sha256": "6E7EB72D59896AF141FE17029FDAD5A0322EADA7F019929F5E78D11C20C8664E", + "bytes": 19922750, + "tests": { + "tests": 326, + "failures": 0, + "errors": 0, + "skipped": 24 + }, + "passed": 302, + "checks": [ + "Java 8/11 check shadowJar", + "console one send per line and prefix/color retention", + "report player single prefix, console each-line prefix", + "locale unique keys/parity/fields/no semicolons", + "core/storage string-only and SQL resources unchanged" + ], + "humanAcceptance": "pending" + }, + "instance": "invitecode-folia-26.1.2", + "runId": "f0d0a1687ee5457b94ae9e272e70837e", + "port": 30101, + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\console-layout-20261018-104918-079ad994", + "done": true, + "active": true, + "consoleProbes": [ + { + "route": "ic", + "lines": 3, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic help", + "lines": 14, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic help admin 2", + "lines": 10, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic help admin reload", + "lines": 9, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic admin doctor", + "lines": 13, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic admin inspect player", + "lines": 10, + "eachLineHasRealLogHeader": true + }, + { + "route": "ic admin inspect invitation", + "lines": 9, + "eachLineHasRealLogHeader": true + } + ], + "rewardRecordLiveProbe": "No reward action row available; template/output checks passed; live record probe not run", + "keyUnchanged": true, + "dataUnchangedExceptRuntimeObservationTimes": true, + "postBootChanges": [ + { + "table": "invitecode_player_network_hashes", + "fields": [ + "expires_at", + "observed_at" + ], + "interpretation": "Runtime network observation timestamp refresh; no identity or historical relationship change" + } + ], + "protectedFilesAndWorldHeadersUnchangedDuringDeployment": true, + "otherInstances": { + "invitecode-spigot-1.8.8": "Stopped", + "invitecode-paper-26.3": "Stopped" + }, + "humanAcceptance": "pending", + "noPush": true, + "textOnlyAudit": { + "coreStorageTextOnly": [ + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/Invitation.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleService.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationEvaluator.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationPolicy.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDefinition.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDeliveryProcessor.kt", + "invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageConfiguration.kt", + "invitecode-storage-json/src/main/kotlin/io/github/command1264/invitecode/storage/json/JsonInviteCodeStorage.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlInviteCodeStorage.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlSchemaMigrator.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflinePlayerAnonymizer.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflineStorageTransfer.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteIdentityRecords.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInvitationRecords.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorage.kt", + "invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteSchemaMigrator.kt" + ], + "sqlResourcesUnchanged": true + } +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-console.md b/docs/testing/evidence/2026-10-18-command-feedback-console.md new file mode 100644 index 0000000..6f38add --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-console.md @@ -0,0 +1,35 @@ +# Console 與逐欄報告:Agent 驗證及 Folia 部署 + +候選 `53893c475fdeaf631ca5b174493f33754660e0ad`,SHA-256 `6E7EB72D59896AF141FE17029FDAD5A0322EADA7F019929F5E78D11C20C8664E`,19,922,750 bytes。 +沿用目前分支;僅 Folia 26.1.2 port 30101 更新。沒有 push、PR、merge 或發布。 + +## 變更與證據 + +Console 邏輯行分別送給核心,一般回覆每行 prefix,框線 help 頂端 prefix 一次; +原生時間戳/INFO 不由插件偽造。Console help 單一入口、後台標題與有效文字導航;玩家固定三按鈕保留。 +doctor/inspect/離線工具及雙語分號句與密集欄位拆行,玩家報告只加一次標題 prefix。 +核心與 storage 共16檔去除字串後比對一致,SQL resources 沒有改動,沒有 schema/交易/管理規則變更。 + +先用測試重現 console 一次送多行的失敗,再修正為通過。 +Java 8/11 均以 mise exec 與 Gradle Wrapper 執行 check shadowJar,326 cases:302 passed、24 MySQL +條件測試 skipped、零失敗。JAR/bytecode、逐行prefix/顏色、玩家報告prefix一次、雙語唯一鍵/變數/ +無分號及逐欄、console去重/導航檢查通過。獨立 review 的布林標籤/報告標題已修正,無未處理Critical/High。 + +## 部署與實際核心核對 + +Folia 原先已停止,確認無host/port釋放並持管理鎖新建備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\console-layout-20261018-104918-079ad994`,逐檔hash通過後 +只換 JAR/完整雙語文案/workspace產物識別。世界、設定、權限、DB及key在部署期間不變。 +啟動 run `f0d0a1687ee5457b94ae9e272e70837e`,當次 Done/ACTIVE,沒有新增錯誤。 +root、help、第2頁、reload help、doctor、玩家與邀請查詢的每個非空輸出行皆有原生時間戳/INFO。 +doctor13行、玩家查詢10行、邀請查詢9行;各報告行有prefix。無Reward Action紀錄,live reward查詢未執行。 + +啟動後DB比對僅網路 observed_at/expires_at 刷新,其餘資料列與備份一致;key一致。 +沒有回灌舊DB、reset、unlink、資格/獎勵/邀請歷史變更。其他兩台仍停止、沒有更新。 +離線匿名化/搬移只以隔離fixture測試,沒有在Human執行。 + +## 下一步 + +Agent驗證完成,待使用者依[最新Folia清單](../command-feedback-human-acceptance.md)驗收Console色彩/ +導航及玩家報告prefix/換行/雙語。前版760c51a局部通過保留,不推定新報告外觀通過。 +關服JLine仍暫緩;其他核心、完整互動流程與臨時設定還原等既有門檻未自動完成。 +同一HTML同步更新,JS語法通過,不以文件示意或server log代替Minecraft渲染驗收。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-click.json b/docs/testing/evidence/2026-10-18-command-feedback-help-click.json new file mode 100644 index 0000000..ff63014 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-click.json @@ -0,0 +1,26 @@ +{ + "recordedUtc": "2026-10-18T08:11:48.355755+00:00", + "candidate": { + "sourceCommit": "656f416df8a7042e42286acef2d5e4f0b100be66", + "sha256": "4D6E9B8BB5E36D7CD2FE6337899008232F7E2E1E871275A867FDE2D52772D1EA", + "bytes": 19914459, + "checks": "Java 8/11 check shadowJar passed; 293 passed/24 MySQL skipped; runtime click and permission tests passed", + "humanAcceptance": "pending" + }, + "name": "invitecode-folia-26.1.2", + "runId": "24d10a1a33fa4f3e9d241c57541678fb", + "port": 30101, + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\help-click-20261018-081003-d6a0244b", + "done": true, + "active": true, + "dbRowsAndKeyUnchanged": true, + "worldHeadersUnchangedDuringDeployment": true, + "otherInstances": { + "invitecode-spigot-1.8.8": "Stopped", + "invitecode-paper-26.3": "Stopped" + }, + "humanAcceptance": "pending limited Folia homepage click test", + "noPush": true, + "futureSpec": "D:/Code/Java/Plugin/InviteCodeKt/notes/admin-player-command-discovery-draft.md", + "futureFeatureImplemented": false +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-click.md b/docs/testing/evidence/2026-10-18-command-feedback-help-click.md new file mode 100644 index 0000000..63a23e1 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-click.md @@ -0,0 +1,19 @@ +# 首頁 help 直接開啟:Folia 局部更新 + +候選 `656f416df8a7042e42286acef2d5e4f0b100be66`。已重現舊版首頁 help 只填入的回歸測試失敗,修正後 +Java 11/8 `mise exec [java@local-8] -- .\gradlew.bat check shadowJar --console=plain` 通過。 +293 passed/24 MySQL 條件測試 skipped;沒有新增依賴、schema 或管理操作。 +完整 diff 已核對:首頁只有 HELP 改為唯讀導航,目標 `/ic help`;另四項仍只填入,權限不變。 + +只更新 Folia 26.1.2 port 30101,正常停止與 drained 退出紀錄確認後持管理鎖備份,再更新。 +備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\help-click-20261018-081003-d6a0244b`;啟動 run `24d10a1a33fa4f3e9d241c57541678fb`,當次 Done/ACTIVE 與 console probes 通過。 +資料庫各表及金鑰一致,部署期間世界 header/設定/權限保留,沒有 reset/unlink。 +Spigot 1.8.8 與 Paper 26.3 均停止,未部署新候選、未啟動。 +SHA-256 `4D6E9B8BB5E36D7CD2FE6337899008232F7E2E1E871275A867FDE2D52772D1EA`。 + +使用者回饋多層選單大致正常,屬局部外觀回饋,不是完整矩陣驗收。 +下一步只需依 [最新 Folia 步驟](../command-feedback-human-acceptance.md) 點首頁 help 複驗。 +新一輪玩家 click 尚待真人確認;沒有 push、PR 或 merge。 + +後續玩家導向管理操作只保存本機草案於 `D:/Code/Java/Plugin/InviteCodeKt/notes/admin-player-command-discovery-draft.md`。 +待目前 help 分支完成後才評估新分支;沒有提前實作或建立 Issue。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.json b/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.json new file mode 100644 index 0000000..02c9a80 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.json @@ -0,0 +1,137 @@ +{ + "recordedUtc": "2026-10-18T07:33:50.932625+00:00", + "candidate": { + "sourceCommit": "6de6dce250334ec6a1647cb91ac2b09918abc9e6", + "sha256": "29C46B948B43B3066768BC824853080D2DD09240E1DA2E6179B5210493B9E54A", + "bytes": 19912806, + "tests": [ + { + "module": "invitecode-core", + "tests": 89, + "failures": 0, + "errors": 0, + "skipped": 0 + }, + { + "module": "invitecode-platform-bukkit", + "tests": 62, + "failures": 0, + "errors": 0, + "skipped": 0 + }, + { + "module": "invitecode-platform-modern", + "tests": 16, + "failures": 0, + "errors": 0, + "skipped": 0 + }, + { + "module": "invitecode-plugin", + "tests": 57, + "failures": 0, + "errors": 0, + "skipped": 3 + }, + { + "module": "invitecode-storage-json", + "tests": 15, + "failures": 0, + "errors": 0, + "skipped": 0 + }, + { + "module": "invitecode-storage-sql", + "tests": 76, + "failures": 0, + "errors": 0, + "skipped": 21 + } + ], + "testCommands": [ + "mise exec -- .\\gradlew.bat check shadowJar --console=plain", + "mise exec java@local-8 -- .\\gradlew.bat check shadowJar --rerun-tasks --console=plain", + "mise exec java@local-8 -- .\\gradlew.bat :invitecode-plugin:test --console=plain" + ], + "state": "awaiting-human-acceptance", + "limitations": [ + "MySQL integration tests skipped without external credentials", + "Live rendering and native console Tab need human acceptance", + "Latest Folia ALPHA not tested; stable 26.1.2 used" + ] + }, + "instances": [ + { + "name": "invitecode-spigot-1.8.8", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8", + "port": 10101, + "runId": "21ec0d02c1014f9a99fcc49700b8563f", + "hostPid": 65080, + "childPid": 16968, + "javaExecutable": "C:\\Program Files\\Java\\jdk1.8.0_501\\bin\\java.exe", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8\\.invitecode-backups\\help-navigation-20261018-073208-0e22a4cf", + "pluginSha256": "29C46B948B43B3066768BC824853080D2DD09240E1DA2E6179B5210493B9E54A", + "coreSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "done": true, + "active": true, + "errors": [], + "databaseRowsUnchanged": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "configurationUnchanged": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpProbesPassed": true, + "humanAcceptance": "pending" + }, + { + "name": "invitecode-paper-26.3", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3", + "port": 20102, + "runId": "f3ebc01950d34969be49f8d034df49c5", + "hostPid": 74024, + "childPid": 70336, + "javaExecutable": "C:\\Program Files\\Java\\jdk-25.0.4.1\\bin\\java.exe", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3\\.invitecode-backups\\help-navigation-20261018-073208-1efc6afd", + "pluginSha256": "29C46B948B43B3066768BC824853080D2DD09240E1DA2E6179B5210493B9E54A", + "coreSha256": "1B243442FC3B3CBE945628F8AF7911E4BE439CA8B22106FB1568AC81D5A5792B", + "done": true, + "active": true, + "errors": [], + "databaseRowsUnchanged": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "configurationUnchanged": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpProbesPassed": true, + "humanAcceptance": "pending" + }, + { + "name": "invitecode-folia-26.1.2", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "port": 30101, + "runId": "5e98fb6b92554296b00c29fb39a876e7", + "hostPid": 74304, + "childPid": 62948, + "javaExecutable": "C:\\Program Files\\Java\\jdk-25.0.4.1\\bin\\java.exe", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\help-navigation-20261018-073208-a34c3166", + "pluginSha256": "29C46B948B43B3066768BC824853080D2DD09240E1DA2E6179B5210493B9E54A", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "done": true, + "active": true, + "errors": [], + "databaseRowsUnchanged": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "configurationUnchanged": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpProbesPassed": true, + "humanAcceptance": "pending" + } + ], + "noPush": true, + "noResetOrUnlink": true, + "humanAcceptance": "pending", + "agentResults": "291 passed, 24 MySQL-dependent skipped; zero failures", + "routing": "Existing unique Velocity legacy routes 10101/20102/30101 preserved; new client switching pending", + "sharedServices": "Velocity 25565 and Lobby 10001 left running; Paper 26.2 not modified" +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.md b/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.md new file mode 100644 index 0000000..8267875 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-deployment.md @@ -0,0 +1,43 @@ +# 分層 help 與權限 Tab:Agent 驗證及部署 + +2026-10-18。程式候選 `6de6dce250334ec6a1647cb91ac2b09918abc9e6`,沿用 `codex/feat/command-feedback-messages`。 +狀態:Agent 驗證及三台部署完成,待使用者驗收;沒有 push、PR、合併或發布。 + +## 變更與驗證 + +首頁五項常用指令,有管理權限時加一個 help 入口。管理分類先依權限篩選,每頁五項; +完整 help 路徑提供參數及範例。只有 help 導覽執行 RUN_COMMAND,操作用法只 SUGGEST_COMMAND。 +所有既有命令、help 路徑、頁碼與適用參數有權限分級 Tab;無候選時回傳空集合。 +沒有變更 storage schema、獎勵、匿名化或跨 backend 行為。 + +RED 已重現 parser、Tab 及首頁過量;修正後 Java 11 `check shadowJar`、Java 8 +`check shadowJar --rerun-tasks`、後續受影響 plugin 測試、JAR 及 Java 8 bytecode 檢查皆通過。 +目前 XML 彙總:315 cases,291 passed,24 MySQL 依賴測試 skipped,零失敗;不把 skipped 當通過。 +獨立唯讀 review 未發現阻擋問題;雙語鍵與變數一致,20 條詳細說明可達。 + +## 產物 + +`InviteCode-0.1.0-SNAPSHOT.jar`,19,912,806 bytes。 +SHA-256:`29C46B948B43B3066768BC824853080D2DD09240E1DA2E6179B5210493B9E54A`。 +候選保留於 `.run/command-feedback-help/candidate/`;完整結果與檢查命令見 +[JSON](2026-10-18-command-feedback-help-deployment.json)。 + +## 三台部署 + +- `invitecode-spigot-1.8.8`,port 10101,run `21ec0d02c1014f9a99fcc49700b8563f`;正常停止、備份、更新後 Done/ACTIVE,console probes 通過。備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-spigot-1.8.8\.invitecode-backups\help-navigation-20261018-073208-0e22a4cf`。 +- `invitecode-paper-26.3`,port 20102,run `f3ebc01950d34969be49f8d034df49c5`;正常停止、備份、更新後 Done/ACTIVE,console probes 通過。備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-paper-26.3\.invitecode-backups\help-navigation-20261018-073208-1efc6afd`。 +- `invitecode-folia-26.1.2`,port 30101,run `5e98fb6b92554296b00c29fb39a876e7`;正常停止、備份、更新後 Done/ACTIVE,console probes 通過。備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\help-navigation-20261018-073208-a34c3166`。 + +每台在停止且持有管理鎖時建立新備份,逐檔核對後只更新 JAR、雙語 messages 及 workspace 產物識別。 +資料庫各表在啟動前後一致、quick_check=ok,key 與設定不變;部署期間 world level.dat 不變。 +世界原位保留,備份不含完整世界。沒有再重設 B 或解除邀請,沒有更新核心或修改共享 Velocity/Lobby。 +三條原有唯一路由保留;實際客戶端新一輪切服與點擊/Tab/色彩仍待真人確認。 +Paper 26.2 沒有修改,仍停止;最新 Folia ALPHA 及既有 Paper 26.2 adapter 複驗缺口未關閉。 + +下一步:依 [真人清單](../command-feedback-human-acceptance.md) 先完成六項 help 複驗,再續原本未完成的 12 步。 +真人通過後仍需還原暫時測試設定/權限、保存證據,另取得 push/PR/merge 授權。 + +同一 HTML 閱讀入口已更新新版首頁樣例、玩家/console 切換、help 分層及本輪六項複驗。 +靜態 anchor、JavaScript 語法、DOM stub 的層級/受眾及原 12 步控制檢查通過; +沒有以文件樣例代替實際瀏覽器或 Minecraft 渲染驗收。暫存清單記於 `.run/command-feedback-help/manifest.json`, +待驗收候選與必要證據保留;本輪額外保存量約 20 MB,沒有建立額外核心或完整 runtime。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.json b/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.json new file mode 100644 index 0000000..781f0b5 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.json @@ -0,0 +1,102 @@ +{ + "recordedUtc": "2026-10-18T07:57:20.168665+00:00", + "candidate": { + "sourceCommit": "fb303e23bb6acca4e6d97aa9686bc89475ff0166", + "sha256": "E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA", + "bytes": 19914359, + "tests": { + "tests": 317, + "failures": 0, + "errors": 0, + "skipped": 24 + }, + "passed": 293, + "checks": [ + "Java 11 check shadowJar", + "Java 8 check shadowJar", + "Java 8 bytecode and plugin JAR", + "locale key/placeholder parity", + "fixed three nav slots; disabled no events; enabled yellow read-only help", + "empty prefix no extra separator space" + ], + "humanAcceptance": "pending", + "limitations": [ + "24 MySQL integration cases skipped without service", + "Minecraft rendering and native terminal Tab remain human acceptance", + "latest Folia ALPHA not tested" + ] + }, + "instances": [ + { + "name": "invitecode-spigot-1.8.8", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8", + "port": 10101, + "runId": "1ac82869c64f4e8c88bff92231e931c1", + "hostPid": 68828, + "childPid": 61032, + "javaAlias": "local-8", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8\\.invitecode-backups\\help-frame-20261018-075438-411ad62a", + "pluginSha256": "E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA", + "coreSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "done": true, + "active": true, + "errors": [], + "dbRowsUnchangedAfterBoot": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "protectedFilesUnchangedDuringDeployment": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpFrameProbesPassed": true, + "humanAcceptance": "pending" + }, + { + "name": "invitecode-paper-26.3", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3", + "port": 20102, + "runId": "ac48e2bb512041f395f7dd5431eabbda", + "hostPid": 19592, + "childPid": 74944, + "javaAlias": "local-25", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3\\.invitecode-backups\\help-frame-20261018-075439-aea591bb", + "pluginSha256": "E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA", + "coreSha256": "1B243442FC3B3CBE945628F8AF7911E4BE439CA8B22106FB1568AC81D5A5792B", + "done": true, + "active": true, + "errors": [], + "dbRowsUnchangedAfterBoot": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "protectedFilesUnchangedDuringDeployment": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpFrameProbesPassed": true, + "humanAcceptance": "pending" + }, + { + "name": "invitecode-folia-26.1.2", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "port": 30101, + "runId": "fe2826bf8c5e4cc58af81244b93897dd", + "hostPid": 63828, + "childPid": 76128, + "javaAlias": "local-25", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\help-frame-20261018-075439-3905d088", + "pluginSha256": "E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "done": true, + "active": true, + "errors": [], + "dbRowsUnchangedAfterBoot": true, + "sqliteQuickCheck": "ok", + "keyUnchanged": true, + "protectedFilesUnchangedDuringDeployment": true, + "worldHeadersUnchangedDuringDeployment": true, + "consoleHelpFrameProbesPassed": true, + "humanAcceptance": "pending" + } + ], + "noPush": true, + "noResetOrUnlink": true, + "humanAcceptance": "pending", + "routing": "Existing unique legacy Velocity routes preserved; client interaction pending", + "sharedServices": "Velocity and Lobby untouched; Paper 26.2 not updated" +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.md b/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.md new file mode 100644 index 0000000..63f0190 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-frame-deployment.md @@ -0,0 +1,38 @@ +# Help 框線與固定導航部署證據 + +2026-10-18。程式候選 `fb303e23bb6acca4e6d97aa9686bc89475ff0166`,分支 `codex/feat/command-feedback-messages`。 +Agent 驗證完成,待使用者驗收;沒有 push、PR、合併或發布。 + +## 驗證 + +新增測試先重現未加框線/導航不固定的失敗,再修正為通過。 +Java 8 與 11 的 `mise exec [java@local-8] -- .\gradlew.bat check shadowJar --console=plain` 通過; +Java 8 bytecode/JAR、雙語鍵與變數、空 prefix/同列標題、全部固定導航狀態及 click/hover 檢查通過。 +317 cases:293 passed、24 MySQL 條件測試 skipped,零失敗。 +獨立唯讀 review 發現的空 prefix 多餘空格已修復及複驗,其餘無阻擋。 + +## 產物與部署 + +`InviteCode-0.1.0-SNAPSHOT.jar`,19,914,359 bytes。 +SHA-256:`E8640904EA2963FB741C19A2037C9FD359DF85BAFF2B3F2F9A7EC1F591AE2EBA`。 + +- `invitecode-spigot-1.8.8`,port 10101,run `1ac82869c64f4e8c88bff92231e931c1`;備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-spigot-1.8.8\.invitecode-backups\help-frame-20261018-075438-411ad62a`。 +- `invitecode-paper-26.3`,port 20102,run `ac48e2bb512041f395f7dd5431eabbda`;備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-paper-26.3\.invitecode-backups\help-frame-20261018-075439-aea591bb`。 +- `invitecode-folia-26.1.2`,port 30101,run `fe2826bf8c5e4cc58af81244b93897dd`;備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\help-frame-20261018-075439-3905d088`。 + +三台在使用者已停止後,重新確認 Stopped、無 host、port 釋放,持管理鎖建立全新備份及逐檔 hash 核對。 +只更新 JAR、雙語 messages 及 workspace 產物識別;設定、權限、DB/key 與部署期間 world level.dat 保持不變。 +世界原位保留,備份不含完整世界。沒有 reset、unlink、更新核心或變更路由。 +當次 Done/ACTIVE、console 框線/同列 prefix/三項固定導航、分頁及詳細用法實際輸出均通過,沒有新增錯誤; +重啟後各 SQLite 表仍與本輪備份相同且 quick_check=ok。完整資料見 +[JSON](2026-10-18-command-feedback-help-frame-deployment.json)。 + +下一步依 [真人六項清單](../command-feedback-human-acceptance.md) 複驗三台。 +Minecraft 字型、換行、色彩、停用點擊與 native console Tab 仍待真人;最新 Folia ALPHA 與既有 Paper 26.2 +adapter 複驗缺口保留。關服 JLine 問題不處理、不做隔離測試。 +真人通過後仍須完成原本未完流程、還原暫時設定/權限、保存證據,再另取得 remote 操作授權。 + +文件沿用同一離線 HTML 入口。anchor、JS 語法與 DOM stub 的標題/三項停用首頁/首末頁/返回 +互動檢查通過;不是瀏覽器排版或 Minecraft 渲染證據。候選與必要證據約 20 MB,保留待驗收; +清單為 `.run/command-feedback-help-frame/manifest.json`,沒有新增核心或完整測試環境。 +實際 Java 程序核對:Spigot 使用本機 8.0_501,Paper/Folia 使用本機 25.0.4.1。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-return.json b/docs/testing/evidence/2026-10-18-command-feedback-help-return.json new file mode 100644 index 0000000..b612b23 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-return.json @@ -0,0 +1,40 @@ +{ + "recordedUtc": "2026-10-18T08:33:39.362958+00:00", + "candidate": { + "sourceCommit": "760c51a8b3ae50e172cda8218f62aa5c8b4b9de7", + "sha256": "D2669D283F5ACD0FB7AB1A9B45C398371E88EE9B0B1795A29DCCB429E1A3A012", + "bytes": 19918290, + "tests": { + "tests": 322, + "failures": 0, + "errors": 0, + "skipped": 24 + }, + "passed": 298, + "checks": [ + "Java 8/11 check shadowJar", + "permission-filtered page return, future category invariant and runtime reload back button", + "approximate player font and terminal cell frame alignment, bounded padding" + ], + "humanAcceptance": "pending" + }, + "name": "invitecode-folia-26.1.2", + "runId": "01820f515a9e4ce09d733a12215c03e3", + "port": 30101, + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\help-return-20261018-083101-9be8492c", + "done": true, + "active": true, + "dbRowsAndKeyUnchanged": true, + "worldAndProtectedFilesUnchangedDuringDeployment": true, + "otherInstances": { + "invitecode-spigot-1.8.8": "Stopped", + "invitecode-paper-26.3": "Stopped" + }, + "liveConsoleBackTargets": { + "reload": "/ic help admin 2", + "doctor": "/ic help admin 2", + "storage": "/ic help admin 2" + }, + "humanAcceptance": "pending limited Folia alignment and page return", + "noPush": true +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-help-return.md b/docs/testing/evidence/2026-10-18-command-feedback-help-return.md new file mode 100644 index 0000000..cce92d1 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-help-return.md @@ -0,0 +1,23 @@ +# 框線與父頁返回修正:Folia 局部更新 + +候選 `760c51a8b3ae50e172cda8218f62aa5c8b4b9de7`;SHA-256 `D2669D283F5ACD0FB7AB1A9B45C398371E88EE9B0B1795A29DCCB429E1A3A012`。 +Java 8/11 `mise exec [java@local-8] -- .\gradlew.bat check shadowJar --console=plain` 通過; +322 cases,298 passed、24 MySQL 條件測試 skipped,零失敗。 +先以測試重現第 2 頁返回錯誤,再驗證權限過濾後的位置、所有分類返回包含自己的頁面、 +runtime reload 按鈕與字寬近似補線、console 欄寬及補線上限。 +獨立 review 發現管理索引返回未包含管理入口,已改回 `/ic` 並補測;其餘無阻擋。 + +Folia 在本輪部署前已停止(停止防護檢查沒有送出 Stop),重新核對 Stopped、無 host、port 釋放後, +持管理鎖建立新備份 `D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\help-return-20261018-083101-9be8492c`,更新並啟動 run `01820f515a9e4ce09d733a12215c03e3`。 +當次 Done/ACTIVE、console help、reload/doctor/storage 的返回 2/2 目標均核對通過。 +世界/設定/權限在部署期間保持不變,重啟後資料庫各表與 key 仍和備份一致。 +沒有 reset/unlink、schema 變更、核心或路由更新。 +Spigot/Paper 仍停止,未部署本輪候選。沒有 push、PR、merge 或發行。 + +框線為字寬近似,不保證自訂資源包、字型、GUI scale 或窄聊天視窗像素對齊; +單次最多補 256 個線字元。Console 使用終端欄寬,玩家使用預設字型估算。 +下一步僅依 [最新 Folia 清單](../command-feedback-human-acceptance.md) 複驗框線與返回; +真人尚未通過,不啟動其他兩台或要求立即做詳細流程。 +共用規則與回歸測試涵蓋未來新增指令,沒有逐項寫死頁碼。 + +既有單一 HTML 已同步;JS 語法與 DOM stub 的 reload 返回第 2 頁檢查通過,非 Minecraft 渲染證據。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage1.md b/docs/testing/evidence/2026-10-18-command-feedback-stage1.md new file mode 100644 index 0000000..d7bd192 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage1.md @@ -0,0 +1,58 @@ +# 指令回饋第一階段:訊息與設定底層驗證 + +日期:2026-10-18。範圍為 [已核准計畫的第一階段](../../plans/command-feedback-implementation-plan.md)。本文件記錄 Agent 驗證,不是遊戲內或真人驗收。 + +## 來源與範圍 + +- base:`develop`,`5041c701f824ba5934a0647f2db52a475f503bca`;建立前已透過 `git ls-remote` 核對。 +- branch:`codex/feat/command-feedback-messages`。 +- Worktree:`D:\Code\Java\Plugin\InviteCodeKt\worktrees\feat-command-feedback-messages`。 +- 版本沿用 `0.1.0-SNAPSHOT`,沒有合併 release、修改版號、建立 Issue、push 或發布。 +- 已完成訊息呈現底層、內建語系備援、單次變數替換、prefix 配置驗證、缺檔安全復位與設定快照回歸。沒有更改 InviteCodePlugin/PlayerWorkflowController/Dialog adapter 接線。 +- 執行期語系只新增 `presentation.prefix`;完整新文案仍在 `docs/plans/*.draft.yml`。目前遊戲內輸出不會自動變成新設計。 + +## RED → GREEN 證據 + +1. 新增「動態值包含另一個 placeholder」案例,原本 `LocalizedMessages.resolve` 連續 replace 導致 AssertionFailedError;改為只掃描模板一次後通過。 +2. 新增 prefix 回覆案例,初始呈現入口沒有 prefix/色碼處理時 AssertionFailedError;完成單次 prefix、獨立行、NONE 與空 prefix 後通過。 +3. 內建備援與空 prefix 測試先分別出現 AssertionFailedError/IllegalArgumentException;完成保留自訂語系優先序的備援及 prefix 解析例外後通過。 +4. HEX/裝飾/console 測試先失敗,完成 RGB 與基本色分流、console 去裝飾及暗色處理後通過。 +5. loader 首次 load 自動補缺檔、partial catalog 備援,以及 installer 中斷寫入不留下半份目標檔先失敗;完成從 JAR 復位與暫存後發布後通過。 + +測試撰寫中曾修正 JUnit assertThrows import;這項編譯錯誤不計入行為 RED 證據。缺少內建資源原本就會明確失敗,該測試保留作回歸,不宣稱它是新增行為。 + +## 執行結果 + +| 檢查 | 結果 | +| --- | --- | +| local Java 11:`mise exec -- .\gradlew.bat check shadowJar --console=plain` | BUILD SUCCESSFUL | +| local Java 8:`mise exec java@local-8 -- .\gradlew.bat check shadowJar --console=plain` | BUILD SUCCESSFUL;有使用既有 Gradle cache,受影響訊息/設定測試實際重跑 | +| Java 8 bytecode 與插件 JAR 內容驗證 | 隨 check 通過 | +| 最終 XML 報告 | 58 suites,280 個已報告案例;0 failure、0 error、3 skipped,即 277 通過 | +| 本輪直接相關測試 | LocalizedMessages 5、MessagePresentation 6、RuntimeConfigurationAssembler 5、BukkitConfigurationLoader 6、BundledConfigurationInstaller 3、MessageConfigurationStageOne 2,共 27,皆通過 | +| `git diff --check` | 通過 | + +獨立子代理唯讀審查已覆核實際共享 Worktree 的 formatter、fallback、loader/installer 與測試,沒有保留已確認的實質問題。曾提出動態值解析疑慮,重新讀取實際呼叫與解析順序後確認是誤讀並撤回;主 Agent 同時核對了完整 production diff 與測試結果。審查不代替 runtime/真人驗收。 + +工具鏈實際為 local-11 的 Java 11.0.32,以及 local-8 的 Java 1.8.0_501;沒有安裝或修改全域工具鏈。MySQL 測試的 host/password 僅在當次程序清空,以保證不連線未核對的 DB;MySQL 相關動態測試可能在產生案例前跳過,最終 XML 的 3 skipped **不是**所有未執行 MySQL 情境數量。此輪不能宣稱 MySQL 整合已驗證。 + +原始 XML/HTML 保留在各 module 的 `build/test-results/test/` 與 `build/reports/tests/test/`。後續重跑可能更新這些 build 報告;本文件保留本輪結果摘要。 + +## 重要回歸邊界 + +- 動態字串 `�&l{status}` 保持字面文字,不會改色、加粗或展開其他變數;樣式片段與純文字分開保存,後續 adapter 不能重新解析這些動態值。 +- 同列/獨立行 prefix 只加一次,空 prefix/只有樣式的 prefix 不產生空格或空行;prefix 的樣式不漏到正文。 +- 舊版 HEX 使用既有近似基本色策略;console 保留成功/提醒/錯誤色彩、去除裝飾,近黑轉灰,其他過暗色在標準黑底可讀基本色中選最近值。 +- 備援順序為自訂玩家語系→自訂預設語系→內建玩家語系→內建預設語系。每個快照的相同查詢語系/鍵只對內建備援警告一次。 +- 已有設定、損壞設定、自訂語系、資料庫與 anti-abuse key 保留;寫入失敗不留下半份目標檔。新測試用 @TempDir 中的合成資料,不接觸既有資料或金鑰。 +- 用真實 loader、MessagePresenter 與 AtomicRuntimeSnapshot 組合驗證:有效候選可安裝,損壞替代檔不改寫磁碟內容,也不取代前一份快照。 + +## 本機產物與限制 + +- JAR:`invitecode-plugin/build/libs/InviteCode-0.1.0-SNAPSHOT.jar`。 +- SHA-256:`C3A1482EB94A45D264A26C1FA241997B17DBC44EE9B6A134B1C61606689A8837`。 +- 大小:19,855,807 bytes。 +- 不變更 F205/1.0.0 發行候選及其歷史驗收證據,不將此產物部署到 Human 測服。 +- 沒有啟動 Minecraft/InstanceHarbor、沒有隔離關服測試、沒有 MySQL 連線、沒有遊戲內截圖或真人驗收。 + +第一階段完成後,下一步建議依計畫第二階段接入指令、聊天、help、status/stats、Dialog 與 MESSAGE 獎勵,並套用完整雙語文案。使用者此次只授權第一階段;第二階段尚未開始,需另行確認。推送與 PR 也仍未授權。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage2.md b/docs/testing/evidence/2026-10-18-command-feedback-stage2.md new file mode 100644 index 0000000..05ca40b --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage2.md @@ -0,0 +1,74 @@ +# 指令回饋與 messages:第二階段證據 + +日期:2026-10-18。範圍為[實作計畫第二階段](../../plans/command-feedback-implementation-plan.md#第二階段輸出整合與封裝)。本機實作與 Agent 檢查完成;真實核心矩陣及集中真人驗收仍未執行。這不是新產物的使用者驗收或發布紀錄。 + +## 版本與授權邊界 + +- 基線 develop:`5041c701f824ba5934a0647f2db52a475f503bca`。 +- 沿用 branch `codex/feat/command-feedback-messages`;第一階段 checkpoint `d6442a934436fd0c4186b6eb0c1ac958ccd980af`。 +- Worktree:`D:\Code\Java\Plugin\InviteCodeKt\worktrees\feat-command-feedback-messages`。 +- 本文件與第二階段程式碼一起提交;最終 checkpoint 用該提交識別,避免把前一階段 commit 誤認為本輪產物版本。 +- 使用者已授權第二階段本機實作/測試,明確暫不 push。沒有 GitHub write、PR、merge、tag 或發布,也沒有部署 Human、啟動伺服器或修改 InstanceHarbor。 +- `repo/` 保持 develop;既有 release Worktree、F205、歷史驗收、固定 Human 世界及資料不變。關服終端例外繼續暫緩,沒有隔離測試。 + +## 完成的輸出路徑 + +- 一般指令、reload/doctor、管理查詢、多行 status/stats、聊天、Dialog 及 MESSAGE 資格通知使用同一份已解析文字片段;一份完整回覆只加一次 prefix。logger 不額外加 prefix。 +- help 對照全部 20 個 parser route ID,保留 `/ic`、`admin reload` 別名,依權限與玩家身分篩選;玩家用法只用 `SUGGEST_COMMAND` 填入。說明是獨立受信任模板,重設樣式不繼承用法列粗體。 +- 聊天確認使用七個邏輯區塊,prefix 獨立無尾空白、期限不帶冒號,綠紅同意/不同意及 hover 不另加 prefix。空 prefix 不留空白行;Dialog 改用有意義的標題且不重複正文標題。 +- code 點擊只套在真正 `{code}` 片段,不會誤套到恰好相同的文字。payload 保持原始邀請碼;舊版填入聊天列,新版使用可用的剪貼簿 action。邀請碼保留 HEX 顏色彩蛋。 +- 完整繁中/英文資源套用,鍵與變數對等。已有自訂檔不覆寫,缺鍵、缺檔復位及失敗保留快照沿用第一階段測試與契約。 +- 動態值不重新解析格式或變數,輸出邊界處理 section sign 與控制字元;不改命令 payload、領域狀態、儲存 schema 或外部獎勵冪等性。Console 使用可讀基本色、不額外套裝飾,不自行發送 ANSI。 + +## 測試方法與案例 + +輸出 adapter 的測試先觀察到舊實作缺少色彩/樣式邊界的兩項失敗;help 測試先觀察到舊 help 缺說明、分類及 click 的三項失敗。再完成最小實作。編譯錯誤、fixture 錯誤與後續新增的測試不算作行為 RED 證據。 + +新增/擴充案例涵蓋: + +- `CommandHelpTest`:20 個路由的唯一性、parser metadata、root/reload 別名。 +- `RuntimeCommandHelpTest`:一般玩家、部分管理權限、完整管理員、Console、僅共用 help 而沒有空分類、所有重複 usage placeholder 都只建議指令、自訂說明色彩與 reset。 +- `RuntimeCommandOutputTest`:Console 的玩家專用指令拒絕有 prefix/色彩,doctor 仍可執行。 +- `BukkitMessageOutputTest`:基本色、樣式隔離、Console 無粗體或控制字元、玩家動態值不重解析。 +- `BundledMessageCatalogTest`:實際兩份 YAML 的完整鍵/變數對等,20 個 help 說明鍵存在,期限不帶冒號。 +- `PlayerMessageLayoutsTest`:實際 loader 的雙語版面、七區塊、空 prefix、RGB、同字面邀請碼不誤綁 click、status 原因只用一份 prefix。 +- `PlayerWorkflowPresentationIntegrationTest`:真實 controller、背景 executor 與暫存 SQLite,配合可控排程/Player proxy,走 code、私密聊天、確認一次、取消、逾時、status/stats、重複 claim 前置拒絕。 +- `RewardMessagePresentationTest`:真實 Bukkit reward environment 發送一次有 prefix 的資格通知;離線不呼叫輸出,保留 `RECIPIENT_OFFLINE`。既有 reward state/offline recovery 測試繼續通過。 +- `ReflectiveNativeDialogInputTest`:typed request 及 callback、關閉/失敗 fallback、原文值、樣式片段及 reset。Adventure 使用可控組件替身;Bungee 使用實際測試依賴反射方法,並修正 Boolean setter 必須查 boxed `Boolean` 的問題。 +- 既有 tab、設定復位/reload、儲存、隱私、獎勵與 JAR 驗證繼續由完整 `check` 覆蓋。 + +這些組合測試沒有啟動 Minecraft,不能當成客戶端 E2E 或真人外觀驗收。 + +## 建置與產物 + +工具鏈由 mise 選用既有 `local-11`(11.0.32)與 `local-8`(1.8.0_501),沿用 Gradle Wrapper,沒有安裝 JDK 或新增 production dependency。兩次測試均在子程序明確清空 `INVITECODE_TEST_MYSQL_HOST` 與 `INVITECODE_TEST_MYSQL_PASSWORD`;不連既有 MySQL。 + +```powershell +mise exec -- .\gradlew.bat check shadowJar --rerun-tasks --console=plain --quiet +mise exec java@local-8 -- .\gradlew.bat check shadowJar --rerun-tasks --no-build-cache --console=plain +``` + +兩個 JDK 的完整 `check shadowJar` 均 exit 0,66 suites、304 項中 280 通過、24 跳過、0 failure/error。後續只新增一般玩家及完整管理員兩項 help 案例,於兩個 JDK 以 `:invitecode-plugin:test --no-build-cache` 重跑完整 plugin 測試,均 exit 0,help 六項全數通過。最終合併未變更模組及受影響 plugin 的報告為 66 suites、306 項中 **282 通過、24 跳過、0 failure/error**。MySQL 動態 factory 也可能在產生案例前跳過;報表數量不代表完成 MySQL 整合。 + +初次 Java 8 clean 檢查使用了 Gradle cache,MySQL skip 計數與 Java 11 不同,因此沒有採用該次計數或將其宣稱為實際執行證據。重新以 `--rerun-tasks --no-build-cache` 執行後,35 個 actionable tasks 全數執行,與 Java 11 的 skip 結果一致。這輪沒有連線 MySQL。 + +- 最終 JAR:`invitecode-plugin/build/libs/InviteCode-0.1.0-SNAPSHOT.jar`。 +- SHA-256:`E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B`。 +- 大小:19,890,059 bytes。 +- `verifyPluginJar`/`verifyJava8Bytecode` 通過:plugin.yml 為 ASCII/有效 UTF-8、產品名 InviteCode、api-version 1.13,設定只放 JAR `config/` 路徑,必要驅動及資源存在,class major ≤ 52,Gson relocation/Vault 隔離邊界保留。兩語 YAML 另由實際 parser 測試核對。 +- 完整 diff 主審及獨立唯讀輸出路徑審查未發現未解決的 Critical/High 問題;`git diff --check` 通過。僅有 Gradle 既有 deprecation 及測試 proxy 泛型 cast 等警告。 +- 主要 HTML 閱讀入口沿用既有 messages 設計頁,更新第二階段狀態;Node 語法檢查、ID 唯一性、章節 anchor、本機來源連結及 JS 控制目標檢查通過。保留原右緣懸浮捲軸、鍵盤及拖曳程式;本輪沒有瀏覽器排版驗證,不把靜態檢查當作畫面證據。 + +## Dialog 置中的直接依據與限制 + +原生 Paper/Spigot adapter 使用 `plain_message` 訊息區塊,不加入補空格或每秒重畫。確認按鈕以文字綠/紅呈現,背景沿用原生客戶端外觀。 + +透過本機官方啟動器的 26.2 metadata 取得[官方 client artifact](https://piston-data.mojang.com/v1/objects/2dc72797acbc1b63fc16a11c4ac393605f453754/client.jar),以有上限的 HTTP Range/ZIP 讀取單一 `DialogBodyHandlers$PlainMessageHandler.class`,核對 entry 大小及 CRC32 `c0860c20`。class SHA-256 為 `669DC72E37506CB804C8EFDC7756075856696E70838ACC9FBC95229958B59F99`。 + +使用既有 `java@local-27` 的 `javap -c -p` 讀取該類別;`createControls` 在 bytecode offset 31 載入 true,offset 32 呼叫 `FocusableTextWidget.setCentered(boolean)`。這提供 26.2 原生訊息區塊置中的直接機制證據;沒有下載或驗證完整 client JAR SHA-1,也沒有啟動客戶端。單一 class 暫存隨本輪 clean 清除,不提交官方 class。 + +26.3、舊版 fallback、不同視窗寬度/字型的實際排版及兩個反射 adapter 的完整 runtime 能力,仍須第三階段核心矩陣與第四階段真人核對。HTML 示意、mock callback、純 JVM 測試與此單一類別證據均不代替這些驗收。 + +## 下一個里程碑 + +依實作計畫「第三階段:Agent 真實核心矩陣」,下一步是先唯讀核對八個 profile、現有核心/JDK/hash、未占用 port 與 Agent 資料隔離,再執行對應測試;目前只完成第二階段,尚未執行第三階段。矩陣完成後,才能交付綁定新 commit/JAR 的集中真人清單。未取得新授權前不啟動後續階段、不 push。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage3.json b/docs/testing/evidence/2026-10-18-command-feedback-stage3.json new file mode 100644 index 0000000..4b75127 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage3.json @@ -0,0 +1,263 @@ +{ + "date": "2026-10-18", + "runtimeCommit": "dfbc39c4a80cea91b22b88c5f89d16107e7d50a2", + "pluginSha256": "E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B", + "scope": "stage3 automated runtime checks, not visual or human acceptance", + "profiles": [ + { + "profile": "spigot-1.8.8", + "implementation": "SPIGOT", + "minecraftVersion": "1.8.8", + "build": "local-buildtools", + "coreSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "javaAlias": "local-8", + "port": 51888, + "dialog": "NONE", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "spigot-1.12.2", + "implementation": "SPIGOT", + "minecraftVersion": "1.12.2", + "build": "local-buildtools", + "coreSha256": "CA59A730F5B1C2E85A2ABE907D9689CC2636BE0200F333C1E1B87E2D620D8513", + "javaAlias": "local-8", + "port": 51222, + "dialog": "NONE", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "spigot-1.16.5", + "implementation": "SPIGOT", + "minecraftVersion": "1.16.5", + "build": "local-buildtools", + "coreSha256": "C738DCB9AC8114228107BB4CDA97BFEC62A243C99FE0E7C6CAF9D424BD1EF93C", + "javaAlias": "local-8", + "port": 51650, + "dialog": "NONE", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "spigot-latest", + "implementation": "SPIGOT", + "minecraftVersion": "26.3", + "build": "local-buildtools", + "coreSha256": "E0B82659EAB415F49A40DE3444B1F0E12FA919BDEBB3171D985D4DB101DDB089", + "javaAlias": "local-25", + "port": 52620, + "dialog": "SPIGOT", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "paper-1.20.6", + "implementation": "PAPER", + "minecraftVersion": "1.20.6", + "build": "151", + "coreSha256": "4B011F5ADB5F6C72007686A223174FCE82F31AEB4B34FAF4652ABC840B47E640", + "javaAlias": "local-21", + "port": 62060, + "dialog": "NONE", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "paper-1.21.8", + "implementation": "PAPER", + "minecraftVersion": "1.21.8", + "build": "60", + "coreSha256": "8DE7C52C3B02403503D16FAC58003F1EFEF7DD7A0256786843927FA92EE57F1E", + "javaAlias": "local-21", + "port": 62180, + "dialog": "PAPER", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "paper-latest", + "implementation": "PAPER", + "minecraftVersion": "26.3", + "build": "203", + "coreSha256": "0FCB63F341ABE5D8370D354BB2E39D47C917D8010C817F4567F89E97B5C3ECF9", + "javaAlias": "local-25", + "port": 62620, + "dialog": "PAPER", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + }, + { + "profile": "folia-latest", + "implementation": "FOLIA", + "minecraftVersion": "26.1.2", + "build": "8", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "javaAlias": "local-25", + "port": 63620, + "dialog": "PAPER", + "smoke": "passed", + "snapshotAudit": "passed", + "processesExited": true, + "portReleased": true, + "checks": [ + "cycle1 doctor/help/prefix/no-format-leak", + "reload restores missing bundled locale", + "cycle2 doctor/help/prefix/no-format-leak", + "failed reload rejects invalid file; active snapshot verified by separate audit", + "restart preserves SQLite/key/custom locale and restores missing rewards" + ] + } + ], + "protocolTests": [ + { + "profile": "paper-1.21.8", + "phase": "claim", + "result": "passed", + "checks": [ + "native input submit/cancel callbacks", + "native confirmation labels and payload", + "native decline/timeout/confirm callbacks", + "code raw payload and hover", + "help suggests without running", + "qualification MESSAGE once", + "already claimed preflight before UI" + ], + "client": "mineflayer 4.39.0 / minecraft-protocol 1.68.0", + "visualAcceptance": false + }, + { + "profile": "paper-1.21.8", + "phase": "reward", + "result": "passed", + "checks": [ + "offline MESSAGE delivered once after restart", + "stats qualified one" + ], + "client": "mineflayer 4.39.0 / minecraft-protocol 1.68.0", + "visualAcceptance": false + }, + { + "profile": "spigot-1.8.8", + "phase": "claim", + "result": "passed", + "checks": [ + "private chat cancel", + "seven logical confirmation sections", + "chat decline/timeout/confirm", + "code raw payload and hover", + "help suggests without running", + "qualification MESSAGE once", + "already claimed preflight before UI" + ], + "client": "mineflayer 4.39.0 / minecraft-protocol 1.68.0", + "visualAcceptance": false + }, + { + "profile": "spigot-1.8.8", + "phase": "reward", + "result": "passed", + "checks": [ + "offline MESSAGE delivered once after restart", + "stats qualified one" + ], + "client": "mineflayer 4.39.0 / minecraft-protocol 1.68.0", + "visualAcceptance": false + } + ], + "limitations": [ + "Folia 26.3 ALPHA unverified; user approved 26.1.2 STABLE fallback (upstream unsupported)", + "No rendered client/hover/clipboard/alignment acceptance", + "Paper/Spigot 26.3 native Dialog client flow unverified" + ], + "humanTouched": false, + "velocityTouched": false, + "productCodeChanged": false, + "remoteWrites": false, + "cleanup": { + "taskOwnedPath": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\feat-command-feedback-messages\\.run\\command-feedback-stage3\\data", + "createdNew": true, + "activeRuntimeProcesses": 0, + "exitReceipts": 34, + "acceptedLaunchTickets": 34, + "portsReleased": [ + 51888, + 51222, + 51650, + 52620, + 62060, + 62180, + 62620, + 63620 + ], + "logicalBytesRetained": 1822741677.0, + "state": "retained-cleanup-blocked", + "reason": "Automatic approval review rejected recursive removal: blocked by policy; no detailed reason supplied", + "deletionPerformed": false, + "preservedRoot": "D:\\Code\\Java\\Plugin\\InviteCodeKt\\worktrees\\feat-command-feedback-messages\\.run\\command-feedback-stage3" + } +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage3.md b/docs/testing/evidence/2026-10-18-command-feedback-stage3.md new file mode 100644 index 0000000..fce60e6 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage3.md @@ -0,0 +1,97 @@ +# 訊息顯示第三階段:真實核心矩陣 + +日期:2026-10-18。受測 runtime commit 為 `dfbc39c4a80cea91b22b88c5f89d16107e7d50a2`,JAR SHA-256 為 `E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B`,大小 19,890,059 bytes。後續本輪文件提交不改動 runtime/JAR。 + +使用者授權沿用 `codex/feat/command-feedback-messages` 與既有 Worktree 進行第三階段,明確暫不 push。本輪不部署 Human、不改管理器程式、不接人工 Velocity,也不處理已暫緩的 ConPTY 關服問題。 + +## 結果與限制 + +八個選定核心已通過兩輪啟停、Console help/doctor/reload、缺檔復位、自訂語系保留及空服重啟後 SQLite/key 一致性檢查。額外八份 audit 也通過實際 failed reload 後的 ACTIVE/同 generation 及退出核對。實際 provider、完整核心 hash 與資源狀態見[機器可讀摘要](2026-10-18-command-feedback-stage3.json)。這輪沒有修改產品程式,因此沒有重新建置不同的 JAR。 + +Spigot 1.8.8 完成真實網路連線的私密聊天、確認、資格及重啟後離線 MESSAGE 補發。Paper 1.21.8 完成原生輸入提交/取消、確認不同意/逾時/同意的實際回呼,以及重啟後的離線 MESSAGE 補發;兩者 help、code payload、重複 claim 前置拒絕亦通過。封包內容不等於客戶端畫面、置中、滑鼠 hover 或剪貼簿操作驗收。 + +**保留兩項缺口:** + +- Folia 26.3 build 3 為 ALPHA,現行管理器只接受 STABLE。使用者已明確同意測最後找到的 STABLE Folia 26.1.2 build 8,保留最新 Folia 未驗證;該舊版本目前已停止上游支援。此結果不能宣稱 Folia 26.3 相容。 +- `mct 0.20.1` 的 `client list` 為空;`client search --loader fabric --version 26.3` 及 `1.21.8` 無變體,26.2 可查到 Fabric 變體但本機未建立客戶端。本輪不安裝新依賴/客戶端,也沒有截圖、真實 GUI 或真人操作。Paper/Spigot 26.3 的 Dialog 開啟、點擊與外觀仍須後續驗收。 + +## 核心、JDK 與 port + +| Matrix profile | 本輪鎖定核心 | JDK(mise alias) | Port | +| --- | --- | --- | --- | +| spigot-1.8.8 | Spigot 1.8.8,git-Spigot-3c60ece-741a1bd | local-8:1.8.0_501 | 51888 | +| spigot-1.12.2 | Spigot 1.12.2,git-Spigot-79a30d7-f4830a1 | local-8:1.8.0_501 | 51222 | +| spigot-1.16.5 | Spigot 1.16.5,3096a-Spigot-9fb885e-af1a232 | local-8:1.8.0_501 | 51650 | +| spigot-latest | Spigot 26.3,4663-Spigot-bed90fc-c4db4c3 | local-25:25.0.4.1 | 52620 | +| paper-1.20.6 | Paper 1.20.6 build 151 | local-21:21.0.12.1 | 62060 | +| paper-1.21.8 | Paper 1.21.8 build 60 | local-21:21.0.12.1 | 62180 | +| paper-latest | Paper 26.3 build 203 | local-25:25.0.4.1 | 62620 | +| folia-latest | Folia 26.1.2 build 8;經同意的 STABLE 替代範圍 | local-25:25.0.4.1 | 63620 | + +Spigot 固定版本從 `D:\Code\Java\Plugin\BuildTools\Server\` 重用,沒有重新編譯或改寫 BuildTools。26.3 使用 `spigot-26.3-build4663.jar`;核對其 bundler 內嵌 JAR 的 `Implementation-Version`、版本與 refs,再與[官方 26.3 metadata](https://hub.spigotmc.org/versions/26.3.json)比對。`latest.json` 當時仍指向較舊的 4648,沒有將它直接當成最新 26.3 身分。 + +Paper/Folia 依[官方 Paper API](https://fill.papermc.io/v3/projects/paper)及[Folia API](https://fill.papermc.io/v3/projects/folia)核對版本與 build channel。三個既有 launcher 的 SHA-256 與官方一致;Paper 26.3 build 203 尚未在既有 cache,透過管理器下載到本輪隔離 cache 並核對官方 SHA-256。完整 hash 與 metadata 保存於同名 JSON 摘要。 + +Java 先透過 mise 核對實際版本及 alias 的 junction 目標,再把 `C:\Program Files\Java\` 下的實體 `java.exe` 登記到本輪專用 runtime registry;不把 junction 路徑交給管理器,也不改全域 mise/Java 設定。管理器依既有契約直接呼叫核對過的實體 JDK。 + +## 資料與生命週期邊界 + +使用 InstanceHarbor 現行 C# `Prepare`/`Start`/`Command`/`Stop`/`Status`,不使用舊 runner 的直接 Java 啟停。CLI 為既有 portable Basic: + +```text +D:\Code\Java\Plugin\InstanceHarbor\worktrees\refactor-csharp-management-baseline\artifacts\portable-20261005-090638-9e19b49e\basic\InstanceHarbor.exe +SHA-256 D79B8F380C35982B2C457731B3DCDE084B30CA2578BB6C624FD36CE7642FBAAD +``` + +本輪專屬資料根為功能 Worktree `.run/command-feedback-stage3/data`,政策/profile 根為相鄰 `config/`。掃描僅允許 `Agent/InviteCode`;每台實例位於: + +```text +/instances/Agent/InviteCode/messages-dfbc39c-/ +``` + +建立前確認八個 matrix port 都沒有 listener,且新目錄不存在;逐台檢查 schema 2/Agent metadata、JAR hash、loopback/offline mode、port 及 reparse point 邊界。不覆寫既有實例。既有設定曾重用 matrix port,故只將它們視為本輪未監聽的 Agent 測試 port,不宣稱取得 Human 槽位或路由。 + +現行管理器沒有已發布的共用 libraries adapter,因此採明確、有上限的隔離模式:重用既有 launcher/固定 LuckPerms 來源並核對副本 hash,各台 libraries、world、remap cache、plugins、SQLite、設定、log 與執行狀態獨立。新 Agent 依既有政策安裝 LuckPerms;不改 Human 或共用 manager settings。啟動模式為 Detached,不做 ConPTY 隔離測試。 + +開始時 C 約 56 GiB、D 約 51 GiB 可用;本輪峰值預算 8 GiB,要求至少 10 GiB 餘量,依序測試,必要的兩個不同 port 任務可並行。可重建 runtime 在退出與證據保存後回收;候選 JAR、Worktree、腳本、小型摘要與必要 log 保留,實際回收結果見 JSON。 + +最終核對共有 **34 個 accepted launch ticket 與 34 份相符退出 receipt**(包含首輪測試錯誤及補驗),均 child exit 0、outputDrained;所有本輪 Manager/Host/Java 程序已退出,八個 port 均無 listener。原始 log、receipt、metadata、Dialog JSON、腳本與本輪 config 保留於 `.run/command-feedback-stage3/`。 + +**資源回收尚未完成:**自動核准審查拒絕刪除本輪 `data/`,只提供 `blocked by policy`,沒有更具體理由。沒有改用其他方式刪除;目前保留 1,822,741,677 bytes(約 1.70 GiB)的可重建資料,沒有將其回報為已回收。程序停止/port 釋放已完成,磁碟清理與真人驗收仍分別列為未完成。 + +## 可重現檢查流程 + +每個 profile 使用同一個 JAR: + +1. `Prepare` 記錄明確 profile/build、插件 hash、JDK、Agent 路徑及 port,manager `List` 核對八台可見。 +2. 第一次啟動等待插件啟用及核心 Done,再查 doctor ACTIVE、外部整合關閉、預期 Dialog provider。Console help 有完整管理用法、只一份 prefix,沒有玩家專用用法或外洩格式碼。 +3. 移開本輪自己的 zh_TW,reload 後與原內建檔逐位元組比對。正常停止,核對退出 receipt 與程序/port,保存空服 SQLite/key hash。 +4. 把本輪 en_US prefix 改成 `[Matrix]` 並切英文,移開本輪 rewards.yml。重新啟動檢查缺檔復位、英文明確回饋與自訂語系不被覆寫。 +5. 在本輪設定寫入無效 timeout;reload 拒絕且不覆寫壞檔。額外稽核實際查 doctor,確認仍為 ACTIVE、相同 configuration generation 及先前 `[Matrix]` 訊息;恢復原始位元組後 reload 成功。 +6. 正常停止後,退出 receipt 與當次 run、host、Java PID/啟動時間綁定,確認 exit 0、outputDrained、程序退出及 port 釋放。空服兩輪 DB/key hash 一致,key 保持 32 bytes;不輸出 key 本文。 + +不把 CLI 的 accepted、exit code 或 listening 單獨當作通過;結果須由逐 profile 斷言、log、receipt 與最終機器可讀摘要共同核對。 + +## 玩家與 Dialog 傳輸測試 + +重用已存在的 `mineflayer 4.39.0`/`minecraft-protocol 1.68.0`/`prismarine-nbt`,不修改或安裝它們。測試暫時設定相同網路 `ALLOW`、三秒確認期限及登入一天達資格,限本輪 Agent 資料;測後復原設定。 + +- 邀請人 `IcMsgA` 查看 code,檢查 raw code click payload/hover;help 的七項玩家用法皆為 suggest,不立即執行。邀請人離線。 +- 受邀人 `IcMsgB` 測 cancel/不同意/逾時/同意,再驗證 status、資格通知一次及已登記者再次 claim 先拒絕、不開 UI;旁觀合成帳號檢查聊天室未公開邀請碼。 +- 重啟後邀請人登入,只收到一次資格 MESSAGE,stats 為一筆 qualified。Console 核對 pending 由 1 變 0。 +- Paper 1.21.8 保存原生輸入/確認的實際 S2C Dialog JSON,核對 title、五個正文區塊、綠紅標籤及 raw code 顏色;回傳 custom action 的結果另見最終摘要。 + +此為真實核心上的網路/回呼證據,並非渲染客戶端;沒有把伺服器指令、合成 callback、封包或 HTML 當成點擊外觀驗收。 + +成功條件同時由網路回覆與 Console pending ledger 核對;第一階段玩家流程結束後 pending=1,正常停止再啟動,邀請人登入後 pending=0。被拒絕的首輪封包不計入成功結果;最後兩個完整流程均以正常 stop、相符 receipt、host/Java 退出及 port 釋放收尾。 + +## 首輪失敗與測試修正 + +- Paper/Folia 的 ANSI 會穿插 prefix 各色段,首輪原文比對失敗。保留原始 log 與 first-attempt JSON,只在文字斷言前正規化 ANSI;複驗成功。這不是修改產品以迎合測試。 +- 1.21.8 首次 native cancel 被核心 decoder 拒絕。實際核心 `ServerboundCustomClickActionPacket` bytecode 顯示 optional tag 經 `lengthPrefixed(65536)` 包裝;既有測試套件 schema 缺少此長度且以 boolean option 描述。只在本輪封包 adapter 按受測 codec 編碼,保留依賴不變。首輪拒絕發生在插件事件之前,不能計為插件 callback 通過。 +- 第二次確認字句比對以 JSON 原文搜尋,未考慮 `{seconds}` 已拆成有樣式的組件,改以組件的 text/extra 組合後核對五段正文;保留接收 JSON。這是測試結構修正,不改文字契約。 +- 獨立審查補強 runner 的失敗退出碼、receipt/PID/port 綁定、設定復原及 failed reload 後 doctor。先前只看 reload 失敗回覆的證據不單獨作為保留快照的結論。 + +## 下一步 + +依[實作計畫第四階段](../../plans/command-feedback-implementation-plan.md#第四階段集中一次的真人外觀驗收),Agent 可執行範圍完成後,建議交付綁定此 JAR 的集中真人清單,先核對既有固定 Spigot 1.8.8、Paper 26.3、Folia 26.1.2 的實際版本/路由,再經明確部署安排更新目標插件。前幾輪真人結果保持原產物綁定;新 prefix、色彩、置中、hover、剪貼簿與按鈕外觀須重新驗收。本輪沒有開始部署、真人操作或 remote write。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.json b/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.json new file mode 100644 index 0000000..576c381 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.json @@ -0,0 +1,173 @@ +{ + "date": "2026-10-18", + "checkedAtUtc": "2026-10-18T06:41:39.978512+00:00", + "sourceCheckpoint": "5af0cb5", + "runtimeCommit": "dfbc39c4a80cea91b22b88c5f89d16107e7d50a2", + "state": "deployed-started-agent-verified-awaiting-human", + "instances": [ + { + "name": "invitecode-spigot-1.8.8", + "port": 10101, + "core": "SPIGOT", + "minecraftVersion": "1.8.8", + "build": "git-Spigot-3c60ece-741a1bd", + "pluginSha256": "E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8\\.invitecode-backups\\command-feedback-20261018-063038-46e9c986", + "backupFileCount": 19, + "backupHashesVerified": true, + "worldDataIncludedInBackup": false, + "worldHeadersUnchangedDuringDeployment": true, + "keyPreserved": true, + "schema": 9, + "runId": "cafed55c7b0a4ea7971c50b5425b239f", + "hostPid": 67624, + "childPid": 67844, + "javaExecutable": "C:\\Program Files\\Java\\jdk1.8.0_501\\bin\\java.exe", + "mode": "ConPty", + "state": "Listening", + "coreDone": true, + "dialog": "NONE", + "agentCommandChecks": [ + "doctor ACTIVE", + "help new prefix", + "console player-only refusal", + "valid reload", + "UTF8 log" + ], + "B": { + "generationBefore": 0, + "generationAfter": 1, + "claimWindowExpiresTaipei": "2026-10-19T14:38:24.123000+08:00" + }, + "historicalInvitations": { + "QUALIFIED": 1 + }, + "historicalRewardActions": { + "DELIVERED": 2 + }, + "auditRecordsAdded": 1, + "newInvitationsCreatedByAgent": 0, + "qualificationTestMode": "immediate-basic-permission; A leaves before final confirmation", + "sameNetworkTestSetting": "ALLOW", + "sameNetworkOriginalSetting": "DENY", + "humanAcceptance": "pending" + }, + { + "name": "invitecode-paper-26.3", + "port": 20102, + "core": "PAPER", + "minecraftVersion": "26.3", + "build": "202", + "pluginSha256": "E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3\\.invitecode-backups\\command-feedback-20261018-063038-0f8a0cca", + "backupFileCount": 18, + "backupHashesVerified": true, + "worldDataIncludedInBackup": false, + "worldHeadersUnchangedDuringDeployment": true, + "keyPreserved": true, + "schema": 9, + "runId": "6d0f3f9d678c4b3cb2c8c61383f8cc35", + "hostPid": 51620, + "childPid": 25144, + "javaExecutable": "C:\\Program Files\\Java\\jdk-25.0.4.1\\bin\\java.exe", + "mode": "ConPty", + "state": "Listening", + "coreDone": true, + "dialog": "PAPER", + "agentCommandChecks": [ + "doctor ACTIVE", + "help new prefix", + "console player-only refusal", + "valid reload", + "UTF8 log" + ], + "B": { + "generationBefore": 0, + "generationAfter": 1, + "claimWindowExpiresTaipei": "2026-10-19T14:38:26.428722+08:00" + }, + "historicalInvitations": { + "QUALIFIED": 1 + }, + "historicalRewardActions": { + "DELIVERED": 2 + }, + "auditRecordsAdded": 1, + "newInvitationsCreatedByAgent": 0, + "qualificationTestMode": "manual invitecode.test.qualified false; grant after A leaves", + "sameNetworkTestSetting": "ALLOW", + "sameNetworkOriginalSetting": "ALLOW", + "humanAcceptance": "pending" + }, + { + "name": "invitecode-folia-26.1.2", + "port": 30101, + "core": "FOLIA", + "minecraftVersion": "26.1.2", + "build": "8", + "pluginSha256": "E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B", + "backup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\command-feedback-20261018-063038-7d440eea", + "backupFileCount": 19, + "backupHashesVerified": true, + "worldDataIncludedInBackup": false, + "worldHeadersUnchangedDuringDeployment": true, + "keyPreserved": true, + "schema": 9, + "runId": "d307427bd85845bf8e6cf7030d8ad668", + "hostPid": 74236, + "childPid": 72296, + "javaExecutable": "C:\\Program Files\\Java\\jdk-25.0.4.1\\bin\\java.exe", + "mode": "ConPty", + "state": "Listening", + "coreDone": true, + "dialog": "PAPER", + "agentCommandChecks": [ + "doctor ACTIVE", + "help new prefix", + "console player-only refusal", + "valid reload", + "UTF8 log" + ], + "B": { + "generationBefore": 0, + "generationAfter": 1, + "claimWindowExpiresTaipei": "2026-10-19T14:38:31.389488+08:00" + }, + "historicalInvitations": { + "UNLINKED": 1 + }, + "historicalRewardActions": {}, + "auditRecordsAdded": 2, + "newInvitationsCreatedByAgent": 0, + "qualificationTestMode": "manual invitecode.test.qualified false; grant after A leaves", + "sameNetworkTestSetting": "ALLOW", + "sameNetworkOriginalSetting": "DENY", + "humanAcceptance": "pending" + } + ], + "preservedSharedServices": [ + { + "name": "Velocity", + "state": "Listening", + "runId": "0469c7f626414832877e4f3fd998ad12" + }, + { + "name": "lobby", + "state": "Listening", + "runId": "172f6e972128449f8b6cc515525a390d" + } + ], + "notTouched": [ + "Paper26.2 Human", + "Velocity routes", + "shared global settings", + "InstanceHarbor product code" + ], + "limitations": [ + "client rendering/click/copy not verified", + "Spigot LP JSON permission writes fail due existing Gson mismatch; failed new file quarantined; no LP writes required in current Spigot test", + "Paper26.2 isolated adapter retest pending", + "Folia26.3 ALPHA not verified" + ], + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.md b/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.md new file mode 100644 index 0000000..c439418 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage4-deployment.md @@ -0,0 +1,82 @@ +# 第四階段:三台固定測服部署與啟動 + +2026-10-18 使用者明確授權停服備份後部署三台、重設 B、解除 Folia 指定舊 CLAIMED, +保留歷史與稽核,再啟動核對;暫不 push。沿用 `codex/feat/command-feedback-messages` 與原 Worktree。 +程式來源仍為 `dfbc39c`,沒有重建 JAR;部署來源 checkpoint `5af0cb5`。 + +## 完成結果 + +三台已裝唯一的 `InviteCode-0.1.0-SNAPSHOT.jar`,SHA-256: +`E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B`。 +完整雙語 messages 已部署;storage、rewards、密鑰原值保留。 +實際 build/JDK/當次 run/備份位置見[機器可讀證據](2026-10-18-command-feedback-stage4-deployment.json)。 + +| 固定測服 | 本輪實際核心 | 實際 JDK | Port | 啟動/doctor | +| --- | --- | --- | --- | --- | +| invitecode-spigot-1.8.8 | git-Spigot-3c60ece-741a1bd | 1.8.0_501 | 10101 | Done、ACTIVE、Dialog NONE | +| invitecode-paper-26.3 | Paper 26.3 build 202 | 25.0.4.1 | 20102 | Done、ACTIVE、Dialog PAPER | +| invitecode-folia-26.1.2 | Folia 26.1.2 build 8 | 25.0.4.1 | 30101 | Done、ACTIVE、Dialog PAPER | + +三台目前 Managed/Listening/ConPTY,當次核心版本來自新啟動 log;Java 路徑另以子程序 PID 核對。 +每台以當次 run 發送 help、doctor、console code 拒絕及有效 reload,均觀察到對應輸出。 +中文 log 以 UTF-8 嚴格解碼,沒有 U+FFFD;實際原生主控台字色、粗細仍需人眼驗收。 +畫面、hover、剪貼簿、點擊與真人切服沒有由 Agent 代為驗收。 + +## 備份與資料邊界 + +三台在 stopped、無 listener、無待執行核心更新、持有 `.testlab-manager.lock` 時備份。 +Spigot/Paper/Folia 分別核對 19/18/19 個檔案,包括舊 JAR、完整 InviteCode 資料目錄 +(DB、key、YAML、語系)、LuckPerms JSON/設定、metadata 與 ops。備份 DB 的 quick_check=ok、schema 9。 +備份原始選定檔案合計 60,207,155 bytes;另保留停用原 JAR 與操作證據,不把它當成可立即刪除暫存。 +備份含私有資料,不提交 Git。 + +沒有複製整個世界:世界原位保留,部署前後 level.dat hash 相同;正常啟停的世界儲存不宣稱逐位元組不變。 +部署時 DB、key、storage、rewards、權限與 ops 保持原 hash,之後才執行已授權帳號操作。 +三台資料庫沒有重建或 migration,密鑰逐位元組與停服備份相同。 +舊 Paper 26.3 `InviteCode-1.0.0.jar` 移入備份,沒有與新 JAR 同時放在 plugins 載入。 + +## 帳號操作與稽核 + +先核對各服沒有玩家在線,A/B UUID 與舊 Invitation 方向唯一且一致,再執行管理指令。 +三台 B 的 generation 0 → 1;A 紀錄、有效邀請碼、舊 Reward 與舊 Invitation 列均保留。 +Spigot/Paper 的舊 QUALIFIED 不改;Folia 唯一舊 CLAIMED 經 inspect 核對後單獨 unlink, +再次 inspect 確認 UNLINKED 才 reset B。沒有直接寫入 SQLite。 + +只讀 DB 核對:三台新 audit 分別 +1/+1/+2;只有 Folia 指定列的 status 改成 UNLINKED, +沒有新建 Invitation 或 Reward、沒有待處理/結果不明獎勵。B 新登記視窗最早於臺灣時間 +2026-10-19 14:38 到期。後續真人建立的新列及其 generation/獎勵恰一次仍待驗收後核對。 + +## 啟動時發現與處理 + +1. **Spigot 的有效 Java 選版與 metadata 不同。**原本實例設定為 inherit,繼承全域 mise local-25。 + 已正常 stop、核對 exit 0/outputDrained、備份本台管理設定,再以 SettingsSet 的 revision 檢查 + 將本台改為 mise local-8。全域 revision 不變,重新啟動後核對實際 java.exe 與版本。 +2. **工具輸出編碼。**最初 Python 輸出沿用 Windows 編碼,工具讀取時看似亂碼; + 核對原始 log 是正確 UTF-8,後續工具使用 `python -X utf8`。沒有修改插件文案來補償轉讀問題。 +3. **Spigot 既有 LuckPerms JSON 寫入失敗。**測試權限設定觸發 `NoSuchMethodError: + com.google.gson.stream.JsonWriter.value(java.lang.Boolean)`,後續讀取指出 JSON 未完整寫入。 + 這不是 InviteCode exception,也沒有修復第三方插件。當次新建的 B 權限檔原本不存在; + 正常停服後將失敗檔移入本台備份作證據,保留舊使用者權限不變,再重啟。 + 此輪 Spigot 改用基本玩家權限 `invitecode.command.basic` 當資格條件,B 最後同意後立即達資格, + A 須在最後同意前回 Lobby;不再要求 Spigot 寫 LuckPerms JSON。當次重啟 log 無 exception。 + 舊 LuckPerms 的 JSON 寫入限制仍存在,不把繞開該測試依賴描述為修復完成。 +4. Paper/Folia 的 B 測試資格已設 false 並核對落盤與 permission check=false。 + Paper 26.3 的 B 原有直接 wildcard true,為一般玩家 help 暫時移除,原檔已備份;驗收後需還原。 + 一次等待英文成功字串因 LuckPerms 實際使用繁中而逾時;先核對落盤狀態後才繼續,沒有重送已完成的 unset。 + +上述測服設定調整與已授權準備直接相關;沒有新增依賴、改核心、修 InstanceHarbor 或更改共用設定。 +JLine 關服問題仍保持先前暫緩,不做其隔離測試。 + +## 已核對與待完成 + +獨立 reviewer 已檢查備份/部署腳本的範圍、鎖、hash、DB/key/world 保留與唯一 JAR; +指出中斷時需查 journal 人工恢復,沒有自動 rollback,本輪沒有部署中斷。 +完成後第二次獨立唯讀覆核實際 Status、port/PID、備份及 SQL:A/邀請碼/Reward 逐列保留, +B generation、單筆 Folia UNLINKED、audit 增量與臨時權限均相符,未發現 Critical/High。 +此覆核沒有發送伺服器命令,也不取代真人驗收。 +操作原始 log、run 與私有資料清單留在 Worktree `.run/command-feedback-stage4/`,必要備份留在固定實例內。 + +下一步依[現在可執行的兩帳號清單](../command-feedback-human-acceptance.md)完成三台集中真人驗收, +再核對新資料與還原臨時設定/權限、停止不再使用的後端。 +Paper 26.2 Human 未變且未啟動,其隔離 adapter 自動複驗尚待執行;最新 Folia ALPHA 缺口仍保留。 +Agent 部署/啟動檢查通過不等於真人驗收、合併或發布。本輪沒有 push、PR、merge、tag 或 release。 diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.json b/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.json new file mode 100644 index 0000000..2137d17 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.json @@ -0,0 +1,251 @@ +{ + "checkedAt": "2026-10-17T20:42:57.820468+00:00", + "checkpoint": "85fb9389e53f9f72c6240eb1956e4e5ee3617674", + "runtimeCommit": "dfbc39c4a80cea91b22b88c5f89d16107e7d50a2", + "candidateSha256": "E350DCA507D1FB953A2B785474708226BFBD682CBFE5D44E7E9BF0D0630C6C8B", + "candidateBytes": 19890059, + "state": "prepared-only-not-deployed", + "instances": [ + { + "name": "invitecode-folia-26.1.2", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "core": "FOLIA", + "minecraftVersion": "26.1.2", + "build": "8", + "buildEvidence": "workspace hash matches actual JAR", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "metadataCoreHashMatches": true, + "javaAlias": "local-25", + "javaExecutableExists": true, + "port": 30101, + "managerState": "Stopped", + "managerDiscovered": true, + "forwardingConfigMatches": true, + "route": "127.0.0.1:30101", + "routeLiveAcceptance": "pending for new candidate", + "installedPlugin": "InviteCode-0.1.0-SNAPSHOT.jar", + "installedPluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "sqliteSchema": 9, + "sqliteQuickCheck": "ok", + "accounts": [ + { + "role": "A", + "generation": 0, + "activeCodeCount": 1 + }, + { + "role": "B", + "generation": 0, + "activeCodeCount": 0 + } + ], + "invitationStatusCounts": { + "CLAIMED": 1 + }, + "rewardActionStatusCounts": {}, + "matchingIpAction": "DENY", + "localeDiff": { + "zh_TW": { + "installedSha256": "64EB834762D21DE25902D822303AE0D6AD30E6294E74C82D22D9357FFD01E725", + "candidateSha256": "A44EB1BF8B87B1F80712B64EF421D0D2C3665B89D994D80AA77EF3C146EC5471", + "different": true + }, + "en_US": { + "installedSha256": "6B13BB41A5037A5F84967B7039924E12E8C3BC474551A6F85F92C583812748FB", + "candidateSha256": "1F6B27FAD2E68A3996841346311ED223D067E67217C1FB16D1FD5F1972B70B4E", + "different": true + } + }, + "allPluginJars": [ + "InviteCode-0.1.0-SNAPSHOT.jar", + "LuckPerms-Bukkit-5.5.85.jar" + ] + }, + { + "name": "invitecode-paper-26.2", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.2", + "core": "PAPER", + "minecraftVersion": "26.2", + "build": "134", + "buildEvidence": "installed update record newHash matches actual JAR; not boot-verified this turn", + "coreSha256": "3CCE0A4922BAF79BD8E1275EE5FF9F073F24675770E09B0D4BE9442D513E7A6B", + "metadataCoreHashMatches": false, + "javaAlias": "local-25", + "javaExecutableExists": true, + "port": 20101, + "managerState": "Stopped", + "managerDiscovered": true, + "forwardingConfigMatches": true, + "route": "127.0.0.1:20101", + "routeLiveAcceptance": "pending for new candidate", + "installedPlugin": "InviteCode-0.1.0-SNAPSHOT.jar", + "installedPluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "sqliteSchema": 9, + "sqliteQuickCheck": "ok", + "accounts": [ + { + "role": "A", + "generation": 0, + "activeCodeCount": 1 + }, + { + "role": "B", + "generation": 0, + "activeCodeCount": 0 + } + ], + "invitationStatusCounts": { + "CLAIMED": 1 + }, + "rewardActionStatusCounts": {}, + "matchingIpAction": "DENY", + "localeDiff": { + "zh_TW": { + "installedSha256": "64EB834762D21DE25902D822303AE0D6AD30E6294E74C82D22D9357FFD01E725", + "candidateSha256": "A44EB1BF8B87B1F80712B64EF421D0D2C3665B89D994D80AA77EF3C146EC5471", + "different": true + }, + "en_US": { + "installedSha256": "6B13BB41A5037A5F84967B7039924E12E8C3BC474551A6F85F92C583812748FB", + "candidateSha256": "1F6B27FAD2E68A3996841346311ED223D067E67217C1FB16D1FD5F1972B70B4E", + "different": true + } + }, + "allPluginJars": [ + "InviteCode-0.1.0-SNAPSHOT.jar", + "LuckPerms-Bukkit-5.5.85.jar" + ] + }, + { + "name": "invitecode-paper-26.3", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3", + "core": "PAPER", + "minecraftVersion": "26.3", + "build": "202", + "buildEvidence": "installed update record newHash matches actual JAR; not boot-verified this turn", + "coreSha256": "1B243442FC3B3CBE945628F8AF7911E4BE439CA8B22106FB1568AC81D5A5792B", + "metadataCoreHashMatches": false, + "javaAlias": "local-25", + "javaExecutableExists": true, + "port": 20102, + "managerState": "Stopped", + "managerDiscovered": true, + "forwardingConfigMatches": true, + "route": "127.0.0.1:20102", + "routeLiveAcceptance": "pending for new candidate", + "installedPlugin": "InviteCode-1.0.0.jar", + "installedPluginSha256": "F2055052DC9E8C0913AFE85C6B19E46850FC2F2FC2C7B5467DE60CA567203BCE", + "sqliteSchema": 9, + "sqliteQuickCheck": "ok", + "accounts": [ + { + "role": "A", + "generation": 0, + "activeCodeCount": 1 + }, + { + "role": "B", + "generation": 0, + "activeCodeCount": 0 + } + ], + "invitationStatusCounts": { + "QUALIFIED": 1 + }, + "rewardActionStatusCounts": { + "DELIVERED": 2 + }, + "matchingIpAction": "ALLOW", + "localeDiff": { + "zh_TW": { + "installedSha256": "64EB834762D21DE25902D822303AE0D6AD30E6294E74C82D22D9357FFD01E725", + "candidateSha256": "A44EB1BF8B87B1F80712B64EF421D0D2C3665B89D994D80AA77EF3C146EC5471", + "different": true + }, + "en_US": { + "installedSha256": "6B13BB41A5037A5F84967B7039924E12E8C3BC474551A6F85F92C583812748FB", + "candidateSha256": "1F6B27FAD2E68A3996841346311ED223D067E67217C1FB16D1FD5F1972B70B4E", + "different": true + } + }, + "allPluginJars": [ + "InviteCode-1.0.0.jar", + "LuckPerms-Bukkit-5.5.85.jar" + ] + }, + { + "name": "invitecode-spigot-1.8.8", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8", + "core": "SPIGOT", + "minecraftVersion": "1.8.8", + "build": "local-buildtools", + "buildEvidence": "workspace hash matches actual JAR", + "coreSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "metadataCoreHashMatches": true, + "javaAlias": "local-8", + "javaExecutableExists": true, + "port": 10101, + "managerState": "Stopped", + "managerDiscovered": true, + "forwardingConfigMatches": true, + "route": "127.0.0.1:10101", + "routeLiveAcceptance": "pending for new candidate", + "installedPlugin": "InviteCode-0.1.0-SNAPSHOT.jar", + "installedPluginSha256": "D6AF246F62256E2BEF1FB441DC282B4ADE6001269776D8966C7652F5E264ED6C", + "sqliteSchema": 9, + "sqliteQuickCheck": "ok", + "accounts": [ + { + "role": "A", + "generation": 0, + "activeCodeCount": 1 + }, + { + "role": "B", + "generation": 0, + "activeCodeCount": 0 + } + ], + "invitationStatusCounts": { + "QUALIFIED": 1 + }, + "rewardActionStatusCounts": { + "DELIVERED": 2 + }, + "matchingIpAction": "DENY", + "localeDiff": { + "zh_TW": { + "installedSha256": "64EB834762D21DE25902D822303AE0D6AD30E6294E74C82D22D9357FFD01E725", + "candidateSha256": "A44EB1BF8B87B1F80712B64EF421D0D2C3665B89D994D80AA77EF3C146EC5471", + "different": true + }, + "en_US": { + "installedSha256": "6B13BB41A5037A5F84967B7039924E12E8C3BC474551A6F85F92C583812748FB", + "candidateSha256": "1F6B27FAD2E68A3996841346311ED223D067E67217C1FB16D1FD5F1972B70B4E", + "different": true + } + }, + "allPluginJars": [ + "InviteCode-0.1.0-SNAPSHOT.jar", + "LuckPerms-Bukkit-5.4.145.jar" + ] + } + ], + "entryServices": [ + { + "name": "Velocity", + "state": "Listening" + }, + { + "name": "lobby", + "state": "Listening" + } + ], + "limitations": [ + "not started or deployed", + "no account reset performed", + "human acceptance pending", + "Paper26.2 affected adapter retest pending", + "latest Folia ALPHA remains unverified" + ] +} diff --git a/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.md b/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.md new file mode 100644 index 0000000..24f6546 --- /dev/null +++ b/docs/testing/evidence/2026-10-18-command-feedback-stage4-preflight.md @@ -0,0 +1,68 @@ +# 第四階段固定測服唯讀核對 + +日期:2026-10-18(Asia/Taipei)。程式仍為第二階段 `dfbc39c` 的 E350 JAR; +準備工作基於文件 checkpoint `85fb938`,沿用原功能 Worktree,沒有重新建置。 + +## 結果與界線 + +四台 Human 皆被現行 C# 管理器 List 發現;逐台 Status 為 Stopped、沒有 host/run, +10101/20101/20102/30101 沒有 listener。Velocity 與 Lobby 的既有 managed run 正常監聽, +未因本次工作停止或重啟。沒有部署、啟動、重設帳號、改設定或 remote write。 + +實際核心 SHA 與建立 metadata:Spigot/Folia 相符;Paper 26.2 的實際 JAR 是 build 134, +Paper 26.3 是 build 202。兩者以 `.testlab-core-backups/*/update.json` 中的 newHash +逐一對上實際 `server.jar`,不是僅按檔名猜版本。兩台舊 `versions/` 的 materialized JAR +仍分別為 build 133/184,不應當成更新後當次啟動證據;本輪沒有啟動。 + +四台都有唯一 loopback 路由、offline backend、Spigot Bungee forwarding;Paper/Folia +另核對 bungee-cord online-mode=true、Velocity modern forwarding=false。 +代理 online-mode=true、legacy forwarding,玩家入口 25565。設定相符不代表本候選已真人切服。 +實際核心、JAR、port、語系差異與資料狀態詳見[JSON](2026-10-18-command-feedback-stage4-preflight.json)。 + +## 現行管理器核對 + +最初使用第三階段的舊 CLI,管理器拒絕 executable identity;改用現行 Manager 同包 CLI 後, +仍因 config/host context 不符被拒絕。沒有停止衝突 Manager,也沒有修改設定繞過檢查。 +唯讀檢視當前 Manager 命令列後,沿用其 config-root 與 host,List/Status 成功。 + +- CLI:`InstanceHarbor/worktrees/feat-core-update-workflow/artifacts/portable-core-group-query-20261014/gui/InstanceHarbor.exe` +- Data root:`D:\Code\Java\Plugin\InstanceHarbor` +- Config root:`InstanceHarbor/worktrees/refactor-csharp-management-baseline/artifacts/csharp-feedback-acceptance/config` +- Host:`InstanceHarbor/worktrees/feat-java-runtime-selector/artifacts/portable-20261007-133506-db6c6a36/gui/host/Host.exe` + +這些是本輪查詢身分,不是要求使用者固定採用過時包;後續控制前仍須重新核對當前 Manager。 +Java alias 的實體執行檔存在,但沒有本輪 JVM 啟動版本證據。 + +## 本機準備區 + +Worktree `.run/command-feedback-stage4/` 只包含讀取/準備腳本、manifest、候選 JAR、 +從候選 JAR 取出的雙語 messages 與逐台暫時設定提案。JAR hash 與第三階段完全一致; +既有 messages 均與新文案不同,因此部署時需要明確備份與逐檔更新。 +準備區不是 Human 的備份,沒有複製 DB、key 或世界。 + +四台 SQLite 以 URI `mode=ro`、query_only 檢查:schema 9、quick_check=ok。 +只保存 aggregate/A-B 角色狀態,JSON 不包含原始 UUID、Invite Code、IP、網路 hash 或 key。 +三台主測服的 B 都已登記;Folia 有舊 CLAIMED,Spigot/Paper 26.3 有舊 QUALIFIED。 +完整重測需要先確認 B 資格重設;Folia 還需確認對精確舊 CLAIMED 的 unlink,避免歷史列同時達資格。 +這些是待確認資料操作,本輪沒有執行。 + +## 獨立審查與修正 + +獨立唯讀 reviewer 檢查 core/SQL/workflow,指出 reset 只增加 eligibility_generation, +不移除歷史 Invitation;資格掃描仍重評所有 CLAIMED。清單已改為先保存權限並設 false、 +B 暫留 Lobby、精確處理 Folia 舊 CLAIMED 後再 reset,核對 generation 與新 Invitation。 +不能只用玩家 status/stats 代替資料證據,Paper 26.2 明確排除於本輪 Human 資料操作。 + +本輪只改測試文件與本機閱讀入口,不修改這些既有領域行為。未使用 Java/Gradle, +無需重跑已完成的程式測試;本輪檢查 JSON、連結、HTML IDs/JS 語法、候選 hash、部署來源與 diff。 +靜態核對 29 個唯一 HTML ID、23 個本機/章節連結、12 步驟;另有 2 個既有外部來源連結,未重查網路。 +Node 檢查內嵌 JS 語法, +以最小 DOM stub 驗證初始/下一項/最後一項/全部/路由切換,不把它當成瀏覽器渲染。 +再次雜湊確認四台已裝 InviteCode JAR 與八份語系檔仍與 preflight 相同。 +瀏覽器實際渲染、Minecraft 畫面、剪貼簿、滑鼠與新核心當次啟動仍未驗證。 + +## 下一步 + +依[第四階段完整清單](../command-feedback-human-acceptance.md),先確認三台的備份部署與 +精確帳號操作,再逐台啟動核對並集中真人驗收。Paper 26.2 adapter Agent 複驗尚待執行; +最新 Folia ALPHA 缺口保留。沒有 push、PR、merge 或 release。 diff --git a/docs/testing/evidence/2026-10-18-folia-help-partial-human-acceptance.json b/docs/testing/evidence/2026-10-18-folia-help-partial-human-acceptance.json new file mode 100644 index 0000000..c4ddeda --- /dev/null +++ b/docs/testing/evidence/2026-10-18-folia-help-partial-human-acceptance.json @@ -0,0 +1,25 @@ +{ + "recordedUtc": "2026-10-18T08:36:40.132938+00:00", + "source": "User explicitly reported acceptance in this conversation", + "candidateCommit": "760c51a8b3ae50e172cda8218f62aa5c8b4b9de7", + "artifactSha256": "D2669D283F5ACD0FB7AB1A9B45C398371E88EE9B0B1795A29DCCB429E1A3A012", + "server": "Folia 26.1.2", + "clientVersion": "not reported", + "status": "partial-human-accepted", + "accepted": [ + "Frame alignment visually acceptable in tested client", + "reload help returns to management page 2", + "doctor help returns to management page 2", + "storage help returns to management page 2" + ], + "notInferred": [ + "Homepage help direct click", + "Disabled button clicks", + "Player/console permission-aware Tab", + "Full bilingual message and Dialog acceptance", + "Other Minecraft cores", + "Merge or push approval" + ], + "userReport": "Folia 的框線目前看起來可以,reload、doctor 和 storage 返回第 2 頁也都正常。", + "next": "Folia remaining message and interaction checks; keep other cores deferred; no automatic runtime changes" +} diff --git a/docs/testing/evidence/2026-10-29-doctor-human-acceptance.json b/docs/testing/evidence/2026-10-29-doctor-human-acceptance.json new file mode 100644 index 0000000..86d573e --- /dev/null +++ b/docs/testing/evidence/2026-10-29-doctor-human-acceptance.json @@ -0,0 +1,15 @@ +{ + "date": "2026-10-29", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "scope": "Folia 26.1.2 doctor display", + "humanReport": "目前看起来我们这次的更改,我看起来应该是没有什么太大的问题的,可以算是通过。", + "result": "passed for reported display scope", + "notIndividuallyConfirmed": [ + "English client locale", + "positive reward counts", + "other cores", + "entire fourth-stage flow" + ], + "serverState": "User reports servers stopped; not restarted by Agent", + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-29-doctor-localization.json b/docs/testing/evidence/2026-10-29-doctor-localization.json new file mode 100644 index 0000000..9be751c --- /dev/null +++ b/docs/testing/evidence/2026-10-29-doctor-localization.json @@ -0,0 +1,59 @@ +{ + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "sha256": "5D7E7782E8BAEA222785DA8FA8B15416E777649517C5F63AD53101D48BE6733D", + "bytes": 19929689, + "tests": { + "tests": 330, + "failures": 0, + "errors": 0, + "skipped": 24 + }, + "passed": 306, + "checks": [ + "Java 11 check shadowJar", + "Java 8 check shadowJar", + "verifyJava8Bytecode", + "verifyPluginJar", + "4 doctor regression tests", + "independent review" + ], + "date": "2026-10-29", + "scope": "Folia 26.1.2 doctor localization and semantic colors", + "agentRuntime": { + "ready": true, + "runId": "1793b599a747476ca11693f29457144b", + "doctorLines": 13, + "translatedValues": true, + "nativeLogHeaders": true, + "errors": false + }, + "preservation": { + "protectedConfigurationAndKeyUnchanged": true, + "databaseRowsRetained": true, + "runtimeTimestampRefresh": [], + "otherServers": [ + { + "name": "invitecode-paper-26.3", + "state": "Stopped" + }, + { + "name": "invitecode-spigot-1.8.8", + "state": "Stopped" + } + ], + "worldsPreservedDuringDeployment": true + }, + "backupPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\doctor-colors-20261029-153124-9da4ca5b", + "instance": "D:/Code/Java/Plugin/InstanceHarbor/instances/Human/InviteCode/invitecode-folia-26.1.2", + "port": 30101, + "java": "local-25 / JDK 25.0.4.1", + "humanAcceptance": "pending", + "remoteWrites": false, + "limits": [ + "MySQL conditional tests skipped (24)", + "Player colors and English client locale still need human acceptance", + "Positive reward counts checked with automated fixtures only", + "Latest Folia ALPHA gap retained", + "Git and build-time provenance deferred to separate draft" + ] +} diff --git a/docs/testing/evidence/2026-10-29-doctor-localization.md b/docs/testing/evidence/2026-10-29-doctor-localization.md new file mode 100644 index 0000000..e8997ed --- /dev/null +++ b/docs/testing/evidence/2026-10-29-doctor-localization.md @@ -0,0 +1,27 @@ +# Folia 健康檢查翻譯與配色候選 + +來源 `1a83b7328353f132dfb5da29b6cde15e3ade50d0`,JAR SHA-256 `5D7E7782E8BAEA222785DA8FA8B15416E777649517C5F63AD53101D48BE6733D`。 + +330 項:306 通過、24 MySQL 條件測試跳過,0 失敗/錯誤。Java 8/11 check shadowJar、bytecode、JAR 檢查通過。四項新增 doctor 回歸涵蓋繁英語系、值樣式、未知值 literal 與 Console 逐行 prefix。獨立 review 無阻擋問題。 + +Folia build 8、port 30101、JDK 25.0.4.1。已先核對停止、備份 21 個檔案,才替換唯一 JAR 與兩份語系。部署期間世界標頭、DB、key、設定與權限不變;啟動後資料庫逐表核對無列變化。其他兩台維持停止。 + +以下來自本次 ready run 的 latest.log;它驗證翻譯與逐行 log,不等於玩家色彩真人驗收。Console 顏色由 presenter 回歸驗證,實際終端外觀待人工。 + +```text +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 健康檢查 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 執行階段:運作中 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 設定世代:0 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 背景工作:接受新工作 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] PlaceholderAPI:未啟用 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] Vault 經濟服務:不可用 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 原生對話框:Paper +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] RGB 色彩:支援 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 儲存類型:SQLite +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 結構版本:9 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 待執行獎勵:0 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 執行中獎勵:0 +[23:32:41] [Folia Region Scheduler Thread #0/INFO]: [InviteCode] 結果待確認:0 +``` + +本次沒有重設玩家、修改邀請關係、schema、push、PR、merge 或發布。 diff --git a/docs/testing/evidence/2026-10-29-folia-console-player-acceptance.json b/docs/testing/evidence/2026-10-29-folia-console-player-acceptance.json new file mode 100644 index 0000000..22301bc --- /dev/null +++ b/docs/testing/evidence/2026-10-29-folia-console-player-acceptance.json @@ -0,0 +1,24 @@ +{ + "acceptedOn": "2026-10-29 Asia/Taipei", + "candidateCommit": "53893c475fdeaf631ca5b174493f33754660e0ad", + "source": "User reported Console: passed; player report: passed, with screenshot and requested localization/color follow-up", + "server": "Folia 26.1.2", + "status": "partial-human-accepted-with-follow-up", + "accepted": [ + "Console layout", + "Player report layout" + ], + "followUp": [ + "Translate doctor labels and status values using configured locale selection, except proper names", + "True green and false red requested", + "Other status/count colors require discussion before implementation" + ], + "notInferred": [ + "English-locale test passed", + "Full claim/reward/restart acceptance", + "Other cores passed", + "Implementation or merge authorization for proposed non-boolean colors" + ], + "screenshot": "2026-10-29-folia-doctor-localization-feedback.png", + "clientVersion": "not reported" +} diff --git a/docs/testing/evidence/2026-10-29-folia-doctor-localization-feedback.png b/docs/testing/evidence/2026-10-29-folia-doctor-localization-feedback.png new file mode 100644 index 0000000..8a7e0ba Binary files /dev/null and b/docs/testing/evidence/2026-10-29-folia-doctor-localization-feedback.png differ diff --git a/docs/testing/evidence/2026-10-30-claim-ux-expired.png b/docs/testing/evidence/2026-10-30-claim-ux-expired.png new file mode 100644 index 0000000..28f05e3 Binary files /dev/null and b/docs/testing/evidence/2026-10-30-claim-ux-expired.png differ diff --git a/docs/testing/evidence/2026-10-30-claim-ux-fixes.json b/docs/testing/evidence/2026-10-30-claim-ux-fixes.json new file mode 100644 index 0000000..fb327a5 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-claim-ux-fixes.json @@ -0,0 +1,209 @@ +{ + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "sha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "bytes": 19934670, + "tests": { + "tests": 338, + "failures": 0, + "errors": 0, + "skipped": 24 + }, + "passed": 314, + "checks": [ + "Java 11 check shadowJar", + "Java 8 check shadowJar", + "verifyPluginJar", + "verifyJava8Bytecode" + ], + "deployed": false, + "independentReview": "No concrete High/Critical; human client not exercised", + "currentHumanServerSource": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "date": "2026-10-30", + "scope": "Status primary reason, single red error guidance, native input expiration and generic code label", + "redEvidence": [ + ".run/claim-ux-fixes-20261030/TEST-io.github.command1264.invitecode.plugin.PlayerMessageLayoutsTest.xml", + ".run/claim-ux-fixes-20261030/TEST-io.github.command1264.invitecode.plugin.PlayerWorkflowPresentationIntegrationTest.xml", + ".run/claim-ux-fixes-20261030/catalog-red.xml" + ], + "redResult": "5 targeted failures including boundary/early-task/late-submit; catalog 1 failure before changes", + "greenResult": "338 cases: 314 passed, 24 MySQL conditional skipped, 0 failures/errors", + "newRegressionCoverage": [ + "Primary status reason in layout and real SQLite workflow", + "Generic native input label and bilingual style contracts", + "Exactly-at-deadline expiration and once-only handling", + "Early timer rescheduling", + "Late submit expiration response", + "Late cancel explicit cancellation", + "Atomic expired/missing/code results" + ], + "catalogChanges": { + "zh_TW": { + "runtime.usage": { + "before": "&c指令用法不正確。&f請使用 /{label} help 查看說明。", + "after": "&c指令用法不正確,請使用 /{label} help 查看說明。" + }, + "runtime.help-page-error": { + "before": "&c找不到此頁面或主題。&f請使用 /ic help 返回常用指令。", + "after": "&c找不到此頁面或主題,請使用 /ic help 返回常用指令。" + }, + "command.claim.chat-timeout": { + "before": "&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。", + "after": "&c邀請碼輸入已逾時,請重新執行 /invitecode claim。" + }, + "command.claim.dialog-label": { + "before": "六位邀請碼", + "after": "邀請碼" + }, + "command.claim.dialog-timeout": { + "before": "&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。", + "after": "&c邀請碼輸入已逾時,請重新執行 /invitecode claim。" + }, + "command.claim.invalid-code": { + "before": "&c邀請碼格式不正確。&f請檢查後重新輸入。", + "after": "&c邀請碼格式不正確,請檢查後重新輸入。" + }, + "command.claim.unavailable": { + "before": "&c這組邀請碼不存在或已失效。&f請向邀請人確認目前的邀請碼。", + "after": "&c這組邀請碼不存在或已失效,請向邀請人確認目前的邀請碼。" + }, + "command.claim.confirmation-timeout": { + "before": "&e邀請確認已逾時。&f請重新執行 /invitecode claim。", + "after": "&c邀請確認已逾時,請重新執行 /invitecode claim。" + }, + "command.claim.no-confirmation": { + "before": "&e目前沒有可確認的邀請,或確認已逾時。&f請重新執行 /invitecode claim。", + "after": "&c目前沒有可確認的邀請,或確認已逾時,請重新執行 /invitecode claim。" + }, + "command.claim.matching-network-denied": { + "before": "&c你與邀請人近期使用相同網路,依伺服器規則無法登記。&f如需協助,請聯絡管理員。", + "after": "&c你與邀請人近期使用相同網路,依伺服器規則無法登記,如需協助請聯絡管理員。" + }, + "command.error": { + "before": "&c操作失敗。&f請聯絡管理員檢查伺服器紀錄。", + "after": "&c操作失敗,請聯絡管理員檢查伺服器紀錄。" + }, + "command.stopping": { + "before": "&e插件正在停止,暫時無法操作。&f請稍後再試。", + "after": "&c插件正在停止,暫時無法操作,請稍後再試。" + }, + "admin.error": { + "before": "&c管理操作失敗。&f請檢查伺服器紀錄。", + "after": "&c管理操作失敗,請檢查伺服器紀錄。" + }, + "admin.reload-failed": { + "before": "&c重新載入失敗,仍使用上一份有效設定。&f請檢查伺服器紀錄並修正設定。", + "after": "&c重新載入失敗,仍使用上一份有效設定,請檢查伺服器紀錄並修正設定。" + }, + "admin.storage-config-unavailable": { + "before": "&c設定尚未成功載入,無法判定儲存位置。&f請檢查伺服器紀錄。", + "after": "&c設定尚未成功載入,無法判定儲存位置,請檢查伺服器紀錄。" + }, + "admin.storage-failed": { + "before": "&c儲存結構更新失敗。&f請檢查伺服器紀錄。", + "after": "&c儲存結構更新失敗,請檢查伺服器紀錄。" + }, + "admin.doctor-storage-failed": { + "before": "&c儲存健康檢查失敗。&f請檢查伺服器紀錄。", + "after": "&c儲存健康檢查失敗,請檢查伺服器紀錄。" + } + }, + "en_US": { + "runtime.usage": { + "before": "&cInvalid command usage. &fUse /{label} help for instructions.", + "after": "&cInvalid command usage, so use /{label} help for instructions." + }, + "runtime.help-page-error": { + "before": "&cThat page or topic was not found. &fUse /ic help to return to common commands.", + "after": "&cThat page or topic was not found, so use /ic help to return to common commands." + }, + "command.claim.chat-timeout": { + "before": "&eCode input has expired. &fRun /invitecode claim again.", + "after": "&cCode input expired, so run /invitecode claim again." + }, + "command.claim.dialog-label": { + "before": "Six-character Invite Code", + "after": "Invite code" + }, + "command.claim.dialog-timeout": { + "before": "&eCode input has expired. &fRun /invitecode claim again.", + "after": "&cCode input expired, so run /invitecode claim again." + }, + "command.claim.invalid-code": { + "before": "&cInvalid Invite Code format. &fCheck the code and enter it again.", + "after": "&cThe Invite Code format is invalid, so check it and enter the code again." + }, + "command.claim.unavailable": { + "before": "&cThis Invite Code does not exist or is no longer active. &fAsk the inviter for their current code.", + "after": "&cThis Invite Code does not exist or is no longer active, so ask the inviter for their current code." + }, + "command.claim.confirmation-timeout": { + "before": "&eInvitation confirmation has expired. &fRun /invitecode claim again.", + "after": "&cInvitation confirmation expired, so run /invitecode claim again." + }, + "command.claim.no-confirmation": { + "before": "&eThere is no invitation to confirm, or it has expired. &fRun /invitecode claim again.", + "after": "&cThere is no invitation to confirm, or it has expired, so run /invitecode claim again." + }, + "command.claim.matching-network-denied": { + "before": "&cServer rules prevent this claim because you and the inviter recently used the same network. &fContact an administrator if you need help.", + "after": "&cServer rules prevent this claim because you and the inviter recently used the same network, so contact an administrator if you need help." + }, + "command.error": { + "before": "&cThe operation failed. &fContact an administrator to check the server log.", + "after": "&cThe operation failed, so contact an administrator to check the server log." + }, + "command.stopping": { + "before": "&eThe plugin is stopping and cannot accept operations. &fTry again later.", + "after": "&cThe plugin is stopping and cannot accept operations, so try again later." + }, + "admin.error": { + "before": "&cThe administrative operation failed. &fCheck the server log.", + "after": "&cThe administrative operation failed, so check the server log." + }, + "admin.reload-failed": { + "before": "&cReload failed. The previous configuration remains active. &fCheck the server log and fix the configuration.", + "after": "&cReload failed while the previous configuration remains active, so check the server log and fix the configuration." + }, + "admin.storage-config-unavailable": { + "before": "&cConfiguration is not loaded, so the storage location is unknown. &fCheck the server log.", + "after": "&cBecause configuration is not loaded, the storage location is unknown, so check the server log." + }, + "admin.storage-failed": { + "before": "&cStorage schema update failed. &fCheck the server log.", + "after": "&cStorage schema update failed, so check the server log." + }, + "admin.doctor-storage-failed": { + "before": "&cThe storage health check failed. &fCheck the server log.", + "after": "&cThe storage health check failed, so check the server log." + } + } + }, + "otherReasonPresentationForDiscussion": { + "location": "/ic claim when ineligible", + "currentChineseExample": "目前無法使用邀請碼:你已建立自己的邀請碼、可登記期間已結束。", + "decision": "unchanged; discuss whether to use primary reason here too" + }, + "deploymentDecision": "User selected finish existing qualification/offline rewards first; stop and back up before later Folia deployment", + "humanRuntime": { + "state": "Listening", + "BGeneration": 2, + "currentInvitations": [ + { + "status": "CLAIMED", + "count": 1 + } + ], + "rewards": [], + "agentMutations": false + }, + "humanClaimEvidence": "2026-10-30-folia-claim-human-acceptance.json", + "runtimeMutationsThisTurn": false, + "humanNewCandidateAcceptance": "pending", + "remaining": [ + "qualification and offline reward human acceptance on old installed candidate", + "backup and deploy new candidate after server stopped", + "new native input timeout screen acceptance requires later suitable account; do not reset current B", + "restart, setting restoration and other-core human acceptance" + ], + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-30-claim-ux-fixes.md b/docs/testing/evidence/2026-10-30-claim-ux-fixes.md new file mode 100644 index 0000000..ddefe7e --- /dev/null +++ b/docs/testing/evidence/2026-10-30-claim-ux-fixes.md @@ -0,0 +1,133 @@ +# 2026-10-30 InviteCode claim UI 修正證據 + +來源 `5702e91a261cf6587056eac8752c21f49a26ff33`,JAR SHA-256 `B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72`。本機候選,尚未部署。原功能分支與 Worktree 保留,沒有 push/PR/merge。 + +Java 11/8 的 `check shadowJar`、Java 8 bytecode、JAR 檢查通過。338 項:314 通過、24 MySQL 條件跳過,0 失敗/錯誤。 +先重現 5 項 targeted 失敗與 catalog 1 項失敗,再修正;RED XML 留在本輪 `.run/claim-ux-fixes-20261030`。 +測試以可控時鐘與真實 SQLite workflow 驗證期限、關閉呼叫與訊息,不代表真人渲染結果。 + +根因:到期比較原先不包含相等,單次 tick 排程提早執行後不再檢查,逾時 consume 回傳 null 與沒有會話混淆。 +修正:同一截止邊界、剩餘時間重排、原子讀取提交結果,過期就回覆且不進入登記;舊 String? wrapper 保留。 +status 只顯示既有理由次序的第一項,不改 eligibility 判定。Dialog 標籤改邀請碼,不改實際碼長或格式。 + +使用者已回報 assigned tests/登記完成;唯讀核對 A→B 只有一筆 generation 2 的 CLAIMED,舊 UNLINKED 保留,獎勵 0。 +輸入框逾時與文案的缺陷另外保留為新候選待複驗,不因登記完成將四個 UI 缺陷算通過。 +使用者選定先完成既有關係的資格/離線補發,再停服更新。本輪沒有測服、設定、權限或 DB 變更。 + +## 尚待討論的相似呈現 + +`/ic claim` 不合資格的現有文案可能是: + +> 目前無法使用邀請碼:你已建立自己的邀請碼、可登記期間已結束。 + +這裡仍合併所有理由,用頓號分隔;本輪未改。建議後續討論是否和 status 一樣只提示最主要原因。 +儲存切換警告與正式離線報告保留:它們是操作流程/狀態資訊,不是同類錯誤+重試指引。 + +## 雙語文案變更(17 鍵) + +### zh_TW + +- `runtime.usage` + - 原:`&c指令用法不正確。&f請使用 /{label} help 查看說明。` + - 新:`&c指令用法不正確,請使用 /{label} help 查看說明。` +- `runtime.help-page-error` + - 原:`&c找不到此頁面或主題。&f請使用 /ic help 返回常用指令。` + - 新:`&c找不到此頁面或主題,請使用 /ic help 返回常用指令。` +- `command.claim.chat-timeout` + - 原:`&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。` + - 新:`&c邀請碼輸入已逾時,請重新執行 /invitecode claim。` +- `command.claim.dialog-label` + - 原:`六位邀請碼` + - 新:`邀請碼` +- `command.claim.dialog-timeout` + - 原:`&e邀請碼輸入已逾時。&f請重新執行 /invitecode claim。` + - 新:`&c邀請碼輸入已逾時,請重新執行 /invitecode claim。` +- `command.claim.invalid-code` + - 原:`&c邀請碼格式不正確。&f請檢查後重新輸入。` + - 新:`&c邀請碼格式不正確,請檢查後重新輸入。` +- `command.claim.unavailable` + - 原:`&c這組邀請碼不存在或已失效。&f請向邀請人確認目前的邀請碼。` + - 新:`&c這組邀請碼不存在或已失效,請向邀請人確認目前的邀請碼。` +- `command.claim.confirmation-timeout` + - 原:`&e邀請確認已逾時。&f請重新執行 /invitecode claim。` + - 新:`&c邀請確認已逾時,請重新執行 /invitecode claim。` +- `command.claim.no-confirmation` + - 原:`&e目前沒有可確認的邀請,或確認已逾時。&f請重新執行 /invitecode claim。` + - 新:`&c目前沒有可確認的邀請,或確認已逾時,請重新執行 /invitecode claim。` +- `command.claim.matching-network-denied` + - 原:`&c你與邀請人近期使用相同網路,依伺服器規則無法登記。&f如需協助,請聯絡管理員。` + - 新:`&c你與邀請人近期使用相同網路,依伺服器規則無法登記,如需協助請聯絡管理員。` +- `command.error` + - 原:`&c操作失敗。&f請聯絡管理員檢查伺服器紀錄。` + - 新:`&c操作失敗,請聯絡管理員檢查伺服器紀錄。` +- `command.stopping` + - 原:`&e插件正在停止,暫時無法操作。&f請稍後再試。` + - 新:`&c插件正在停止,暫時無法操作,請稍後再試。` +- `admin.error` + - 原:`&c管理操作失敗。&f請檢查伺服器紀錄。` + - 新:`&c管理操作失敗,請檢查伺服器紀錄。` +- `admin.reload-failed` + - 原:`&c重新載入失敗,仍使用上一份有效設定。&f請檢查伺服器紀錄並修正設定。` + - 新:`&c重新載入失敗,仍使用上一份有效設定,請檢查伺服器紀錄並修正設定。` +- `admin.storage-config-unavailable` + - 原:`&c設定尚未成功載入,無法判定儲存位置。&f請檢查伺服器紀錄。` + - 新:`&c設定尚未成功載入,無法判定儲存位置,請檢查伺服器紀錄。` +- `admin.storage-failed` + - 原:`&c儲存結構更新失敗。&f請檢查伺服器紀錄。` + - 新:`&c儲存結構更新失敗,請檢查伺服器紀錄。` +- `admin.doctor-storage-failed` + - 原:`&c儲存健康檢查失敗。&f請檢查伺服器紀錄。` + - 新:`&c儲存健康檢查失敗,請檢查伺服器紀錄。` +### en_US + +- `runtime.usage` + - 原:`&cInvalid command usage. &fUse /{label} help for instructions.` + - 新:`&cInvalid command usage, so use /{label} help for instructions.` +- `runtime.help-page-error` + - 原:`&cThat page or topic was not found. &fUse /ic help to return to common commands.` + - 新:`&cThat page or topic was not found, so use /ic help to return to common commands.` +- `command.claim.chat-timeout` + - 原:`&eCode input has expired. &fRun /invitecode claim again.` + - 新:`&cCode input expired, so run /invitecode claim again.` +- `command.claim.dialog-label` + - 原:`Six-character Invite Code` + - 新:`Invite code` +- `command.claim.dialog-timeout` + - 原:`&eCode input has expired. &fRun /invitecode claim again.` + - 新:`&cCode input expired, so run /invitecode claim again.` +- `command.claim.invalid-code` + - 原:`&cInvalid Invite Code format. &fCheck the code and enter it again.` + - 新:`&cThe Invite Code format is invalid, so check it and enter the code again.` +- `command.claim.unavailable` + - 原:`&cThis Invite Code does not exist or is no longer active. &fAsk the inviter for their current code.` + - 新:`&cThis Invite Code does not exist or is no longer active, so ask the inviter for their current code.` +- `command.claim.confirmation-timeout` + - 原:`&eInvitation confirmation has expired. &fRun /invitecode claim again.` + - 新:`&cInvitation confirmation expired, so run /invitecode claim again.` +- `command.claim.no-confirmation` + - 原:`&eThere is no invitation to confirm, or it has expired. &fRun /invitecode claim again.` + - 新:`&cThere is no invitation to confirm, or it has expired, so run /invitecode claim again.` +- `command.claim.matching-network-denied` + - 原:`&cServer rules prevent this claim because you and the inviter recently used the same network. &fContact an administrator if you need help.` + - 新:`&cServer rules prevent this claim because you and the inviter recently used the same network, so contact an administrator if you need help.` +- `command.error` + - 原:`&cThe operation failed. &fContact an administrator to check the server log.` + - 新:`&cThe operation failed, so contact an administrator to check the server log.` +- `command.stopping` + - 原:`&eThe plugin is stopping and cannot accept operations. &fTry again later.` + - 新:`&cThe plugin is stopping and cannot accept operations, so try again later.` +- `admin.error` + - 原:`&cThe administrative operation failed. &fCheck the server log.` + - 新:`&cThe administrative operation failed, so check the server log.` +- `admin.reload-failed` + - 原:`&cReload failed. The previous configuration remains active. &fCheck the server log and fix the configuration.` + - 新:`&cReload failed while the previous configuration remains active, so check the server log and fix the configuration.` +- `admin.storage-config-unavailable` + - 原:`&cConfiguration is not loaded, so the storage location is unknown. &fCheck the server log.` + - 新:`&cBecause configuration is not loaded, the storage location is unknown, so check the server log.` +- `admin.storage-failed` + - 原:`&cStorage schema update failed. &fCheck the server log.` + - 新:`&cStorage schema update failed, so check the server log.` +- `admin.doctor-storage-failed` + - 原:`&cThe storage health check failed. &fCheck the server log.` + - 新:`&cThe storage health check failed, so check the server log.` diff --git a/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.json b/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.json new file mode 100644 index 0000000..b465c3c --- /dev/null +++ b/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.json @@ -0,0 +1,77 @@ +{ + "date": "2026-10-30", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "jarSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "instance": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "core": "Folia 26.1.2 stable build 8", + "port": 30101, + "java": "local-25 / JDK 25.0.4.1", + "previousRunStopped": { + "runId": "9d3165afa9e54149b9e41183cd88aa9c", + "exitCode": 0, + "outputDrained": true + }, + "backup": { + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\claim-ux-20261029-190401-01167f8f", + "files": 21, + "hashVerified": true, + "worldsRetainedInPlace": true, + "worldHeaderHashVerifiedDuringDeployment": true + }, + "deployment": "JAR and zh_TW/en_US only; one installed JAR, workspace metadata updated", + "postStart": { + "ready": true, + "runId": "778f50e16f4a49c0994aa1449851aaf8", + "hostPid": 49208, + "childPid": 59756, + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "jarSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "doctorPassed": true, + "newHelpErrorCopyPassed": true, + "noRawColors": true, + "startupErrors": false, + "invitationStatus": "QUALIFIED", + "deliveredActions": 2, + "qualificationPermissionRestoredToFalse": true, + "routeConfirmed": true, + "velocityListening": true, + "otherServers": [ + { + "name": "invitecode-paper-26.3", + "state": "Stopped" + }, + { + "name": "invitecode-spigot-1.8.8", + "state": "Stopped" + } + ], + "humanNewCandidateAcceptance": "pending" + }, + "preservation": { + "dbQuickCheck": "ok", + "allHistoricalInvitationAndRewardRowsPreserved": true, + "runtimeNetworkTimestampRefresh": [], + "configAndKeyPreserved": true, + "databaseRestoredFromBackup": false, + "newResetOrClaim": false + }, + "permissionRestoration": { + "player": "Taiwan_PingLord", + "permission": "invitecode.test.qualified", + "before": true, + "expectedAfter": false, + "reason": "Restore agreed temporary qualification override after completed reward acceptance", + "state": "verified", + "after": false, + "onlyTargetNodeChanged": true + }, + "rewardHumanAcceptance": "2026-10-30-folia-reward-human-acceptance.json", + "humanNewCandidateAcceptance": "pending", + "remaining": [ + "Player status primary-reason and error-style visual checks", + "Native input label and timeout visual checks require an eligible account; current A and B cannot claim; do not auto-reset", + "Remaining temporary qualifications/same-network settings restoration after acceptance", + "Other core acceptance and release gates" + ], + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.md b/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.md new file mode 100644 index 0000000..e045c94 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-claim-ux-folia-deployment.md @@ -0,0 +1,21 @@ +# Folia 四項 UI 候選部署與舊流程驗收 + +2026-10-30。舊候選 `1a83b73` 的資格/離線補發/再次登入不重複由使用者確認通過。 +唯讀核對 generation 2 一筆 QUALIFIED、單一 Reward Delivery 完成、A/B 兩筆 MESSAGE 動作均 DELIVERED,舊 UNLINKED 保留。 +這是舊候選流程通過,不代替新輸入框外觀驗收。 + +依使用者選定先測完再更新的順序,正常停止前次 run;退出碼 0、輸出排空、程序及 port 釋放確認。 +21 個檔案在停止狀態備份與 hash 核對完成,世界保留原處且部署期間標頭不變。 +備份位置:`D:\Code\Java\Plugin\InstanceHarbor\instances\Human\InviteCode\invitecode-folia-26.1.2\.invitecode-backups\claim-ux-20261029-190401-01167f8f`。 +僅更新 Folia JAR、兩語系及 workspace metadata。來源 `5702e91a261cf6587056eac8752c21f49a26ff33`,SHA-256 `B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72`。 +沒有重設 B、unlink、回灌 DB、刪 key、改核心或碰其他測服。 + +Folia Done/Listening;實際 JDK 25.0.4.1。doctor、更新後 help 錯誤句與無色碼外洩通過,無啟動 Exception/ERROR。 +啟動後逐表核對邀請/獎勵與備份一致,DB quick_check=ok;config/key 保留。 +之後依測試還原安排,僅透過 LuckPerms 將 B 的 invitecode.test.qualified true 改回原 false,持久化與 live check 通過; +其他權限語意不變。Qualified 及兩個 Delivered 仍保留。這項權限還原與部署期間的資料不變分開記錄。 + +Paper 26.3/Spigot 1.8.8 維持停止。Velocity 入口與 Folia 路由核對;設定與 port 不代替玩家登入驗收。 +A/B 目前都不可再次 claim,新 Dialog 逾時/標籤真人複驗需後續合資格帳號安排,不自動重設 B。 +matching-ip-action=ALLOW 與臨時 qualification profile 仍保留至後續驗收還原,不宣稱全部暫設已還原。 +沒有新 build(重用已通過 Java 8/11 的固定候選)、push、PR、merge 或發布。 diff --git a/docs/testing/evidence/2026-10-30-claim-ux-invalid.png b/docs/testing/evidence/2026-10-30-claim-ux-invalid.png new file mode 100644 index 0000000..ab6d801 Binary files /dev/null and b/docs/testing/evidence/2026-10-30-claim-ux-invalid.png differ diff --git a/docs/testing/evidence/2026-10-30-claim-ux-status.png b/docs/testing/evidence/2026-10-30-claim-ux-status.png new file mode 100644 index 0000000..4c580cf Binary files /dev/null and b/docs/testing/evidence/2026-10-30-claim-ux-status.png differ diff --git a/docs/testing/evidence/2026-10-30-folia-b-reset-ready.json b/docs/testing/evidence/2026-10-30-folia-b-reset-ready.json new file mode 100644 index 0000000..ed0266a --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-b-reset-ready.json @@ -0,0 +1,89 @@ +{ + "date": "2026-10-30", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "pluginSha256": "5D7E7782E8BAEA222785DA8FA8B15416E777649517C5F63AD53101D48BE6733D", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "platform": "Folia 26.1.2 stable build 8", + "instance": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "backup": { + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\b-reset-20261029-174549-58816683", + "files": 20, + "bytes": 242869, + "hashVerified": true, + "worldsRetainedInPlace": true, + "worldHeadersVerifiedBeforeStart": true, + "dbQuickCheck": "ok", + "previousExitCode": 0, + "previousOutputDrained": true + }, + "reset": { + "state": "verified", + "runId": "9d3165afa9e54149b9e41183cd88aa9c", + "player": "Taiwan_PingLord", + "generationBefore": 1, + "command": "ic admin eligibility reset Taiwan_PingLord command-feedback-human-20261030", + "authorized": true, + "requestedUtc": "2026-10-29T17:47:06.113205+00:00", + "firstSeenUtc": "2026-10-29T17:47:06.302606400Z", + "generationAfter": 2, + "deadlineTaipei": "2026-10-31T01:47:06.302606+08:00", + "auditRecordsAdded": 1, + "changedTables": [ + "invitecode_players", + "invitecode_audit_records" + ], + "otherPlayerCodeInvitationRewardDataPreserved": true, + "configurationKeyPermissionsPreserved": true + }, + "runtime": { + "ready": true, + "runId": "9d3165afa9e54149b9e41183cd88aa9c", + "hostPid": 57096, + "childPid": 59612, + "javaAlias": "local-25", + "port": 30101, + "doctorActive": true, + "qualificationPermissionFalse": true, + "startupErrors": false, + "otherServers": [ + { + "name": "invitecode-paper-26.3", + "state": "Stopped" + }, + { + "name": "invitecode-spigot-1.8.8", + "state": "Stopped" + } + ], + "entryPorts": [ + { + "name": "Velocity", + "port": 25565, + "listening": true + }, + { + "name": "lobby", + "port": 10001, + "listening": false + }, + { + "name": "Play", + "port": 20401, + "listening": true + } + ], + "routeConfigured": true, + "humanAcceptance": "not started" + }, + "jdk": "local-25 / C:/Program Files/Java/jdk-25.0.4.1/bin/java.exe", + "sameNetworkAction": "ALLOW unchanged", + "qualificationPermission": "false unchanged", + "dataChanges": "Only B first_seen_at and eligibility_generation, plus one ELIGIBILITY_RESET audit row. All other player/code/invitation/reward data preserved; no unlink. Configuration/key/permission bytes preserved.", + "phase": "2/3 complete; 3/3 human acceptance pending", + "notes": [ + "Start was necessary to execute the authorized admin command via the plugin; no raw SQL mutation.", + "Only Folia started; other InviteCode cores remain stopped.", + "No synthetic player or human claim was performed by Agent.", + "No push/PR/merge." + ] +} diff --git a/docs/testing/evidence/2026-10-30-folia-claim-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-claim-human-acceptance.json new file mode 100644 index 0000000..c9eadec --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-claim-human-acceptance.json @@ -0,0 +1,14 @@ +{ + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "date": "2026-10-30", + "userReport": "登記完成", + "humanReportedSteps": "User reports assigned tests completed; input-dialog UX defects tracked separately, timeout fix not accepted yet.", + "newInvitationCount": 1, + "status": "CLAIMED", + "direction": "Command1 -> Taiwan_PingLord", + "generation": 2, + "oldUnlinkedPreserved": true, + "rewardActionCount": 0, + "qualificationPermission": "false at last verified check", + "dataMutations": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-closeout-crosscore-preparation.json b/docs/testing/evidence/2026-10-30-folia-closeout-crosscore-preparation.json new file mode 100644 index 0000000..6965803 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-closeout-crosscore-preparation.json @@ -0,0 +1,184 @@ +{ + "date": "2026-10-30", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "jarSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "candidateJavaValidation": [ + "Java 11 check shadowJar", + "Java 8 check shadowJar", + "verifyPluginJar", + "verifyJava8Bytecode" + ], + "foliaCloseout": { + "restoration": { + "settingsRestored": true, + "originalPolicy": "PLAY_TIME >= 30m AND LOGIN_DAYS >= 2", + "sameNetworkAction": "DENY", + "reloadPassed": true, + "doctorPassed": true, + "allOtherProtectedDataPreserved": true, + "runId": "a01e5100080543178a140df507e03ae5" + }, + "backupPath": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\folia-closeout-20261029-195818-fe553e57", + "backupFiles": 20, + "originalBackup": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\command-feedback-20261018-063038-7d440eea", + "finalState": "Stopped", + "exitCode": 0, + "outputDrained": true, + "dataPreserved": true + }, + "crosscoreBackups": [ + { + "name": "invitecode-spigot-1.8.8", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-spigot-1.8.8\\.invitecode-backups\\crosscore-20261029-200012-c51e9448", + "files": 20, + "hashVerified": true, + "worldsRetainedInPlace": true + }, + { + "name": "invitecode-paper-26.3", + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-paper-26.3\\.invitecode-backups\\crosscore-20261029-200012-940ad1d0", + "files": 18, + "hashVerified": true, + "worldsRetainedInPlace": true + } + ], + "runtime": { + "instances": [ + { + "name": "invitecode-spigot-1.8.8", + "ready": true, + "runId": "14af70d2993c40d2b2ebcafef1c6fbe8", + "hostPid": 62084, + "childPid": 42292, + "port": 10101, + "javaAlias": "local-8", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "pluginSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "coreLines": [ + "[04:02:50] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-3c60ece-741a1bd (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)" + ], + "coreSha256": "6ED6046687CE9255228FE7BD31E097DA49BEFF2A0C577E7BE56D14F09753239C", + "consoleProbesPassed": true, + "dialog": "NONE", + "rawColors": false, + "startupErrors": false, + "legacyForwardingConfig": true, + "BGeneration": 2, + "newInvitations": 0, + "historicalDeliveredActions": 2 + }, + { + "name": "invitecode-paper-26.3", + "ready": true, + "runId": "d4c297c90da84d68ae4e52fecadb0243", + "hostPid": 57144, + "childPid": 61724, + "port": 20102, + "javaAlias": "local-25", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "pluginSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "coreLines": [ + "[04:02:49] [ServerMain/INFO]: [bootstrap] Loading Paper 26.3-202-main@29aeb60 (2026-10-17T14:15:06Z) for Minecraft 26.3", + "[04:03:03] [Server thread/INFO]: Starting minecraft server version 26.3", + "[04:03:03] [Server thread/INFO]: This server is running Paper version 26.3-202-main@29aeb60 (2026-10-17T14:15:06Z) (Implementing API version 26.3.build.202-stable)" + ], + "coreSha256": "1B243442FC3B3CBE945628F8AF7911E4BE439CA8B22106FB1568AC81D5A5792B", + "consoleProbesPassed": true, + "dialog": "PAPER", + "rawColors": false, + "startupErrors": false, + "legacyForwardingConfig": true, + "BGeneration": 2, + "newInvitations": 0, + "historicalDeliveredActions": 2 + } + ], + "velocityListening": true, + "routeMappingVerified": true, + "forwarding": "legacy", + "proxyTranslationJarsPresent": [ + "ViaVersion-5.12.0.jar", + "ViaBackwards-5.12.0.jar", + "ViaRewind-4.2.0.jar" + ], + "nativeClientAcceptance": "pending", + "foliaState": "Stopped" + }, + "resets": [ + { + "state": "verified", + "instance": "invitecode-spigot-1.8.8", + "runId": "14af70d2993c40d2b2ebcafef1c6fbe8", + "player": "Taiwan_PingLord", + "generationBefore": 1, + "command": "ic admin eligibility reset Taiwan_PingLord command-feedback-crosscore-20261030", + "authorized": true, + "requestedUtc": "2026-10-29T20:03:38.414369+00:00", + "firstSeenUtc": "2026-10-29T20:03:38.487Z", + "generationAfter": 2, + "deadlineTaipei": "2026-10-31T04:03:38.487000+08:00", + "auditRecordsAdded": 1, + "changedTables": [ + "invitecode_players", + "invitecode_audit_records" + ], + "otherPlayerCodeInvitationRewardDataPreserved": true, + "configurationKeyPermissionsPreserved": true + }, + { + "state": "verified", + "instance": "invitecode-paper-26.3", + "runId": "d4c297c90da84d68ae4e52fecadb0243", + "player": "Taiwan_PingLord", + "generationBefore": 1, + "command": "ic admin eligibility reset Taiwan_PingLord command-feedback-crosscore-20261030", + "authorized": true, + "requestedUtc": "2026-10-29T20:03:39.497956+00:00", + "firstSeenUtc": "2026-10-29T20:03:39.615258700Z", + "generationAfter": 2, + "deadlineTaipei": "2026-10-31T04:03:39.615258+08:00", + "auditRecordsAdded": 1, + "changedTables": [ + "invitecode_players", + "invitecode_audit_records" + ], + "otherPlayerCodeInvitationRewardDataPreserved": true, + "configurationKeyPermissionsPreserved": true + } + ], + "failedReloadValidation": [ + { + "name": "invitecode-spigot-1.8.8", + "invalidBooleanRejected": true, + "validGenerationRetained": true, + "originalFileRestoredByteForByte": true, + "validReloadPassed": true, + "configSha256": "9E6DC6996C5A7EB99E27711E95F34C556CDBAD996C7F8675FE25594EB66EF61C" + }, + { + "name": "invitecode-paper-26.3", + "invalidBooleanRejected": true, + "validGenerationRetained": true, + "originalFileRestoredByteForByte": true, + "validReloadPassed": true, + "configSha256": "9E6DC6996C5A7EB99E27711E95F34C556CDBAD996C7F8675FE25594EB66EF61C" + } + ], + "historicalData": { + "oldGeneration0QualifiedPreserved": true, + "oldDeliveredActionsPerServer": 2, + "newGeneration2InvitationsPerServer": 0, + "AAndOriginalCodePreserved": true, + "dbQuickCheckPerServer": "ok", + "allOtherSettingsKeyAndPermissionsPreserved": true + }, + "humanAcceptance": "pending; no player automation used", + "temporaryConditions": { + "bothSameNetworkAction": "ALLOW preserved for same-PC tests", + "spigotQualification": "invitecode.command.basic; may qualify immediately; inviter must disconnect BEFORE final agreement", + "paperQualification": "invitecode.test.qualified false; console true only after inviter disconnects", + "spigotThirdPartyLimitation": "LuckPerms 5.4.145 existing Gson JSON save issue; no lp permission writes in this test", + "proxyVersionTranslation": "JARs present; native-client connection and transfer still require human acceptance" + }, + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-command-panel-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-command-panel-human-acceptance.json new file mode 100644 index 0000000..a197bca --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-command-panel-human-acceptance.json @@ -0,0 +1,21 @@ +{ + "date": "2026-10-30", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "platform": "Folia 26.1.2", + "humanReport": "以上四項都測試過,基本都沒有問題", + "accepted": [ + "Home help click and disabled navigation", + "Administrator/general-player permissions and Tab boundaries", + "status/stats and invitation-code hover/copy", + "Console Tab completion and argument boundaries" + ], + "result": "passed", + "remaining": [ + "Bilingual messages and valid/invalid reload with restoration", + "Two-account claim confirmation and qualification/reward delivery", + "Restart retention and temporary setting restoration", + "Other core human acceptance" + ], + "serverState": "Not inspected or changed in this documentation-only turn", + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-input-dialog-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-input-dialog-human-acceptance.json new file mode 100644 index 0000000..d96a9fc --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-input-dialog-human-acceptance.json @@ -0,0 +1,60 @@ +{ + "date": "2026-10-30", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "platform": "Folia 26.1.2", + "humanReport": "標籤/逾時關閉/逾時提示/格式錯誤/取消:通過", + "accepted": [ + "input label without fixed length", + "automatic input dialog close at timeout", + "timeout feedback", + "single-red invalid-format message", + "cancel/decline without registration" + ], + "runtimeState": "Listening", + "BGeneration": 3, + "currentGenerationInvitationCount": 0, + "historicalInvitations": [ + { + "status": "UNLINKED", + "generation": 0 + }, + { + "status": "QUALIFIED", + "generation": 2 + } + ], + "rewardActions": [ + { + "status": "DELIVERED", + "count": 2 + } + ], + "qualificationPermission": false, + "temporarySameNetworkAction": "ALLOW", + "temporaryQualificationPolicy": { + "config-version": 1, + "policies": { + "new-player": { + "any-of": [ + { + "all-of": [ + { + "id": "manual-human-test", + "type": "PERMISSION", + "permission": "invitecode.test.qualified" + } + ] + } + ] + } + } + }, + "agentMutations": false, + "remoteWrites": false, + "remaining": [ + "Restore remaining temporary Folia same-network and qualification-profile settings using verified original backups", + "Prepare same-candidate Spigot 1.8.8 and Paper 26.3 acceptance", + "Retain latest Folia ALPHA and Paper 26.2 adapter verification gaps until addressed" + ], + "note": "Folia assigned input UI checks passed; this does not mark other cores or the entire branch accepted." +} diff --git a/docs/testing/evidence/2026-10-30-folia-input-dialog-reset-ready.json b/docs/testing/evidence/2026-10-30-folia-input-dialog-reset-ready.json new file mode 100644 index 0000000..b65282c --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-input-dialog-reset-ready.json @@ -0,0 +1,82 @@ +{ + "date": "2026-10-30", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "jarSha256": "B0FB78588CA317650A83F7385441576DC5034612249318E865BB89FAB083EF72", + "instance": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "authorization": "User approved a new B-only 2->3 reset after reviewing its scope; no new accepted invitation or rewards", + "backup": { + "path": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2\\.invitecode-backups\\input-reset-20261029-192359-a1621a97", + "files": 20, + "hashVerified": true, + "dbQuickCheck": "ok", + "worldsRetainedInPlace": true, + "worldHeadersVerifiedBeforeStart": true, + "previousExitCode": 0, + "previousOutputDrained": true + }, + "operation": { + "state": "verified", + "runId": "7a949699bc6b4678b4094f7338e00e1c", + "player": "Taiwan_PingLord", + "generationBefore": 2, + "command": "ic admin eligibility reset Taiwan_PingLord claim-input-ui-20261030", + "authorized": true, + "requestedUtc": "2026-10-29T19:25:02.479966+00:00", + "firstSeenUtc": "2026-10-29T19:25:02.616506700Z", + "generationAfter": 3, + "deadlineTaipei": "2026-10-31T03:25:02.616506+08:00", + "auditRecordsAdded": 1, + "changedTables": [ + "invitecode_players", + "invitecode_audit_records" + ], + "otherPlayerCodeInvitationRewardDataPreserved": true, + "configurationKeyPermissionsPreserved": true + }, + "runtime": { + "ready": true, + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "runId": "7a949699bc6b4678b4094f7338e00e1c", + "childPid": 49684, + "hostPid": 24516, + "port": 30101, + "dbQuickCheck": "ok", + "BGeneration": 3, + "currentInvitations": 0, + "oldInvitations": [ + { + "status": "UNLINKED", + "generation": 0 + }, + { + "status": "QUALIFIED", + "generation": 2 + } + ], + "rewardActions": [ + { + "status": "DELIVERED", + "count": 2 + } + ], + "qualificationPermission": false, + "startupErrors": false, + "otherServers": [ + { + "name": "invitecode-paper-26.3", + "state": "Stopped" + }, + { + "name": "invitecode-spigot-1.8.8", + "state": "Stopped" + } + ], + "routeVerified": true, + "velocityListening": true, + "humanInputAcceptance": "pending" + }, + "noJarOrConfigurationChanges": true, + "noUnlinkOrNewClaim": true, + "humanAcceptance": "pending input dialog only", + "remoteWrites": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-locale-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-locale-human-acceptance.json new file mode 100644 index 0000000..35e5ce0 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-locale-human-acceptance.json @@ -0,0 +1,18 @@ +{ + "date": "2026-10-30", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "platform": "Folia 26.1.2", + "humanReport": "以上四項都有通過,並且 console 跟著預設的這個繁體中文跑,也沒有問題。然後第三步的這個部分,我只有更改這個 config 裡面的這個 use-client-locale,剩下的是沒有動過的,後面也有將其復原了。", + "accepted": [ + "Reported bilingual display", + "Console follows configured Traditional Chinese default", + "use-client-locale setting switch and restoration as reported" + ], + "scopeClarification": "Actual setting edits were limited to use-client-locale; prefix templates and invalid types were not edited. Do not equate locale selection with failed-reload snapshot retention.", + "stillUnverified": [ + "presentation.prefix edit followed by successful reload", + "Invalid prefix type rejected with previous valid snapshot retained", + "Prefix-template restoration after that failure scenario" + ], + "agentActions": "Documentation only; no settings, data, lifecycle or remote writes" +} diff --git a/docs/testing/evidence/2026-10-30-folia-reload-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-reload-human-acceptance.json new file mode 100644 index 0000000..071b657 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-reload-human-acceptance.json @@ -0,0 +1,23 @@ +{ + "date": "2026-10-30", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "platform": "Folia 26.1.2", + "humanReport": "reload了之後,這個 reload 的訊息就已經生效了,並且不同的語言也有這個不同的 prefix,是沒有問題的。然後第二個部分是確定是拒絕 update 錯誤的這個 config 設定,並且保持原有的這個設定這樣子,也沒有跑到預設的這個 true 之類的。因為我有在先前將 true 跟 false 都 reload 過一遍,它確實有正確地按照這個開啟或關閉的這個功能。然後之後再將其改壞,確實有保留上一版的這個部分這樣子。", + "accepted": [ + "Successful reload updates visible feedback", + "Locale-specific prefixes display correctly", + "use-client-locale true and false each apply correctly after reload", + "Invalid configuration reload is rejected and retains last valid settings instead of falling back to defaults" + ], + "result": "Bilingual and reload human acceptance passed within reported scope", + "clarification": "Invalid config case used use-client-locale; no claim that a numeric presentation.prefix template was specifically tested. The reported real invalid-config case satisfies this human reload gate; do not demand the earlier example again.", + "restoration": "User previously reported restoring use-client-locale; no Agent runtime changes this turn", + "supersedesPendingAssessment": "2026-10-30-folia-locale-human-acceptance.json", + "remaining": [ + "Two-account confirmation flow", + "Qualification and offline once-only rewards", + "Restart retention and test-setting restoration", + "Other core human acceptance" + ], + "agentActions": "Documentation only; no server, settings, data or remote writes" +} diff --git a/docs/testing/evidence/2026-10-30-folia-reward-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-reward-human-acceptance.json new file mode 100644 index 0000000..f71261b --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-reward-human-acceptance.json @@ -0,0 +1,35 @@ +{ + "date": "2026-10-30", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "humanReport": "以上确认完成,确认没有问题。", + "accepted": [ + "qualification notification", + "offline rewards", + "no duplicate reward on rejoin" + ], + "generation": 2, + "invitationCount": 1, + "invitationStatus": "QUALIFIED", + "actions": [ + { + "action_type": "MESSAGE", + "status": "DELIVERED", + "position": 0, + "recipient": "A" + }, + { + "action_type": "MESSAGE", + "status": "DELIVERED", + "position": 1, + "recipient": "B" + } + ], + "deliveries": [ + { + "status": "DELIVERED", + "count": 1 + } + ], + "oldUnlinkedPreserved": true, + "agentMutations": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-two-account-preflight.json b/docs/testing/evidence/2026-10-30-folia-two-account-preflight.json new file mode 100644 index 0000000..ad5d856 --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-two-account-preflight.json @@ -0,0 +1,80 @@ +{ + "date": "2026-10-30", + "checkedUtc": "2026-10-29T17:31:58.586488+00:00", + "instance": "D:\\Code\\Java\\Plugin\\InstanceHarbor\\instances\\Human\\InviteCode\\invitecode-folia-26.1.2", + "sourceCommit": "1a83b7328353f132dfb5da29b6cde15e3ade50d0", + "pluginSha256": "5D7E7782E8BAEA222785DA8FA8B15416E777649517C5F63AD53101D48BE6733D", + "coreSha256": "607AFD1C3320008E1FFD2EAEE6780ACE4419D5F8C527B75E79F259BE79EBF57B", + "minecraftVersion": "26.1.2", + "core": "Folia", + "coreIdentity": "unchanged from previously verified stable build 8", + "port": 30101, + "serverState": "Listening", + "runId": "61949b6f08e948319f7e8b1af192f370", + "route": "invitecode-folia-26.1.2 = 127.0.0.1:30101", + "language": { + "default": "zh_TW", + "use-client-locale": true + }, + "claim": { + "window": "24h", + "input-mode": "AUTO", + "confirmation-timeout": "60s", + "chat-input-timeout": "60s", + "existing-player-policy": "START_WINDOW" + }, + "sameNetworkAction": "ALLOW", + "B": { + "name": "Taiwan_PingLord", + "generation": 1, + "firstSeen": "2026-10-18T06:38:31.389488600Z", + "expiredDeadlineTaipei": "2026-10-19 14:38:31 +08:00", + "eligible": false, + "blockingReason": "CLAIM_WINDOW_EXPIRED", + "activeCodeCount": 0, + "currentGenerationInvitationCount": 0, + "oldInvitations": [ + { + "status": "UNLINKED", + "invitee_eligibility_generation": 0 + } + ], + "rewardActionCount": 0, + "qualificationPermission": "false in persisted LuckPerms and live read-only check" + }, + "A": { + "name": "Command1", + "activeCodePreserved": true + }, + "rewardTypes": [ + "MESSAGE", + "MESSAGE" + ], + "proposedOperation": { + "state": "awaiting explicit authorization", + "command": "ic admin eligibility reset Taiwan_PingLord command-feedback-human-20261030", + "scope": "Folia B only", + "firstSeenAt": "set to execution time", + "generation": "1 -> 2", + "newAuditRecords": 1, + "preserve": [ + "A", + "invite codes", + "old UNLINKED invitation", + "reward records", + "worlds", + "key", + "config", + "permissions" + ], + "noUnlinkNeeded": true, + "backup": "consistent SQLite backup and settings/key/permissions snapshot before operation; no old DB restore" + }, + "completedPhase": "1/3 read-only preflight", + "remainingPhases": [ + "2/3 approved backup and B eligibility reset", + "3/3 human confirmation and reward testing with data verification" + ], + "remoteWrites": false, + "dataMutations": false +} diff --git a/docs/testing/evidence/2026-10-30-folia-ux-three-checks-human-acceptance.json b/docs/testing/evidence/2026-10-30-folia-ux-three-checks-human-acceptance.json new file mode 100644 index 0000000..457e3ae --- /dev/null +++ b/docs/testing/evidence/2026-10-30-folia-ux-three-checks-human-acceptance.json @@ -0,0 +1,60 @@ +{ + "date": "2026-10-30", + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "platform": "Folia 26.1.2", + "humanReport": "以上三點都通過,都沒有什麼問題。", + "accepted": [ + "status displays primary reason only", + "error and retry guidance share one red sentence", + "invitation/stats retained across restart without repeat rewards" + ], + "liveReadOnlyCheck": { + "sourceCommit": "5702e91a261cf6587056eac8752c21f49a26ff33", + "serverState": "Listening", + "players": [ + { + "name": "Command1", + "generation": 0, + "activeCodes": 1, + "currentInvitations": [] + }, + { + "name": "Taiwan_PingLord", + "generation": 2, + "activeCodes": 0, + "currentInvitations": [ + { + "status": "QUALIFIED", + "count": 1 + } + ] + } + ], + "rewardActions": [ + { + "status": "DELIVERED", + "count": 2 + } + ], + "agentMutations": false + }, + "newInputDialogHumanAcceptance": "pending; A has own code, B has qualified current-generation invitation", + "proposedPreparation": { + "state": "awaiting explicit authorization; not performed", + "player": "Taiwan_PingLord", + "command": "ic admin eligibility reset Taiwan_PingLord claim-input-ui-20261030", + "generation": "2 -> 3", + "firstSeen": "set to execution time; opens configured 24h claim window", + "auditRecordsAdded": 1, + "preserve": [ + "generation-2 QUALIFIED invitation", + "generation-0 UNLINKED invitation", + "2 DELIVERED reward actions", + "A and code", + "worlds/key/config/permissions" + ], + "testScope": "input label, 60s automatic close and timeout feedback, invalid-code red sentence, valid input followed by decline/cancel; no new accepted invitation or rewards" + }, + "agentDataMutations": false, + "remoteWrites": false +} diff --git a/docs/testing/test-servers.md b/docs/testing/test-servers.md index 2d394a1..e4317e8 100644 --- a/docs/testing/test-servers.md +++ b/docs/testing/test-servers.md @@ -2,6 +2,14 @@ InviteCode 使用專案外的 `D:\Code\Java\Plugin\InstanceHarbor` 共用伺服器核心快取與工具,但每個 profile、Worktree 與驗收版本都建立獨立實例。World、插件設定、SQLite、log 與其他可變狀態不跨實例共用。 +訊息顯示矩陣的現行 C# 管理器操作、鎖定核心/JDK、Agent 隔離及檢查結果見 [2026-10-18 第三階段證據](evidence/2026-10-18-command-feedback-stage3.md)。下方 PowerShell runner 是歷史流程;本輪沒有直接沿用其啟停或舊訊息比對,也沒有把可攜式管理器的 C# 入口退回為舊產品腳本。渲染客戶端與真人外觀驗收仍分開處理。 + +第四階段的[兩帳號真人步驟](command-feedback-human-acceptance.md)已更新為可直接開始的版本; +2026-10-18 已依使用者授權備份、部署並啟動三台,完成 B 資格重設與 Folia 指定舊列 unlink。 +世界、歷史與稽核保留;實際核心/JDK、候選 hash、當次 run 與備份見[部署證據](evidence/2026-10-18-command-feedback-stage4-deployment.md)。 +Spigot 的資格測試不寫 LuckPerms JSON,A 須在 B 最後同意前回 Lobby。 +部署前的[唯讀 preflight](evidence/2026-10-18-command-feedback-stage4-preflight.json)保留為歷史基線,不代表目前仍未部署。 + ## 測試矩陣 正式矩陣定義於 `test-servers/matrix.json`: diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/Invitation.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/Invitation.kt index 79f10e4..dc47bd2 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/Invitation.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/Invitation.kt @@ -38,7 +38,7 @@ data class Invitation( fun qualify(at: Instant, policyId: String, revision: String): Invitation { check(status == InvitationStatus.CLAIMED) { - "Only a claimed invitation can become qualified; current status is $status." + "Only a claimed invitation can become qualified\ncurrent status is $status." } require(policyId.isNotBlank()) { "Qualification policy ID must not be blank." } require(revision.isNotBlank()) { "Qualification revision must not be blank." } @@ -71,7 +71,7 @@ data class Invitation( context: InvitationAdministrationContext, ): AuditedInvitationTransition { check(status == InvitationStatus.CLAIMED) { - "Only a claimed invitation can be transferred; current status is $status." + "Only a claimed invitation can be transferred\ncurrent status is $status." } require(newInviterId != inviteeId) { "An invitee cannot become their own inviter." } require(newInviterId != inviterId) { "Transfer requires a different Inviter." } diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleService.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleService.kt index acfa4d2..fe21df6 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleService.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleService.kt @@ -54,7 +54,7 @@ interface InviteCodeTransaction { class InviteCodeCollisionException( val attempts: Int, ) : IllegalStateException( - "Could not allocate a unique Invite Code after $attempts attempts; " + + "Could not allocate a unique Invite Code after $attempts attempts\n" + "increase the Invite Code namespace or inspect the Invite Code registry.", ) diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationEvaluator.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationEvaluator.kt index 477479e..2b8bac2 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationEvaluator.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationEvaluator.kt @@ -81,7 +81,7 @@ class QualificationEvaluator( "Qualification context Claim timestamp must match Invitation ${invitation.id}." } check(invitation.status == InvitationStatus.CLAIMED) { - "Only a claimed Invitation can be evaluated; current status is ${invitation.status}." + "Only a claimed Invitation can be evaluated\ncurrent status is ${invitation.status}." } val facts = mutableListOf() diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationPolicy.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationPolicy.kt index 986273f..958f6d5 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationPolicy.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/QualificationPolicy.kt @@ -72,7 +72,7 @@ object QualificationConfigurationParser { "Qualification configuration requires numeric integer 'config-version'.", ) require(version == CURRENT_VERSION) { - "Qualification config-version $version is unsupported; expected $CURRENT_VERSION." + "Qualification config-version $version is unsupported\nexpected $CURRENT_VERSION." } val rawPolicies = value["policies"] require(rawPolicies is Map<*, *> && rawPolicies.isNotEmpty()) { @@ -136,7 +136,7 @@ object QualificationPolicyParser { MissingQualificationProviderOutcome.valueOf(it.uppercase(Locale.ROOT)) } catch (error: IllegalArgumentException) { throw IllegalArgumentException( - "$location has unsupported on-unavailable value '$it'; use UNKNOWN or UNSATISFIED.", + "$location has unsupported on-unavailable value '$it'\nuse UNKNOWN or UNSATISFIED.", error, ) } diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDefinition.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDefinition.kt index befbee8..278acfa 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDefinition.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDefinition.kt @@ -69,7 +69,7 @@ object RewardConfigurationParser { val version = (value["config-version"] as? Number)?.toString()?.toIntOrNull() ?: throw IllegalArgumentException("Reward configuration requires numeric integer config-version.") require(version == CURRENT_VERSION) { - "Reward config-version $version is unsupported; expected $CURRENT_VERSION." + "Reward config-version $version is unsupported\nexpected $CURRENT_VERSION." } val milestoneRewards = value["milestone-rewards"].requiredStringMap("milestone-rewards") .mapValues { (rewardId, rawReward) -> parseMilestoneReward(rewardId, rawReward) } diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDeliveryProcessor.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDeliveryProcessor.kt index 060afe8..21f84ec 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDeliveryProcessor.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/RewardDeliveryProcessor.kt @@ -136,7 +136,7 @@ class RewardDeliveryCoordinator( ): StoredRewardAction { val current = requireNotNull(records.rewardAction(actionId)) { "Reward Action $actionId does not exist." } check(current.status == requiredStatus) { - "Reward Action $actionId must be $requiredStatus; current status is ${current.status}." + "Reward Action $actionId must be $requiredStatus\ncurrent status is ${current.status}." } val transitionAt = if (occurredAt.isAfter(current.updatedAt)) { occurredAt @@ -202,7 +202,7 @@ class RewardDeliveryProcessor( } catch (error: Exception) { val uncertain = coordinator.uncertain( processing.id, - "External Reward Action execution threw ${error.javaClass.simpleName}; result is unknown.", + "External Reward Action execution threw ${error.javaClass.simpleName}\nresult is unknown.", now(), ) return result(RewardActionProcessingStatus.UNCERTAIN, uncertain) diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageConfiguration.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageConfiguration.kt index a714443..92a0eea 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageConfiguration.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageConfiguration.kt @@ -102,7 +102,7 @@ object StorageConfigurationParser { } val version = value.requiredInteger("config-version", "Storage configuration") require(version == CURRENT_VERSION) { - "Storage config-version $version is unsupported; expected $CURRENT_VERSION." + "Storage config-version $version is unsupported\nexpected $CURRENT_VERSION." } val sqlite = value.requiredMap("sqlite", "Storage configuration") require(sqlite.keys == setOf("file")) { "sqlite must contain only file." } diff --git a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageRecords.kt b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageRecords.kt index d44f10e..3558f6f 100644 --- a/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageRecords.kt +++ b/invitecode-core/src/main/kotlin/io/github/command1264/invitecode/core/StorageRecords.kt @@ -219,6 +219,9 @@ interface InviteCodeQueries { /** Returns every eligibility generation, newest Claim first with Invitation ID as the tie-breaker. */ fun invitationsByInvitee(inviteeId: UUID): List + /** Invitation status in the invitee's current eligibility generation. */ + fun currentInviteeInvitationStatus(inviteeId: UUID): io.github.command1264.invitecode.api.InvitationStatus? + /** Returns all Invitations currently attributed to the Inviter, newest first with ID as the tie-breaker. */ fun invitationsByInviter(inviterId: UUID): List diff --git a/invitecode-core/src/test/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleServiceTest.kt b/invitecode-core/src/test/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleServiceTest.kt index afd0882..325fcbb 100644 --- a/invitecode-core/src/test/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleServiceTest.kt +++ b/invitecode-core/src/test/kotlin/io/github/command1264/invitecode/core/InviteCodeLifecycleServiceTest.kt @@ -90,7 +90,7 @@ class InviteCodeLifecycleServiceTest { assertEquals(2, error.attempts) assertEquals( - "Could not allocate a unique Invite Code after 2 attempts; " + + "Could not allocate a unique Invite Code after 2 attempts\n" + "increase the Invite Code namespace or inspect the Invite Code registry.", error.message, ) diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncRewardDeliveryWorkflow.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncRewardDeliveryWorkflow.kt index cdf841f..f7215a4 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncRewardDeliveryWorkflow.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/AsyncRewardDeliveryWorkflow.kt @@ -118,7 +118,7 @@ class AsyncRewardDeliveryWorkflow( RewardActionProcessingStatus.UNCERTAIN, store.uncertain( actionId, - "External Reward Action execution threw ${outcome.errorType}; result is unknown.", + "External Reward Action execution threw ${outcome.errorType}\nresult is unknown.", now(), ), ) diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitPluginConfiguration.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitPluginConfiguration.kt index 1820e3e..808a117 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitPluginConfiguration.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitPluginConfiguration.kt @@ -71,7 +71,7 @@ object BukkitPluginConfigurationParser { } val version = value.requiredInteger("config-version", "General configuration") require(version == CURRENT_VERSION) { - "General config-version $version is unsupported; expected $CURRENT_VERSION." + "General config-version $version is unsupported\nexpected $CURRENT_VERSION." } val language = value.requiredMap("language", "General configuration") requireKeys(language, LANGUAGE_KEYS, "language") diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt index d6b4477..afc529d 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/BukkitRewardExecutionEnvironment.kt @@ -22,6 +22,7 @@ class BukkitRewardExecutionEnvironment( private val economy: EconomyRewardGateway? = null, private val isPrimaryThread: () -> Boolean = Bukkit::isPrimaryThread, private val playerLookup: (UUID) -> Player? = server::getPlayer, + private val messageDelivery: (Player, String) -> Unit = { player, text -> player.sendMessage(text) }, ) : RewardExecutionEnvironment { override fun isOnline(playerId: UUID): Boolean { requireMainThread() @@ -48,7 +49,7 @@ class BukkitRewardExecutionEnvironment( requireMainThread() val player = playerLookup(playerId) ?: return OnlineRewardActionResult.RECIPIENT_OFFLINE - player.sendMessage(messages.resolve(playerId, localeKey)) + messageDelivery(player, messages.resolve(playerId, localeKey)) return OnlineRewardActionResult.ACCEPTED } diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt index e75288d..de37c00 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessions.kt @@ -10,6 +10,11 @@ sealed class ChatInputResult { object Cancelled : ChatInputResult() } +sealed class DialogInputResult { + data class Code(val value: String) : DialogInputResult() + object Expired : DialogInputResult() +} + class ClaimInteractionSessions( private val now: () -> Instant = Instant::now, ) { @@ -35,7 +40,7 @@ class ClaimInteractionSessions( @Synchronized fun hasChatInput(playerId: UUID): Boolean { val session = sessions[playerId] as? Session.ChatInput ?: return false - if (now().isAfter(session.expiresAt)) { + if (!now().isBefore(session.expiresAt)) { sessions.remove(playerId) return false } @@ -46,25 +51,29 @@ class ClaimInteractionSessions( fun consumeChatInput(playerId: UUID, message: String): ChatInputResult? { val session = sessions[playerId] as? Session.ChatInput ?: return null sessions.remove(playerId) - if (now().isAfter(session.expiresAt)) return null + if (!now().isBefore(session.expiresAt)) return null val value = message.trim() return if (value.equals("cancel", ignoreCase = true)) ChatInputResult.Cancelled else ChatInputResult.Code(value) } @Synchronized - fun consumeDialogInput(playerId: UUID, value: String): String? { + fun consumeDialogInput(playerId: UUID, value: String): String? = + (consumeDialogInputResult(playerId, value) as? DialogInputResult.Code)?.value + + @Synchronized + fun consumeDialogInputResult(playerId: UUID, value: String): DialogInputResult? { val session = sessions[playerId] as? Session.DialogInput ?: return null sessions.remove(playerId) - if (now().isAfter(session.expiresAt)) return null - return value.trim() + if (!now().isBefore(session.expiresAt)) return DialogInputResult.Expired + return DialogInputResult.Code(value.trim()) } @Synchronized fun consumeConfirmation(playerId: UUID): ClaimConfirmation? { val session = sessions[playerId] as? Session.Confirmation ?: return null sessions.remove(playerId) - if (now().isAfter(session.value.expiresAt)) return null + if (!now().isBefore(session.value.expiresAt)) return null return session.value } @@ -74,7 +83,7 @@ class ClaimInteractionSessions( @Synchronized fun expireChatInput(playerId: UUID): Boolean { val session = sessions[playerId] as? Session.ChatInput ?: return false - if (!now().isAfter(session.expiresAt)) return false + if (now().isBefore(session.expiresAt)) return false sessions.remove(playerId) return true } @@ -82,7 +91,7 @@ class ClaimInteractionSessions( @Synchronized fun expireDialogInput(playerId: UUID): Boolean { val session = sessions[playerId] as? Session.DialogInput ?: return false - if (!now().isAfter(session.expiresAt)) return false + if (now().isBefore(session.expiresAt)) return false sessions.remove(playerId) return true } @@ -90,7 +99,7 @@ class ClaimInteractionSessions( @Synchronized fun expireConfirmation(playerId: UUID): Boolean { val session = sessions[playerId] as? Session.Confirmation ?: return false - if (!now().isAfter(session.value.expiresAt)) return false + if (now().isBefore(session.value.expiresAt)) return false sessions.remove(playerId) return true } diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelp.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelp.kt new file mode 100644 index 0000000..2a1bd08 --- /dev/null +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelp.kt @@ -0,0 +1,80 @@ +package io.github.command1264.invitecode.platform.bukkit + +/** Help entries mirror parser routes while keeping localized descriptions outside routing logic. */ +data class CommandHelpEntry( + val id: InviteCodeCommandId, + val usage: String, + val descriptionKey: String, + val permission: String, + val playerOnly: Boolean, +) + +object CommandHelp { + val entries: List = listOf( + entry(InviteCodeCommandId.HELP, "help", "help", "invitecode.command.basic", false), + entry(InviteCodeCommandId.CODE, "code", "code", "invitecode.command.code", true), + entry(InviteCodeCommandId.CLAIM, "claim [code]", "claim", "invitecode.command.claim", true), + entry(InviteCodeCommandId.CONFIRM, "confirm", "confirm", "invitecode.command.claim", true), + entry(InviteCodeCommandId.CANCEL, "cancel", "cancel", "invitecode.command.claim", true), + entry(InviteCodeCommandId.STATUS, "status", "status", "invitecode.command.status", true), + entry(InviteCodeCommandId.STATS, "stats", "stats", "invitecode.command.stats", true), + entry( + InviteCodeCommandId.ADMIN_INSPECT_PLAYER, + "admin inspect player ", "inspect-player", "invitecode.admin.inspect", false, + ), + entry( + InviteCodeCommandId.ADMIN_INSPECT_INVITATION, + "admin inspect invitation ", "inspect-invitation", "invitecode.admin.inspect", false, + ), + entry( + InviteCodeCommandId.ADMIN_INSPECT_REWARD, + "admin inspect reward ", "inspect-reward", "invitecode.admin.inspect", false, + ), + entry( + InviteCodeCommandId.ADMIN_INVITATION_UNLINK, + "admin invitation unlink ", "unlink", "invitecode.admin.invitation", false, + ), + entry( + InviteCodeCommandId.ADMIN_INVITATION_TRANSFER, + "admin invitation transfer ", + "transfer", "invitecode.admin.invitation", false, + ), + entry( + InviteCodeCommandId.ADMIN_INVITATION_FORCE_QUALIFY, + "admin invitation force-qualify ", + "force-qualify", "invitecode.admin.qualification", false, + ), + entry( + InviteCodeCommandId.ADMIN_ELIGIBILITY_RESET, + "admin eligibility reset ", "reset-eligibility", + "invitecode.admin.eligibility", false, + ), + entry( + InviteCodeCommandId.ADMIN_REWARD_RETRY, + "admin reward retry ", "retry-reward", "invitecode.admin.reward", false, + ), + entry( + InviteCodeCommandId.ADMIN_REWARD_MARK_DELIVERED, + "admin reward mark-delivered ", "mark-delivered", + "invitecode.admin.reward", false, + ), + entry( + InviteCodeCommandId.ADMIN_CODE_ROTATE, + "admin code rotate ", "rotate-code", "invitecode.admin.code", false, + ), + entry( + InviteCodeCommandId.ADMIN_STORAGE_MIGRATE, + "admin storage migrate ", "migrate-storage", "invitecode.admin.storage", false, + ), + entry(InviteCodeCommandId.ADMIN_RELOAD, "reload", "reload", "invitecode.admin.reload", false), + entry(InviteCodeCommandId.ADMIN_DOCTOR, "admin doctor", "doctor", "invitecode.admin.doctor", false), + ) + + private fun entry( + id: InviteCodeCommandId, + usage: String, + description: String, + permission: String, + playerOnly: Boolean, + ) = CommandHelpEntry(id, usage, "runtime.help-description.$description", permission, playerOnly) +} diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigation.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigation.kt new file mode 100644 index 0000000..a9659a3 --- /dev/null +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigation.kt @@ -0,0 +1,121 @@ +package io.github.command1264.invitecode.platform.bukkit + +import java.util.Locale + +data class HelpQuery(val home: Boolean, val path: List, val page: Int = 1) +data class HelpRow(val usage: String, val descriptionKey: String, val target: String, val navigation: Boolean) +data class HelpPage( + val query: HelpQuery, + val rows: List = emptyList(), + val detail: CommandHelpEntry? = null, + val pages: Int = 1, + val previous: String? = null, + val next: String? = null, + val back: String? = null, + val error: Boolean = false, +) + +/** Permission-filtered help tree shared by parsing, rendering and completion. */ +object CommandHelpNavigation { + const val PAGE_SIZE = 5 + private val homeIds = listOf(InviteCodeCommandId.CODE, InviteCodeCommandId.CLAIM, + InviteCodeCommandId.STATUS, InviteCodeCommandId.STATS, InviteCodeCommandId.HELP) + + fun path(entry: CommandHelpEntry): List = + if (entry.id == InviteCodeCommandId.ADMIN_RELOAD) listOf("admin", "reload") + else entry.usage.split(' ').takeWhile { !it.startsWith('<') && !it.startsWith('[') } + + fun query(arguments: List): HelpQuery? { + if (arguments.isEmpty()) return HelpQuery(true, emptyList()) + if (!arguments.first().equals("help", true) || arguments.any { it.isBlank() }) return null + val tail = arguments.drop(1).map { it.lowercase(Locale.ROOT) } + val hasPage = tail.lastOrNull()?.toIntOrNull() != null + val page = if (hasPage) tail.last().toIntOrNull() ?: return null else 1 + if (page < 1) return null + val topic = if (hasPage) tail.dropLast(1) else tail + if (!known(topic) || (hasPage && leaf(topic) != null)) return null + return HelpQuery(false, topic, page) + } + + private fun known(topic: List): Boolean = topic.isEmpty() || topic == listOf("admin") || + CommandHelp.entries.any { path(it).take(topic.size) == topic } + + private fun leaf(topic: List) = CommandHelp.entries.firstOrNull { path(it) == topic } + + private fun visible(player: Boolean, permission: (String) -> Boolean) = CommandHelp.entries.filter { + permission("invitecode.command.basic") && (!it.playerOnly || player) && permission(it.permission) + } + + fun resolve(query: HelpQuery, label: String, player: Boolean, permission: (String) -> Boolean): HelpPage { + val allowed = visible(player, permission) + fun usage(entry: CommandHelpEntry) = "/$label ${path(entry).let { + if (entry.id == InviteCodeCommandId.ADMIN_RELOAD) listOf("reload") else it + }.joinToString(" ")}" + fun detailRow(entry: CommandHelpEntry, navigate: Boolean) = HelpRow(usage(entry), entry.descriptionKey, + if (navigate) command(label, path(entry)) else usage(entry), navigate) + val admins = allowed.filter { !it.playerOnly && it.id != InviteCodeCommandId.HELP } + if (query.home) { + val rows = homeIds.mapNotNull { id -> allowed.firstOrNull { it.id == id } }.map { entry -> detailRow(entry, false).copy(navigation = entry.id == InviteCodeCommandId.HELP) } + val adminLink = if (admins.isEmpty() || !player) emptyList() else listOf( + HelpRow("/$label help admin", "runtime.help-topic.admin", command(label, listOf("admin")), true)) + return HelpPage(query, rows + adminLink) + } + val detail = leaf(query.path) + if (detail != null) return if (detail in allowed) { + HelpPage(query, detail = detail, back = parentLink(query.path, label, player, permission)) + } else HelpPage(query, error = true) + val candidates = when { + query.path.isEmpty() && player -> homeIds.mapNotNull { id -> allowed.firstOrNull { it.id == id } } + .map { detailRow(it, true) } + query.path.isEmpty() || query.path == listOf("admin") -> admins.map { path(it)[1] }.distinct().map { topic -> + HelpRow("/$label help admin $topic", "runtime.help-topic-description.$topic", + command(label, listOf("admin", topic)), true) + } + else -> allowed.filter { path(it).size > query.path.size && path(it).take(query.path.size) == query.path } + .map { detailRow(it, true) } + } + val pages = maxOf(1, (candidates.size + PAGE_SIZE - 1) / PAGE_SIZE) + if (candidates.isEmpty() || query.page > pages) return HelpPage(query, error = true) + val rows = candidates.drop((query.page - 1) * PAGE_SIZE).take(PAGE_SIZE) + return HelpPage(query, rows, pages = pages, + previous = if (query.page > 1) command(label, query.path, query.page - 1) else null, + next = if (query.page < pages) command(label, query.path, query.page + 1) else null, + back = if (query.path.isEmpty()) "/$label" else parentLink(query.path, label, player, permission)) + } + + private fun parentLink(topic: List, label: String, player: Boolean, permission: (String) -> Boolean): String { + if (topic == listOf("admin")) return "/$label" + val parent = topic.dropLast(1) + val first = resolve(HelpQuery(false, parent), label, player, permission) + val target = command(label, topic) + val number = (1..first.pages).firstOrNull { page -> + val content = if (page == 1) first else resolve(HelpQuery(false, parent, page), label, player, permission) + content.rows.any { it.target == target } + } ?: 1 + return command(label, parent, number.takeIf { it > 1 }) + } + + fun complete(arguments: List, player: Boolean, permission: (String) -> Boolean): List { + if (arguments.isEmpty() || !permission("invitecode.command.basic")) return emptyList() + val topic = arguments.drop(1).map { it.lowercase(Locale.ROOT) } + if (topic.any { it.toIntOrNull() != null } || leaf(topic) != null) return emptyList() + val allowed = visible(player, permission) + val candidates = allowed.map(::path).filter { it.size > topic.size && it.take(topic.size) == topic } + .map { it[topic.size] }.distinct().toMutableList() + if (topic.isEmpty() && allowed.any { path(it).first() == "admin" } && "admin" !in candidates) candidates.add("admin") + val page = resolve(HelpQuery(false, topic), "ic", player, permission) + if (!page.error && page.pages > 1) candidates.addAll((1..page.pages).map(Int::toString)) + return candidates + } + + fun command(label: String, topic: List, page: Int? = null): String = + (listOf("/$label", "help") + topic + listOfNotNull(page?.toString())).joinToString(" ") + + fun detailKey(entry: CommandHelpEntry) = entry.descriptionKey.replace("help-description", "help-detail") + + fun example(entry: CommandHelpEntry, label: String): String = "/$label " + entry.usage + .replace("[code]", "A1B2C3").replace("", "Alex") + .replace("", "EXAMPLE_INVITATION_UUID").replace("", "EXAMPLE_ACTION_UUID") + .replace("", "new-player").replace("", "SQLITE") + .replace("", "manual-review") +} diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayout.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayout.kt new file mode 100644 index 0000000..c9d8594 --- /dev/null +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayout.kt @@ -0,0 +1,38 @@ +package io.github.command1264.invitecode.platform.bukkit + +import kotlin.math.roundToInt + +/** Approximate default-font alignment; resource packs and client font settings can differ. */ +object HelpFrameLayout { + fun align(header: PresentedMessage, divider: PresentedMessage, audience: MessageAudience = MessageAudience.RGB_PLAYER): Pair { + val console = audience == MessageAudience.CONSOLE + val top = width(header, console) + val bottom = width(divider, console) + val target = maxOf(top, bottom) + return extend(header, target - top, console) to extend(divider, target - bottom, console) + } + + private fun extend(message: PresentedMessage, missing: Int, console: Boolean): PresentedMessage { + val tail = message.segments.lastOrNull() + val strokeWidth = if (console) 1.0 else if (tail != null && MessageDecoration.BOLD in tail.decorations) 9.0 else 8.0 + val count = (missing / strokeWidth).roundToInt().coerceIn(0, 256) + if (count == 0) return message + return PresentedMessage(message.segments + MessageSegment("─".repeat(count), tail?.color, + tail?.decorations ?: emptySet())) + } + + private fun width(message: PresentedMessage, console: Boolean): Int = message.segments.sumOf { segment -> + segment.text.codePoints().toArray().sumOf { point -> + val size = when { + console -> if (point >= 0x2E80) 2 else 1 + point == 32 -> 4 + point < 128 && point.toChar() in "!.,:;|'i" -> 2 + point < 128 && point.toChar() in "[]It" -> 4 + point < 128 && point.toChar() in "fl{}" -> 5 + point == 0x2500 || point >= 0x2E80 -> 8 + else -> 6 + } + size + if (!console && point != 32 && MessageDecoration.BOLD in segment.decorations) 1 else 0 + } + } +} diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParser.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParser.kt index 2ddd090..2cec39c 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParser.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParser.kt @@ -42,12 +42,14 @@ object InviteCodeCommandParser { fun parse(rawArguments: List): InviteCodeCommandParseResult { if (rawArguments.any { it.isBlank() }) return invalid() val arguments = rawArguments.map { it.lowercase(Locale.ROOT) } - if (arguments.isEmpty() || arguments == listOf("help")) { + if (arguments.isEmpty() || arguments.firstOrNull() == "help") { + if (CommandHelpNavigation.query(rawArguments) == null) return invalid() return command( InviteCodeCommandId.HELP, "invitecode.command.basic", playerOnly = false, maintenance = true, + operands = rawArguments, ) } return when (arguments.first()) { diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletion.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletion.kt index f7d2e43..5e80b0e 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletion.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletion.kt @@ -8,11 +8,16 @@ object InviteCodeTabCompletion { player: Boolean, hasPermission: (String) -> Boolean, onlinePlayerNames: Collection, + qualificationProfileIds: Collection = emptyList(), ): List { - if (arguments.isEmpty()) return emptyList() + if (arguments.isEmpty() || !hasPermission("invitecode.command.basic")) return emptyList() val path = arguments.dropLast(1).map { it.lowercase(Locale.ROOT) } val prefix = arguments.last() - val candidates = if ( + val candidates = if (path.firstOrNull() == "help") { + CommandHelpNavigation.complete(path, player, hasPermission) + } else if (path.size == 4 && path.take(3) == listOf("admin", "invitation", "force-qualify")) { + permitted(hasPermission, "invitecode.admin.qualification", qualificationProfileIds) + } else if ( path.size == 4 && path.take(3) == listOf("admin", "invitation", "transfer") ) { permitted(hasPermission, "invitecode.admin.invitation", onlinePlayerNames) diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessages.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessages.kt index 3371969..60ee644 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessages.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessages.kt @@ -1,14 +1,18 @@ package io.github.command1264.invitecode.platform.bukkit import java.util.Locale +import java.util.concurrent.ConcurrentHashMap class LocalizedMessages( private val defaultLocale: String, private val useClientLocale: Boolean, catalogs: Map>, private val onMissingKey: (String) -> Unit = {}, + bundledCatalogs: Map> = emptyMap(), ) { - private val catalogs = catalogs.mapKeys { normalizeLocale(it.key) } + private val catalogs = catalogs.mapKeys { normalizeLocale(it.key) }.mapValues { it.value.toMap() } + private val bundledCatalogs = bundledCatalogs.mapKeys { normalizeLocale(it.key) }.mapValues { it.value.toMap() } + private val reportedFallbacks = ConcurrentHashMap.newKeySet() init { require(this.catalogs.containsKey(normalizeLocale(defaultLocale))) { @@ -25,14 +29,23 @@ class LocalizedMessages( } preferred?.get(key)?.let { return it } catalogs.getValue(normalizeLocale(defaultLocale))[key]?.let { return it } + val fallbackLocale = if (useClientLocale && clientLocale != null) normalizeLocale(clientLocale) else null + val fallback = fallbackLocale?.let { bundledCatalogs[it]?.get(key) } + ?: bundledCatalogs[normalizeLocale(defaultLocale)]?.get(key) + if (fallback != null) { + // Catalogs are immutable snapshots; report once per lookup locale and key. + if (reportedFallbacks.add("$fallbackLocale:$key")) onMissingKey(key) + return fallback + } onMissingKey(key) return "[missing: $key]" } fun resolve(clientLocale: String?, key: String, variables: Map): String { require(variables.keys.all(VARIABLE_NAME::matches)) { "Message variable names must use lowercase snake_case." } - return variables.entries.fold(resolve(clientLocale, key)) { message, (name, value) -> - message.replace("{$name}", value) + // Match only the template: a replacement may itself contain another placeholder. + return PLACEHOLDER.replace(resolve(clientLocale, key)) { match -> + variables[match.groupValues[1]] ?: match.value } } @@ -44,5 +57,6 @@ class LocalizedMessages( private companion object { val VARIABLE_NAME = Regex("[a-z][a-z0-9_]*") + val PLACEHOLDER = Regex("\\{([a-z][a-z0-9_]*)}") } } diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentation.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentation.kt new file mode 100644 index 0000000..872aa16 --- /dev/null +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentation.kt @@ -0,0 +1,123 @@ +package io.github.command1264.invitecode.platform.bukkit + +import io.github.command1264.invitecode.core.LegacyInviteCodeColor +import io.github.command1264.invitecode.core.InviteCodeColor +import kotlin.math.pow + +enum class MessageAudience { LEGACY_PLAYER, RGB_PLAYER, CONSOLE, PLAIN } +enum class PrefixPlacement { INLINE, OWN_LINE, NONE } +enum class MessageDecoration { BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, OBFUSCATED } + +data class MessageSegment( + val text: String, + val color: Int? = null, + val decorations: Set = emptySet(), + val variable: String? = null, +) + +data class PresentedMessage(val segments: List) { + val plainText: String get() = segments.joinToString("") { it.text } +} + +/** Presentation boundary. Callers keep click payloads separate from displayed text. */ +class MessagePresenter(private val messages: LocalizedMessages) { + fun render( + locale: String?, + key: String, + variables: Map = emptyMap(), + audience: MessageAudience = MessageAudience.LEGACY_PLAYER, + prefix: PrefixPlacement = PrefixPlacement.INLINE, + ): PresentedMessage { + val body = parse(messages.resolve(locale, key), variables) + val heading = if (prefix == PrefixPlacement.NONE) emptyList() else { + parse(messages.resolve(locale, "presentation.prefix"), emptyMap()) + } + val segments = if (heading.isEmpty()) body else { + heading + MessageSegment(if (prefix == PrefixPlacement.INLINE) " " else "\n") + body + } + return PresentedMessage(segments.map { segment -> + when (audience) { + MessageAudience.RGB_PLAYER -> segment + MessageAudience.LEGACY_PLAYER -> segment.copy(color = segment.color?.let { + InviteCodeColor.fromRgb(it).nearestLegacyColor().color.rgb + }) + MessageAudience.CONSOLE -> segment.copy( + color = segment.color?.let(::consoleColor), decorations = emptySet(), + ) + MessageAudience.PLAIN -> segment.copy(color = null, decorations = emptySet()) + } + }) + } + + private fun parse(template: String, variables: Map): List { + require(variables.keys.all { it.matches(Regex("[a-z][a-z0-9_]*")) }) { + "Message variable names must use lowercase snake_case." + } + val result = mutableListOf() + var color: Int? = null + var decorations = emptySet() + var offset = 0 + fun append(text: String, variable: String? = null) { + if (text.isNotEmpty()) result.add(MessageSegment(text, color, decorations, variable)) + } + TOKEN.findAll(template).forEach { match -> + append(template.substring(offset, match.range.first)) + val hex = match.groupValues[1] + val code = match.groupValues[2].firstOrNull()?.lowercaseChar() + when { + hex.isNotEmpty() -> { + color = hex.toInt(16) + decorations = emptySet() + } + code == 'r' -> { + color = null + decorations = emptySet() + } + code in DECORATIONS -> decorations = decorations + DECORATIONS.getValue(requireNotNull(code)) + code != null -> { + color = LegacyInviteCodeColor.entries.first { it.code == code }.color.rgb + decorations = emptySet() + } + else -> append(variables[match.groupValues[3]] ?: match.value, match.groupValues[3]) + } + offset = match.range.last + 1 + } + append(template.substring(offset)) + return result.toList() + } + + private fun consoleColor(rgb: Int): Int { + val nearest = InviteCodeColor.fromRgb(rgb).nearestLegacyColor() + if (nearest in CONSOLE_COLORS) return nearest.color.rgb + // Avoid turning near-black neutral text into a dark/colored invisible label. + if (nearest == LegacyInviteCodeColor.BLACK || nearest == LegacyInviteCodeColor.DARK_GRAY) { + return LegacyInviteCodeColor.GRAY.color.rgb + } + val desired = InviteCodeColor.fromRgb(rgb) + return CONSOLE_COLORS.minByOrNull { legacy -> + val red = desired.red - legacy.color.red + val green = desired.green - legacy.color.green + val blue = desired.blue - legacy.color.blue + red * red + green * green + blue * blue + }!!.color.rgb + } + + private companion object { + val TOKEN = Regex("&#([0-9a-fA-F]{6})|[&§]([0-9a-fk-orA-FK-OR])|\\{([a-z][a-z0-9_]*)}") + val DECORATIONS = mapOf( + 'k' to MessageDecoration.OBFUSCATED, 'l' to MessageDecoration.BOLD, + 'm' to MessageDecoration.STRIKETHROUGH, 'n' to MessageDecoration.UNDERLINE, + 'o' to MessageDecoration.ITALIC, + ) + // Minimum 4.5:1 contrast against standard black, not a claim about custom terminal themes. + val CONSOLE_COLORS = LegacyInviteCodeColor.entries.filter { legacy -> + fun linear(channel: Int): Double { + val value = channel / 255.0 + return if (value <= 0.04045) value / 12.92 else ((value + 0.055) / 1.055).pow(2.4) + } + val color = legacy.color + val luminance = 0.2126 * linear(color.red) + 0.7152 * linear(color.green) + 0.0722 * linear(color.blue) + (luminance + 0.05) / 0.05 >= 4.5 + } + } +} diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt index 4c35dc6..79d4ef2 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NativeDialogInput.kt @@ -3,15 +3,16 @@ package io.github.command1264.invitecode.platform.bukkit import org.bukkit.entity.Player import java.util.UUID -data class NativeDialogRequest( +data class NativeDialogRequest @JvmOverloads constructor( val title: String, val label: String, val confirm: String, val cancel: String, val maximumLength: Int, + val presentation: NativeDialogPresentation? = null, ) -data class NativeDialogConfirmationRequest( +data class NativeDialogConfirmationRequest @JvmOverloads constructor( val title: String, val inviterLine: String, val codeLabel: String, @@ -23,6 +24,17 @@ data class NativeDialogConfirmationRequest( val disagree: String, val agreeHint: String, val disagreeHint: String, + val presentation: NativeDialogPresentation? = null, +) + +data class NativeDialogPresentation( + val title: PresentedMessage, + val body: List, + val confirm: PresentedMessage, + val cancel: PresentedMessage, + val inputLabel: PresentedMessage? = null, + val confirmHint: PresentedMessage? = null, + val cancelHint: PresentedMessage? = null, ) interface NativeDialogInput : AutoCloseable { diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NetworkAddressHasher.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NetworkAddressHasher.kt index 68f6922..8b60b12 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NetworkAddressHasher.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/NetworkAddressHasher.kt @@ -80,7 +80,7 @@ class NetworkAddressHasher private constructor( fun loadExisting(path: Path): NetworkAddressHasher { require(Files.isRegularFile(path)) { - "Network hash secret ${path.toAbsolutePath()} is missing; run the explicit storage migration." + "Network hash secret ${path.toAbsolutePath()} is missing\nrun the explicit storage migration." } val bytes = Files.readAllBytes(path) require(bytes.size == SECRET_SIZE) { diff --git a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssembler.kt b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssembler.kt index fcee404..7d204f3 100644 --- a/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssembler.kt +++ b/invitecode-platform-bukkit/src/main/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssembler.kt @@ -43,6 +43,7 @@ object RuntimeConfigurationAssembler { rewards: Map, messageCatalogs: Map>, onMissingMessage: (String) -> Unit = {}, + bundledMessageCatalogs: Map> = emptyMap(), ): InviteCodeRuntimeConfiguration { val parsedGeneral = BukkitPluginConfigurationParser.parse(general) val parsedStorage = StorageConfigurationParser.parse(storage) @@ -52,6 +53,9 @@ object RuntimeConfigurationAssembler { val parsedCatalogs = messageCatalogs.mapValues { (locale, document) -> MessageCatalogParser.parse(locale, document) } + val parsedBundledCatalogs = bundledMessageCatalogs.mapValues { (locale, document) -> + MessageCatalogParser.parse(locale, document) + } val defaultCatalog = parsedCatalogs[parsedGeneral.language.defaultLocale] ?: throw IllegalArgumentException( "Default locale ${parsedGeneral.language.defaultLocale} does not have a message catalog.", @@ -65,7 +69,8 @@ object RuntimeConfigurationAssembler { addAll(reward.inviterActions.filter { it.type == RewardActionType.MESSAGE }.map { it.payload }) } }.toSet() - val missingRewardMessages = rewardMessageKeys - defaultCatalog.keys + val missingRewardMessages = rewardMessageKeys - defaultCatalog.keys - + parsedBundledCatalogs[parsedGeneral.language.defaultLocale].orEmpty().keys require(missingRewardMessages.isEmpty()) { "Default locale is missing Reward message keys: ${missingRewardMessages.sorted().joinToString()}." } @@ -79,6 +84,7 @@ object RuntimeConfigurationAssembler { parsedGeneral.language.useClientLocale, parsedCatalogs, onMissingMessage, + bundledCatalogs = parsedBundledCatalogs, ), availableLocales = parsedCatalogs.keys, ) @@ -93,7 +99,7 @@ object MessageCatalogParser { val version = (document["messages-version"] as? Number)?.toString()?.toIntOrNull() ?: throw IllegalArgumentException("Message catalog $locale requires integer messages-version.") require(version == CURRENT_VERSION) { - "Message catalog $locale version $version is unsupported; expected $CURRENT_VERSION." + "Message catalog $locale version $version is unsupported\nexpected $CURRENT_VERSION." } require(document.keys.any { it != "messages-version" }) { "Message catalog $locale must contain at least one message." @@ -114,7 +120,14 @@ object MessageCatalogParser { require(key.isNotBlank()) { "Message catalog $locale contains a blank key." } when (value) { is String -> { - require(value.isNotBlank()) { "Message catalog $locale key $key must not be blank." } + if (key == "presentation.prefix") { + require(value == value.trim() && '\n' !in value && '\r' !in value && + !Regex("\\{[a-z][a-z0-9_]*}").containsMatchIn(value)) { + "Message catalog $locale prefix must be one unpadded line without variables." + } + } else { + require(value.isNotBlank()) { "Message catalog $locale key $key must not be blank." } + } destination[key] = value } is Map<*, *> -> { diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt index 14aed87..351ac0f 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/ClaimInteractionSessionsTest.kt @@ -13,6 +13,39 @@ import java.time.Instant import java.util.UUID class ClaimInteractionSessionsTest { + @Test + fun `dialog submission distinguishes expiration from an absent session atomically`() { + var now = Instant.EPOCH + val id = UUID.randomUUID() + val sessions = ClaimInteractionSessions { now } + assertNull(sessions.consumeDialogInputResult(id, "secret")) + sessions.startDialogInput(id, Duration.ofSeconds(60)) + now = now.plusSeconds(60) + assertEquals(DialogInputResult.Expired, sessions.consumeDialogInputResult(id, "secret")) + assertNull(sessions.consumeDialogInputResult(id, "second")) + sessions.startDialogInput(id, Duration.ofSeconds(60)) + assertEquals(DialogInputResult.Code("A1B2C3"), sessions.consumeDialogInputResult(id, " A1B2C3 ")) + } + @Test + fun `all interaction types expire exactly at their deadline and only once`() { + var now = Instant.EPOCH + val sessions = ClaimInteractionSessions { now } + val id = UUID.randomUUID() + val timeout = Duration.ofSeconds(60) + sessions.startDialogInput(id, timeout) + now = now.plus(timeout) + assertTrue(sessions.expireDialogInput(id)) + assertFalse(sessions.expireDialogInput(id)) + sessions.startChatInput(id, timeout) + now = now.plus(timeout) + assertTrue(sessions.expireChatInput(id)) + assertNull(sessions.consumeChatInput(id, "secret")) + sessions.startConfirmation(ClaimConfirmation.present(id, UUID.randomUUID(), "Inviter", + InviteCode.parse("A1B2C3"), now, timeout)) + now = now.plus(timeout) + assertTrue(sessions.expireConfirmation(id)) + assertNull(sessions.consumeConfirmation(id)) + } @Test fun `chat input does not consume an active confirmation`() { val now = Instant.parse("2026-01-01T00:00:00Z") diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigationTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigationTest.kt new file mode 100644 index 0000000..4b4d805 --- /dev/null +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpNavigationTest.kt @@ -0,0 +1,92 @@ +package io.github.command1264.invitecode.platform.bukkit + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + +class CommandHelpNavigationTest { + private val all: (String) -> Boolean = { true } + private fun page(vararg args: String, player: Boolean = true, permissions: (String) -> Boolean = all): HelpPage = + CommandHelpNavigation.resolve(requireNotNull(CommandHelpNavigation.query(args.toList())), "ic", player, permissions) + + @Test + fun `return locates category on its permission filtered parent page`() { + assertEquals("/ic", page("help", "admin").back) + listOf("storage", "reload", "doctor").forEach { topic -> + val child = page("help", "admin", topic) + assertEquals("/ic help admin 2", child.back, topic) + } + val onlyDoctor: (String) -> Boolean = { it in setOf("invitecode.command.basic", "invitecode.admin.doctor") } + assertEquals("/ic help admin", page("help", "admin", "doctor", permissions = onlyDoctor).back) + assertEquals("/ic help admin invitation", page("help", "admin", "invitation", "transfer").back) + // Every visible child returns to a page which actually contains it, including future categories. + for (number in 1..page("help", "admin").pages) { + val parent = page("help", "admin", number.toString()) + parent.rows.forEach { row -> + val child = CommandHelpNavigation.resolve(requireNotNull(CommandHelpNavigation.query( + row.target.removePrefix("/ic ").split(' '))), "ic", true, all) + val back = CommandHelpNavigation.resolve(requireNotNull(CommandHelpNavigation.query( + child.back!!.removePrefix("/ic ").split(' '))), "ic", true, all) + assertTrue(back.rows.any { it.target == row.target }) + } + } + } + + @Test + fun `homepage contains five common commands and a single admin entrance`() { + val home = page() + assertEquals(listOf("/ic code", "/ic claim", "/ic status", "/ic stats", "/ic help", "/ic help admin"), + home.rows.map { it.usage }) + assertEquals(4, home.rows.count { !it.navigation }) + assertTrue(home.rows.single { it.usage == "/ic help" }.navigation) + assertEquals("/ic help", home.rows.single { it.usage == "/ic help" }.target) + assertTrue(home.rows.none { it.usage.contains("confirm") || it.usage.contains("cancel") || it.usage.contains('<') }) + } + + @Test + fun `management index pages are bounded and point only to help routes`() { + val first = page("help", "admin") + val second = page("help", "admin", "2") + assertEquals(listOf("/ic help admin inspect", "/ic help admin invitation", "/ic help admin eligibility", + "/ic help admin reward", "/ic help admin code"), first.rows.map { it.usage }) + assertEquals(listOf("/ic help admin storage", "/ic help admin reload", "/ic help admin doctor"), second.rows.map { it.usage }) + assertEquals("/ic help admin 2", first.next) + assertNull(first.previous) + assertEquals("/ic help admin 1", second.previous) + assertNull(second.next) + assertTrue(page("help", "admin", "3").error) + assertTrue(first.rows.all { it.navigation && it.target.startsWith("/ic help ") }) + } + + @Test + fun `permission filtering applies to groups details pages and console audiences`() { + val qualificationOnly: (String) -> Boolean = { it in setOf("invitecode.command.basic", "invitecode.admin.qualification") } + assertEquals(listOf("/ic admin invitation force-qualify"), + page("help", "admin", "invitation", permissions = qualificationOnly).rows.map { it.usage }) + assertTrue(page("help", "admin", "invitation", "unlink", permissions = qualificationOnly).error) + assertTrue(page("help", "admin", "2", permissions = qualificationOnly).error) + assertTrue(page("help", "claim", player = false).error) + assertEquals(listOf("/ic help"), page(player = false).rows.map { it.usage }) + assertTrue(page("help", "admin", permissions = { it == "invitecode.command.basic" }).error) + } + + @Test + fun `every operational route has a reachable permission filtered detail without mutating operands`() { + CommandHelp.entries.forEach { entry -> + val result = page(*(listOf("help") + CommandHelpNavigation.path(entry)).toTypedArray()) + assertEquals(entry.id, result.detail?.id) + assertTrue(result.rows.isEmpty()) + assertTrue(result.back!!.startsWith("/ic help")) + } + assertEquals(InviteCodeCommandId.CONFIRM, page("help", "confirm").detail?.id) + assertEquals(InviteCodeCommandId.CANCEL, page("help", "cancel").detail?.id) + assertEquals(listOf("/ic code", "/ic claim", "/ic status", "/ic stats", "/ic help"), page("help").rows.map { it.usage }) + } + + @Test + fun `unknown pages excess arguments and action parameters are not help topics`() { + listOf(listOf("help", "0"), listOf("help", "-1"), listOf("help", "9999999999999"), + listOf("help", "invitation"), listOf("help", "claim", "A1B2C3"), + listOf("help", "admin", "invitation", "transfer", "UUID"), listOf("help", "claim", "1")) + .forEach { assertNull(CommandHelpNavigation.query(it), it.toString()) } + } +} diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpTest.kt new file mode 100644 index 0000000..ea997b2 --- /dev/null +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/CommandHelpTest.kt @@ -0,0 +1,82 @@ +package io.github.command1264.invitecode.platform.bukkit + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertInstanceOf +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test + +class CommandHelpTest { + @Test + fun `help contains exactly one entry for every parser route with matching metadata`() { + assertEquals(20, CommandHelp.entries.size) + assertEquals(InviteCodeCommandId.entries.toSet(), CommandHelp.entries.map { it.id }.toSet()) + assertEquals(CommandHelp.entries.size, CommandHelp.entries.map { it.id }.toSet().size) + + CommandHelp.entries.forEach { entry -> + val arguments = argumentsById.getValue(entry.id) + val parsed = assertInstanceOf( + ParsedInviteCodeCommand::class.java, + InviteCodeCommandParser.parse(arguments), + "${entry.id}: $arguments", + ) + assertEquals(entry.id, parsed.id, entry.usage) + assertEquals(entry.permission, parsed.permission, entry.usage) + assertEquals(entry.playerOnly, parsed.playerOnly, entry.usage) + assertTrue(entry.descriptionKey.startsWith("runtime.help-description.")) + assertTrue(entry.usage.isNotBlank()) + } + } + + @Test + fun `help and reload compatibility routes resolve to their canonical entries`() { + val help = CommandHelp.entries.single { it.id == InviteCodeCommandId.HELP } + val root = assertInstanceOf(ParsedInviteCodeCommand::class.java, InviteCodeCommandParser.parse(emptyList())) + val explicit = assertInstanceOf(ParsedInviteCodeCommand::class.java, InviteCodeCommandParser.parse(listOf("help"))) + assertEquals(help.id, root.id) + assertEquals(help.id, explicit.id) + assertFalse(root.playerOnly) + assertFalse(explicit.playerOnly) + + val reload = CommandHelp.entries.single { it.id == InviteCodeCommandId.ADMIN_RELOAD } + listOf(listOf("reload"), listOf("admin", "reload")).forEach { arguments -> + val parsed = assertInstanceOf( + ParsedInviteCodeCommand::class.java, + InviteCodeCommandParser.parse(arguments), + ) + assertEquals(reload.id, parsed.id) + assertEquals(reload.permission, parsed.permission) + assertFalse(parsed.playerOnly) + } + } + + private companion object { + const val UUID = "00000000-0000-0000-0000-000000000001" + val argumentsById = mapOf( + InviteCodeCommandId.HELP to listOf("help"), + InviteCodeCommandId.CODE to listOf("code"), + InviteCodeCommandId.CLAIM to listOf("claim", "CODE"), + InviteCodeCommandId.CONFIRM to listOf("confirm"), + InviteCodeCommandId.CANCEL to listOf("cancel"), + InviteCodeCommandId.STATUS to listOf("status"), + InviteCodeCommandId.STATS to listOf("stats"), + InviteCodeCommandId.ADMIN_INSPECT_PLAYER to listOf("admin", "inspect", "player", "Alex"), + InviteCodeCommandId.ADMIN_INSPECT_INVITATION to listOf("admin", "inspect", "invitation", UUID), + InviteCodeCommandId.ADMIN_INSPECT_REWARD to listOf("admin", "inspect", "reward", UUID), + InviteCodeCommandId.ADMIN_INVITATION_UNLINK to listOf("admin", "invitation", "unlink", UUID, "reason"), + InviteCodeCommandId.ADMIN_INVITATION_TRANSFER to + listOf("admin", "invitation", "transfer", UUID, "Alex", "reason"), + InviteCodeCommandId.ADMIN_INVITATION_FORCE_QUALIFY to + listOf("admin", "invitation", "force-qualify", UUID, "profile", "reason"), + InviteCodeCommandId.ADMIN_ELIGIBILITY_RESET to listOf("admin", "eligibility", "reset", "Alex", "reason"), + InviteCodeCommandId.ADMIN_REWARD_RETRY to listOf("admin", "reward", "retry", UUID, "reason"), + InviteCodeCommandId.ADMIN_REWARD_MARK_DELIVERED to + listOf("admin", "reward", "mark-delivered", UUID, "reason"), + InviteCodeCommandId.ADMIN_CODE_ROTATE to listOf("admin", "code", "rotate", "Alex", "reason"), + InviteCodeCommandId.ADMIN_STORAGE_MIGRATE to + listOf("admin", "storage", "migrate", "SQLITE", "reason"), + InviteCodeCommandId.ADMIN_RELOAD to listOf("reload"), + InviteCodeCommandId.ADMIN_DOCTOR to listOf("admin", "doctor"), + ) + } +} diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayoutTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayoutTest.kt new file mode 100644 index 0000000..e2fa21c --- /dev/null +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/HelpFrameLayoutTest.kt @@ -0,0 +1,40 @@ +package io.github.command1264.invitecode.platform.bukkit + +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + +class HelpFrameLayoutTest { + private fun text(value: String) = PresentedMessage(listOf(MessageSegment(value, 0x555555))) + + @Test + fun `console uses terminal cells instead of the player font estimate`() { + val title = text("── 中文 ──") + val (top, bottom) = HelpFrameLayout.align(title, text("─"), MessageAudience.CONSOLE) + assertEquals(title, top) + assertEquals(10, bottom.plainText.length) + } + + @Test + fun `short heading grows its rule while long translated heading grows the divider`() { + val divider = text("─".repeat(24)) + val short = text("──── [IC] Help ────") + val (top, bottom) = HelpFrameLayout.align(short, divider) + assertTrue(top.plainText.startsWith(short.plainText)) + assertTrue(top.plainText.length > short.plainText.length) + assertEquals(divider, bottom) + val long = text("──── [InviteCode] Administration configuration reload details 2/2 ────") + val (longTop, longBottom) = HelpFrameLayout.align(long, divider) + assertEquals(long, longTop) + assertTrue(longBottom.plainText.length > divider.plainText.length) + assertEquals(0x555555, longBottom.segments.last().color) + } + + @Test + fun `wide titles retain literal text and padding is bounded`() { + val title = text("──── [邀請碼] 管理員說明 ────") + val (top, bottom) = HelpFrameLayout.align(title, text("────")) + assertEquals(title, top) + assertTrue(bottom.plainText.length > 4) + assertTrue(HelpFrameLayout.align(text("x".repeat(10000)), text("─")).second.plainText.length <= 257) + } +} diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParserTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParserTest.kt index 706debb..cb630db 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParserTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeCommandParserTest.kt @@ -7,6 +7,19 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test class InviteCodeCommandParserTest { + @Test + fun `help navigation preserves topic and page without invoking a management route`() { + listOf(listOf("help", "admin"), listOf("help", "admin", "invitation"), + listOf("help", "admin", "invitation", "transfer"), listOf("help", "admin", "2"), + listOf("help", "confirm")).forEach { arguments -> + val parsed = assertInstanceOf(ParsedInviteCodeCommand::class.java, InviteCodeCommandParser.parse(arguments)) + assertEquals(InviteCodeCommandId.HELP, parsed.id) + assertEquals(arguments, parsed.operands) + assertEquals("invitecode.command.basic", parsed.permission) + assertTrue(parsed.allowedDuringMaintenance) + } + } + @Test fun `player command routes expose permissions and operands`() { val claim = assertInstanceOf( diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletionTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletionTest.kt index e1a0ef3..26b4a8a 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletionTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/InviteCodeTabCompletionTest.kt @@ -7,6 +7,19 @@ class InviteCodeTabCompletionTest { private val allowAll: (String) -> Boolean = { true } private val onlinePlayers = listOf("Alex", "Steve") + @Test + fun `help tabs traverse only permitted topics and real page numbers`() { + assertEquals(listOf("1", "2", "code", "doctor", "eligibility", "inspect", "invitation", "reload", "reward", "storage"), + complete(listOf("help", "admin", ""), player = true)) + assertEquals(listOf("force-qualify", "transfer", "unlink"), complete(listOf("help", "admin", "invitation", ""), true)) + assertEquals(emptyList(), complete(listOf("help", "admin", "invitation", "transfer", ""), true)) + assertEquals(emptyList(), complete(listOf("help", "admin", "2", ""), true)) + val basic: (String) -> Boolean = { it.startsWith("invitecode.command.") } + assertEquals(listOf("cancel", "claim", "code", "confirm", "help", "stats", "status"), + InviteCodeTabCompletion.complete(listOf("help", ""), true, basic, onlinePlayers)) + assertEquals(emptyList(), InviteCodeTabCompletion.complete(listOf("help", "admin", ""), true, basic, onlinePlayers)) + } + @Test fun `player and console receive only applicable root commands`() { assertEquals( @@ -46,7 +59,6 @@ class InviteCodeTabCompletionTest { listOf( listOf("status", ""), listOf("stats", "anything"), - listOf("help", ""), listOf("reload", ""), listOf("unknown", ""), listOf("admin", "doctor", ""), @@ -71,7 +83,7 @@ class InviteCodeTabCompletionTest { InviteCodeTabCompletion.complete(listOf("admin", ""), false, onlyHelp, onlinePlayers), ) - val onlyQualification: (String) -> Boolean = { it == "invitecode.admin.qualification" } + val onlyQualification: (String) -> Boolean = { it in setOf("invitecode.command.basic", "invitecode.admin.qualification") } assertEquals( listOf("force-qualify"), InviteCodeTabCompletion.complete( @@ -92,6 +104,23 @@ class InviteCodeTabCompletionTest { ) } + @Test + fun `qualification profile completion is permission gated and never fills IDs or free text`() { + val arguments = listOf("admin", "invitation", "force-qualify", "invitation-id", "ne") + val profiles = listOf("new-player", "veteran") + assertEquals(listOf("new-player"), InviteCodeTabCompletion.complete(arguments, false, allowAll, onlinePlayers, profiles)) + val denied: (String) -> Boolean = { it != "invitecode.admin.qualification" } + assertEquals(emptyList(), InviteCodeTabCompletion.complete(arguments, true, denied, onlinePlayers, profiles)) + assertEquals(emptyList(), complete(arguments.dropLast(1) + "" + "" + "", false)) + assertEquals(emptyList(), complete(listOf("admin", "invitation", "force-qualify", ""), false)) + assertEquals(emptyList(), InviteCodeTabCompletion.complete(listOf("help", "claim", ""), false, allowAll, onlinePlayers)) + val onlyQualification: (String) -> Boolean = { it in setOf("invitecode.command.basic", "invitecode.admin.qualification") } + assertEquals(listOf("force-qualify"), InviteCodeTabCompletion.complete( + listOf("help", "admin", "invitation", ""), false, onlyQualification, onlinePlayers)) + assertEquals(emptyList(), InviteCodeTabCompletion.complete(listOf("help", "admin", ""), + false, { it != "invitecode.command.basic" }, onlinePlayers)) + } + private fun complete(arguments: List, player: Boolean): List = InviteCodeTabCompletion.complete(arguments, player, allowAll, onlinePlayers) } diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessagesTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessagesTest.kt index 57d3c9f..e5a62b5 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessagesTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/LocalizedMessagesTest.kt @@ -4,6 +4,40 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test class LocalizedMessagesTest { + @Test + fun `bundled fallback preserves custom client and default priority and warns once`() { + val missing = mutableListOf() + val messages = LocalizedMessages("zh_TW", true, + catalogs = mapOf( + "zh_TW" to mapOf("default.only" to "自訂預設"), + "en_US" to mapOf("custom" to "Custom"), + ), + onMissingKey = missing::add, + bundledCatalogs = mapOf( + "zh_TW" to mapOf("new" to "內建", "last" to "最後備援"), + "en_US" to mapOf("new" to "Bundled", "default.only" to "Do not override custom default"), + ), + ) + + assertEquals("Custom", messages.resolve("en_US", "custom")) + assertEquals("自訂預設", messages.resolve("en_US", "default.only")) + assertEquals("Bundled", messages.resolve("en_US", "new")) + assertEquals("Bundled", messages.resolve("en_US", "new")) + assertEquals("最後備援", messages.resolve("en_US", "last")) + assertEquals(listOf("new", "last"), missing) + } + + @Test + fun `variable values are literal and never expanded as other placeholders`() { + val messages = LocalizedMessages("zh_TW", false, mapOf( + "zh_TW" to mapOf("result" to "Player {player}: {status}"), + )) + + assertEquals("Player {status} &a: ready", messages.resolve(null, "result", linkedMapOf( + "player" to "{status} &a", "status" to "ready", + ))) + } + @Test fun `replaces named variables after locale fallback`() { val messages = LocalizedMessages( diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentationTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentationTest.kt new file mode 100644 index 0000000..b4597e6 --- /dev/null +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/MessagePresentationTest.kt @@ -0,0 +1,82 @@ +package io.github.command1264.invitecode.platform.bukkit + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test + +class MessagePresentationTest { + @Test + fun `prefix styling cannot leak into body and unknown syntax stays literal`() { + val result = presenter("Ready &g Z456", "&6&l[InviteCode]").render( + null, "message", audience = MessageAudience.RGB_PLAYER, + ) + assertEquals("[InviteCode] Ready &g Z456", result.plainText) + assertEquals(setOf(MessageDecoration.BOLD), result.segments.first().decorations) + assertEquals(null, result.segments.last().color) + assertEquals(emptySet(), result.segments.last().decorations) + } + + @Test + fun `empty or style only prefix produces no separator or blank line`() { + for (prefix in listOf("", "&7&r")) { + val presenter = presenter("Ready", prefix) + assertEquals("Ready", presenter.render(null, "message").plainText) + assertEquals("Ready", presenter.render(null, "message", prefix = PrefixPlacement.OWN_LINE).plainText) + } + } + + @Test + fun `dynamic values cannot inject colors decorations or more placeholders`() { + val result = presenter("&a{player} {status}").render( + null, "message", linkedMapOf("player" to "�&l{status}", "status" to "OK"), + audience = MessageAudience.RGB_PLAYER, prefix = PrefixPlacement.NONE, + ) + assertEquals("�&l{status} OK", result.plainText) + assertEquals(setOf(0x55FF55), result.segments.map { it.color }.toSet()) + assertEquals(emptySet(), result.segments.first().decorations) + } + + @Test + fun `hex colors follow player capability while reset ends decorations`() { + val presenter = presenter("𞉀&lHello&r end") + val rgb = presenter.render(null, "message", audience = MessageAudience.RGB_PLAYER, prefix = PrefixPlacement.NONE) + assertEquals("Hello end", rgb.plainText) + assertEquals(0x123456, rgb.segments.first().color) + assertEquals(setOf(MessageDecoration.BOLD), rgb.segments.first().decorations) + assertEquals(null, rgb.segments.last().color) + assertEquals(emptySet(), rgb.segments.last().decorations) + + val legacy = presenter.render(null, "message", prefix = PrefixPlacement.NONE) + assertEquals(0x555555, legacy.segments.first().color) + val plain = presenter.render(null, "message", audience = MessageAudience.PLAIN, prefix = PrefixPlacement.NONE) + assertEquals("Hello end", plain.plainText) + assertEquals(setOf(null), plain.segments.map { it.color }.toSet()) + } + + @Test + fun `console retains success warning error colors without bold or invisible black`() { + val presenter = presenter("&a&lSuccess &eWarning &cFailure �Dark") + val console = presenter.render(null, "message", audience = MessageAudience.CONSOLE, prefix = PrefixPlacement.NONE) + assertEquals("Success Warning Failure Dark", console.plainText) + assertEquals(listOf(0x55FF55, 0xFFFF55, 0xFF5555, 0xAAAAAA), console.segments.map { it.color }) + assertEquals(true, console.segments.all { it.decorations.isEmpty() }) + } + + @Test + fun `whole replies receive one prefix but value fragments do not`() { + val presenter = presenter("&fStatus\n&7Pending: {count}") + + assertEquals("[InviteCode] Status\nPending: 2", presenter.render(null, "message", mapOf("count" to "2")).plainText) + assertEquals("[InviteCode]\nStatus\nPending: 2", presenter.render( + null, "message", mapOf("count" to "2"), prefix = PrefixPlacement.OWN_LINE, + ).plainText) + assertEquals("Status\nPending: 2", presenter.render( + null, "message", mapOf("count" to "2"), prefix = PrefixPlacement.NONE, + ).plainText) + } + + private fun presenter(template: String, prefix: String = "&7[&6InviteCode&7]&r") = MessagePresenter( + LocalizedMessages("zh_TW", false, mapOf("zh_TW" to mapOf( + "presentation.prefix" to prefix, "message" to template, + ))), + ) +} diff --git a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssemblerTest.kt b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssemblerTest.kt index 6c18218..45f5389 100644 --- a/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssemblerTest.kt +++ b/invitecode-platform-bukkit/src/test/kotlin/io/github/command1264/invitecode/platform/bukkit/RuntimeConfigurationAssemblerTest.kt @@ -6,6 +6,20 @@ import org.junit.jupiter.api.Assertions.assertThrows import org.junit.jupiter.api.Test class RuntimeConfigurationAssemblerTest { + @Test + fun `only presentation prefix may be empty and must remain a single unpadded line`() { + val catalog = mapOf("messages-version" to 1, "presentation" to mapOf("prefix" to "")) + assertEquals("", MessageCatalogParser.parse("zh_TW", catalog)["presentation.prefix"]) + for (prefix in listOf("[InviteCode] ", "[InviteCode]\n", " ")) { + assertThrows(IllegalArgumentException::class.java) { + MessageCatalogParser.parse("zh_TW", mapOf("messages-version" to 1, "presentation" to mapOf("prefix" to prefix))) + } + } + assertThrows(IllegalArgumentException::class.java) { + MessageCatalogParser.parse("zh_TW", mapOf("messages-version" to 1, "message" to "")) + } + } + @Test fun `parses all configuration documents into one snapshot`() { val configuration = RuntimeConfigurationAssembler.parse( diff --git a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/PresentedMessageComponents.kt b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/PresentedMessageComponents.kt new file mode 100644 index 0000000..e76c3cb --- /dev/null +++ b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/PresentedMessageComponents.kt @@ -0,0 +1,24 @@ +package io.github.command1264.invitecode.platform.modern + +import io.github.command1264.invitecode.platform.bukkit.MessageDecoration +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage + +private val componentControlCodes = Regex("[\\u0000-\\u0008\\u000B-\\u001F\\u007F]") + +/** Builds styled native text components from already parsed presentation segments. */ +internal fun buildStyledComponent( + message: PresentedMessage, + text: (String) -> T, + color: (T, Int) -> T, + decorate: (T, MessageDecoration) -> T, + append: (T, T) -> T, +): T { + val root = text("") + return message.segments.fold(root) { result, segment -> + val safeText = segment.text.replace('§', '&').replace(componentControlCodes, "") + var component = text(safeText) + segment.color?.let { component = color(component, it) } + segment.decorations.forEach { decoration -> component = decorate(component, decoration) } + append(result, component) + } +} diff --git a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt index f4aecc6..7015345 100644 --- a/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt +++ b/invitecode-platform-modern/src/main/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInput.kt @@ -3,6 +3,8 @@ package io.github.command1264.invitecode.platform.modern import io.github.command1264.invitecode.platform.bukkit.NativeDialogInput import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest +import io.github.command1264.invitecode.platform.bukkit.MessageDecoration +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage import io.github.command1264.invitecode.platform.bukkit.UnavailableNativeDialogInput import org.bukkit.entity.Player import org.bukkit.event.Event @@ -175,6 +177,9 @@ private class PaperDialogBackend private constructor( private val componentText: Method, private val componentColoredText: Method, private val textColorRgb: Method, + private val componentColor: Method, + private val componentDecorate: Method, + private val decorationConstants: Map, private val componentAppend: Method, private val plainMessage: Method, private val keyFactory: Method, @@ -203,8 +208,9 @@ private class PaperDialogBackend private constructor( override val provider: String = "PAPER" override fun show(player: Player, request: NativeDialogRequest) { - val title = componentText.invoke(null, request.title) - val label = componentText.invoke(null, request.label) + val presentation = request.presentation + val title = presentation?.let { presented(it.title) } ?: componentText.invoke(null, request.title) + val label = presentation?.inputLabel?.let { presented(it) } ?: componentText.invoke(null, request.label) val inputBuilder = dialogInputText.invoke(null, INPUT_KEY, label) textWidth.invoke(inputBuilder, 300) textMaximumLength.invoke(inputBuilder, request.maximumLength) @@ -212,12 +218,15 @@ private class PaperDialogBackend private constructor( val baseBuilder = dialogBaseBuilder.invoke(null, title) baseInputs.invoke(baseBuilder, Collections.singletonList(input)) + presentation?.body?.takeIf { it.isNotEmpty() }?.let { body -> + baseBody.invoke(baseBuilder, body.map { plainMessage.invoke(null, presented(it)) }) + } baseCanClose.invoke(baseBuilder, true) val base = baseBuild.invoke(baseBuilder) val type = confirmationType.invoke( null, - button(request.confirm, SUBMIT_ACTION), - button(request.cancel, CANCEL_ACTION), + button(presentation?.let { presented(it.confirm) } ?: componentText.invoke(null, request.confirm), SUBMIT_ACTION), + button(presentation?.let { presented(it.cancel) } ?: componentText.invoke(null, request.cancel), CANCEL_ACTION), ) val dialog = dialogCreate.invoke(null, Consumer { factory -> val builder = registryFactoryEmpty.invoke(factory) @@ -228,23 +237,39 @@ private class PaperDialogBackend private constructor( } override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { - val baseBuilder = dialogBaseBuilder.invoke(null, componentText.invoke(null, request.title)) - val codeText = request.codeRgb?.let { rgb -> - componentColoredText.invoke(null, request.code, textColorRgb.invoke(null, rgb)) - } ?: componentText.invoke(null, request.code) - val codeLine = componentAppend.invoke(componentText.invoke(null, request.codeLabel), codeText) - baseBody.invoke(baseBuilder, listOf( - plainMessage.invoke(null, componentText.invoke(null, request.inviterLine)), - plainMessage.invoke(null, codeLine), - plainMessage.invoke(null, componentText.invoke(null, request.question)), - plainMessage.invoke(null, componentText.invoke(null, request.timeoutPrompt)), - )) + val presentation = request.presentation + val baseBuilder = dialogBaseBuilder.invoke( + null, + presentation?.let { presented(it.title) } ?: componentText.invoke(null, request.title), + ) + if (presentation != null) { + baseBody.invoke(baseBuilder, presentation.body.map { plainMessage.invoke(null, presented(it)) }) + } else { + val codeText = request.codeRgb?.let { rgb -> + componentColoredText.invoke(null, request.code, textColorRgb.invoke(null, rgb)) + } ?: componentText.invoke(null, request.code) + val codeLine = componentAppend.invoke(componentText.invoke(null, request.codeLabel), codeText) + baseBody.invoke(baseBuilder, listOf( + plainMessage.invoke(null, componentText.invoke(null, request.inviterLine)), + plainMessage.invoke(null, codeLine), + plainMessage.invoke(null, componentText.invoke(null, request.question)), + plainMessage.invoke(null, componentText.invoke(null, request.timeoutPrompt)), + )) + } baseCanClose.invoke(baseBuilder, true) val base = baseBuild.invoke(baseBuilder) val type = confirmationType.invoke( null, - button(request.agree, CONFIRM_ACTION, 0x55FF55, request.agreeHint), - button(request.disagree, DECLINE_ACTION, 0xFF5555, request.disagreeHint), + button( + presentation?.let { presented(it.confirm) } ?: componentColoredText.invoke(null, request.agree, textColorRgb.invoke(null, 0x55FF55)), + CONFIRM_ACTION, + if (presentation == null) componentText.invoke(null, request.agreeHint) else presentation.confirmHint?.let { presented(it) }, + ), + button( + presentation?.let { presented(it.cancel) } ?: componentColoredText.invoke(null, request.disagree, textColorRgb.invoke(null, 0xFF5555)), + DECLINE_ACTION, + if (presentation == null) componentText.invoke(null, request.disagreeHint) else presentation.cancelHint?.let { presented(it) }, + ), ) val dialog = dialogCreate.invoke(null, Consumer { factory -> val builder = registryFactoryEmpty.invoke(factory) @@ -258,17 +283,23 @@ private class PaperDialogBackend private constructor( closeDialog.invoke(player) } - private fun button(label: String, actionId: String, rgb: Int? = null, tooltip: String? = null): Any { - val component = rgb?.let { componentColoredText.invoke(null, label, textColorRgb.invoke(null, it)) } - ?: componentText.invoke(null, label) + private fun button(component: Any, actionId: String, tooltip: Any? = null): Any { val key = keyFactory.invoke(null, actionId) val action = customClick.invoke(null, key, null) val builder = actionButtonBuilder.invoke(null, component) buttonAction.invoke(builder, action) - if (tooltip != null) buttonTooltip.invoke(builder, componentText.invoke(null, tooltip)) + if (tooltip != null) buttonTooltip.invoke(builder, tooltip) return buttonBuild.invoke(builder) } + private fun presented(message: PresentedMessage): Any = buildStyledComponent( + message, + text = { componentText.invoke(null, it) }, + color = { component, rgb -> componentColor.invoke(component, textColorRgb.invoke(null, rgb)) }, + decorate = { component, decoration -> componentDecorate.invoke(component, decorationConstants.getValue(decoration)) }, + append = { left, right -> componentAppend.invoke(left, right) }, + ) + override fun readResponse(event: Event): DialogResponse? { val identifier = eventIdentifier.invoke(event).toString() if (identifier !in setOf(SUBMIT_ACTION, CANCEL_ACTION, CONFIRM_ACTION, DECLINE_ACTION)) return null @@ -287,6 +318,7 @@ private class PaperDialogBackend private constructor( val event = load("io.papermc.paper.event.player.PlayerCustomClickEvent").asSubclass(Event::class.java) val component = load("net.kyori.adventure.text.Component") val textColor = load("net.kyori.adventure.text.format.TextColor") + val textDecoration = load("net.kyori.adventure.text.format.TextDecoration") val dialogBody = load("io.papermc.paper.registry.data.dialog.body.DialogBody") val key = load("net.kyori.adventure.key.Key") val binaryTag = load("net.kyori.adventure.nbt.api.BinaryTagHolder") @@ -317,6 +349,9 @@ private class PaperDialogBackend private constructor( componentText = component.getMethod("text", String::class.java), componentColoredText = component.getMethod("text", String::class.java, textColor), textColorRgb = textColor.getMethod("color", Int::class.javaPrimitiveType!!), + componentColor = component.getMethod("color", textColor), + componentDecorate = component.getMethod("decorate", textDecoration), + decorationConstants = messageDecorationConstants(textDecoration), componentAppend = component.getMethod("append", component), plainMessage = dialogBody.getMethod("plainMessage", component), keyFactory = key.getMethod("key", String::class.java), @@ -365,6 +400,7 @@ private class SpigotDialogBackend private constructor( private val jsonAsString: Method, private val textComponentConstructor: Constructor<*>, private val setColor: Method, + private val setDecorations: Map, private val addExtra: Method, private val chatColorOf: Method, private val greenColor: Any, @@ -389,36 +425,60 @@ private class SpigotDialogBackend private constructor( override val provider: String = "SPIGOT" override fun show(player: Player, request: NativeDialogRequest) { - val input = textInputConstructor.newInstance(INPUT_KEY, text(request.label)) + val presentation = request.presentation + val inputLabel = presentation?.inputLabel?.let { presented(it) } ?: text(request.label) + val input = textInputConstructor.newInstance(INPUT_KEY, inputLabel) textWidth.invoke(input, 300) textMaximumLength.invoke(input, request.maximumLength) - val base = dialogBaseConstructor.newInstance(text(request.title)) + val base = dialogBaseConstructor.newInstance(presentation?.let { presented(it.title) } ?: text(request.title)) baseInputs.invoke(base, Collections.singletonList(input)) + presentation?.body?.takeIf { it.isNotEmpty() }?.let { body -> + baseBody.invoke(base, body.map { plainMessageConstructor.newInstance(presented(it)) }) + } baseCanClose.invoke(base, true) val dialog = confirmationConstructor.newInstance(base) - confirmationYes.invoke(dialog, button(request.confirm, SUBMIT_ACTION)) - confirmationNo.invoke(dialog, button(request.cancel, CANCEL_ACTION)) + confirmationYes.invoke(dialog, button(presentation?.let { presented(it.confirm) } ?: text(request.confirm), SUBMIT_ACTION)) + confirmationNo.invoke(dialog, button(presentation?.let { presented(it.cancel) } ?: text(request.cancel), CANCEL_ACTION)) showDialog.invoke(player, dialog) } override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { - val base = dialogBaseConstructor.newInstance(text(request.title)) - val codeLine = text(request.codeLabel) - val codeText = text(request.code) - request.codeRgb?.let { rgb -> - setColor.invoke(codeText, chatColorOf.invoke(null, "#%06X".format(rgb))) + val presentation = request.presentation + val base = dialogBaseConstructor.newInstance(presentation?.let { presented(it.title) } ?: text(request.title)) + if (presentation != null) { + baseBody.invoke(base, presentation.body.map { plainMessageConstructor.newInstance(presented(it)) }) + } else { + val codeLine = text(request.codeLabel) + val codeText = text(request.code) + request.codeRgb?.let { rgb -> + setColor.invoke(codeText, chatColorOf.invoke(null, "#%06X".format(rgb))) + } + addExtra.invoke(codeLine, codeText) + baseBody.invoke(base, listOf( + plainMessageConstructor.newInstance(text(request.inviterLine)), + plainMessageConstructor.newInstance(codeLine), + plainMessageConstructor.newInstance(text(request.question)), + plainMessageConstructor.newInstance(text(request.timeoutPrompt)), + )) } - addExtra.invoke(codeLine, codeText) - baseBody.invoke(base, listOf( - plainMessageConstructor.newInstance(text(request.inviterLine)), - plainMessageConstructor.newInstance(codeLine), - plainMessageConstructor.newInstance(text(request.question)), - plainMessageConstructor.newInstance(text(request.timeoutPrompt)), - )) baseCanClose.invoke(base, true) val dialog = confirmationConstructor.newInstance(base) - confirmationYes.invoke(dialog, button(request.agree, CONFIRM_ACTION, greenColor, request.agreeHint)) - confirmationNo.invoke(dialog, button(request.disagree, DECLINE_ACTION, redColor, request.disagreeHint)) + confirmationYes.invoke( + dialog, + button( + presentation?.let { presented(it.confirm) } ?: text(request.agree).also { setColor.invoke(it, greenColor) }, + CONFIRM_ACTION, + if (presentation == null) text(request.agreeHint) else presentation.confirmHint?.let { presented(it) }, + ), + ) + confirmationNo.invoke( + dialog, + button( + presentation?.let { presented(it.cancel) } ?: text(request.disagree).also { setColor.invoke(it, redColor) }, + DECLINE_ACTION, + if (presentation == null) text(request.disagreeHint) else presentation.cancelHint?.let { presented(it) }, + ), + ) showDialog.invoke(player, dialog) } @@ -428,14 +488,20 @@ private class SpigotDialogBackend private constructor( private fun text(value: String): Any = textComponentConstructor.newInstance(value) - private fun button(label: String, actionId: String, color: Any? = null, tooltip: String? = null): Any { - val component = text(label) - if (color != null) setColor.invoke(component, color) + private fun button(component: Any, actionId: String, tooltip: Any? = null): Any { val button = buttonConstructor.newInstance(component, actionConstructor.newInstance(actionId)) - if (tooltip != null) buttonTooltip.invoke(button, text(tooltip)) + if (tooltip != null) buttonTooltip.invoke(button, tooltip) return button } + private fun presented(message: PresentedMessage): Any = buildStyledComponent( + message, + text = ::text, + color = { component, rgb -> setColor.invoke(component, chatColorOf.invoke(null, "#%06X".format(rgb))); component }, + decorate = { component, decoration -> setDecorations.getValue(decoration).invoke(component, true); component }, + append = { left, right -> addExtra.invoke(left, right); left }, + ) + override fun readResponse(event: Event): DialogResponse? { val identifier = eventId.invoke(event).toString() if (identifier !in setOf(SUBMIT_ACTION, CANCEL_ACTION, CONFIRM_ACTION, DECLINE_ACTION)) return null @@ -481,6 +547,13 @@ private class SpigotDialogBackend private constructor( jsonAsString = jsonElement.getMethod("getAsString"), textComponentConstructor = textComponent.getConstructor(String::class.java), setColor = baseComponent.getMethod("setColor", chatColor), + setDecorations = mapOf( + MessageDecoration.BOLD to baseComponent.getMethod("setBold", Boolean::class.javaObjectType), + MessageDecoration.ITALIC to baseComponent.getMethod("setItalic", Boolean::class.javaObjectType), + MessageDecoration.UNDERLINE to baseComponent.getMethod("setUnderlined", Boolean::class.javaObjectType), + MessageDecoration.STRIKETHROUGH to baseComponent.getMethod("setStrikethrough", Boolean::class.javaObjectType), + MessageDecoration.OBFUSCATED to baseComponent.getMethod("setObfuscated", Boolean::class.javaObjectType), + ), addExtra = baseComponent.getMethod("addExtra", baseComponent), chatColorOf = chatColor.getMethod("of", String::class.java), greenColor = chatColor.getField("GREEN").get(null), @@ -516,6 +589,17 @@ private class SpigotDialogBackend private constructor( private fun load(name: String): Class<*> = Class.forName(name) +private fun messageDecorationConstants(enumClass: Class<*>): Map { + val constants = enumClass.enumConstants.associateBy { (it as Enum<*>).name } + return mapOf( + MessageDecoration.BOLD to requireNotNull(constants["BOLD"]), + MessageDecoration.ITALIC to requireNotNull(constants["ITALIC"]), + MessageDecoration.UNDERLINE to requireNotNull(constants["UNDERLINED"]), + MessageDecoration.STRIKETHROUGH to requireNotNull(constants["STRIKETHROUGH"]), + MessageDecoration.OBFUSCATED to requireNotNull(constants["OBFUSCATED"]), + ) +} + private const val INPUT_KEY = "invite_code" private const val SUBMIT_ACTION = "invitecode:claim_dialog_submit" private const val CANCEL_ACTION = "invitecode:claim_dialog_cancel" diff --git a/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt b/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt index cbd955a..94ce0ca 100644 --- a/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt +++ b/invitecode-platform-modern/src/test/kotlin/io/github/command1264/invitecode/platform/modern/ReflectiveNativeDialogInputTest.kt @@ -4,6 +4,10 @@ import io.github.command1264.invitecode.core.InviteCode import io.github.command1264.invitecode.core.InviteCodeFormats import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest +import io.github.command1264.invitecode.platform.bukkit.MessageDecoration +import io.github.command1264.invitecode.platform.bukkit.MessageSegment +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage +import io.github.command1264.invitecode.platform.bukkit.NativeDialogPresentation import org.bukkit.entity.Player import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -14,6 +18,132 @@ import java.util.UUID import java.util.logging.Logger class ReflectiveNativeDialogInputTest { + @Test + fun `styled component builder preserves segment text RGB and decorations`() { + val component = buildStyledComponent( + PresentedMessage(listOf( + MessageSegment("prefix ", 0x12ABEF, setOf(MessageDecoration.BOLD)), + MessageSegment( + "dynamic {value}", 0xCC8844, + setOf(MessageDecoration.ITALIC, MessageDecoration.UNDERLINE, MessageDecoration.STRIKETHROUGH, MessageDecoration.OBFUSCATED), + ), + )), + text = { TestTextComponent(it) }, + color = { value, rgb -> value.copy(color = rgb) }, + decorate = { value, decoration -> value.copy(decorations = value.decorations + decoration) }, + append = { left, right -> left.copy(children = left.children + right) }, + ) + + assertEquals("prefix dynamic {value}", component.children.joinToString("") { it.text }) + assertEquals(0x12ABEF, component.children[0].color) + assertEquals(setOf(MessageDecoration.BOLD), component.children[0].decorations) + assertEquals(0xCC8844, component.children[1].color) + assertEquals( + setOf(MessageDecoration.ITALIC, MessageDecoration.UNDERLINE, MessageDecoration.STRIKETHROUGH, MessageDecoration.OBFUSCATED), + component.children[1].decorations, + ) + } + + @Test + fun `styled component text neutralizes legacy markers and controls without reparsing ampersand codes`() { + val component = buildStyledComponent( + PresentedMessage(listOf(MessageSegment("name §cRED\u001B[31m\u0007 &c\n\tOK"))), + text = { TestTextComponent(it) }, + color = { value, rgb -> value.copy(color = rgb) }, + decorate = { value, decoration -> value.copy(decorations = value.decorations + decoration) }, + append = { left, right -> left.copy(children = left.children + right) }, + ) + + assertEquals("name &cRED[31m &c\n\tOK", component.children.single().text) + } + + @Test + fun `typed Adventure stand-in keeps sibling bold style local after reset`() { + val component = buildStyledComponent( + PresentedMessage(listOf( + MessageSegment("bold", decorations = setOf(MessageDecoration.BOLD)), + MessageSegment(" reset", decorations = emptySet()), + MessageSegment(" bold again", decorations = setOf(MessageDecoration.BOLD)), + )), + text = { TestTextComponent(it) }, + color = { value, rgb -> value.copy(color = rgb) }, + decorate = { value, decoration -> value.copy(decorations = value.decorations + decoration) }, + append = { left, right -> left.copy(children = left.children + right) }, + ) + + assertEquals(listOf("bold", " reset", " bold again"), component.children.map { it.text }) + assertEquals(setOf(MessageDecoration.BOLD), component.children[0].decorations) + assertTrue(component.children[1].decorations.isEmpty()) + assertEquals(setOf(MessageDecoration.BOLD), component.children[2].decorations) + } + + @Test + fun `real Bungee components keep sibling bold style local after reset`() { + val baseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent") + val textComponent = Class.forName("net.md_5.bungee.api.chat.TextComponent") + val constructor = textComponent.getConstructor(String::class.java) + val setBold = baseComponent.getMethod("setBold", Boolean::class.javaObjectType) + val setItalic = baseComponent.getMethod("setItalic", Boolean::class.javaObjectType) + val setUnderlined = baseComponent.getMethod("setUnderlined", Boolean::class.javaObjectType) + val setStrikethrough = baseComponent.getMethod("setStrikethrough", Boolean::class.javaObjectType) + val setObfuscated = baseComponent.getMethod("setObfuscated", Boolean::class.javaObjectType) + val decorationMethods = mapOf( + MessageDecoration.BOLD to setBold, + MessageDecoration.ITALIC to setItalic, + MessageDecoration.UNDERLINE to setUnderlined, + MessageDecoration.STRIKETHROUGH to setStrikethrough, + MessageDecoration.OBFUSCATED to setObfuscated, + ) + + val component = buildStyledComponent( + PresentedMessage(listOf( + MessageSegment("bold", decorations = setOf(MessageDecoration.BOLD)), + MessageSegment(" reset", decorations = emptySet()), + MessageSegment(" bold again", decorations = setOf(MessageDecoration.BOLD)), + )), + text = { constructor.newInstance(it) }, + color = { value, _ -> value }, + decorate = { value, decoration -> decorationMethods.getValue(decoration).invoke(value, true); value }, + append = { left, right -> baseComponent.getMethod("addExtra", baseComponent).invoke(left, right); left }, + ) + val children = baseComponent.getMethod("getExtra").invoke(component) as List<*> + val boldStates = children.map { baseComponent.getMethod("isBold").invoke(it) as Boolean? } + + assertEquals(3, children.size) + assertEquals(listOf(true, false, true), boldStates) + } + + @Test + fun `presentation request reaches backend unchanged without affecting callbacks`() { + val backend = FakeDialogBackend() + val adapter = ReflectiveNativeDialogInput(backend, Logger.getAnonymousLogger()) + val playerId = UUID.randomUUID() + val presentation = presentation() + val presentedRequest = request.copy(presentation = presentation) + var submitted: String? = null + + assertTrue(adapter.show(player(playerId), presentedRequest, { submitted = it }) {}) + assertEquals(presentedRequest, backend.lastInputRequest) + backend.emit(DialogResponse.Submitted(playerId, "CODE")) + assertEquals("CODE", submitted) + } + + @Test + fun `confirmation presentation request reaches backend unchanged and preserves action callbacks`() { + val backend = FakeDialogBackend() + val adapter = ReflectiveNativeDialogInput(backend, Logger.getAnonymousLogger()) + val playerId = UUID.randomUUID() + val request = confirmationRequest.copy(presentation = presentation()) + var confirmed = 0 + var declined = 0 + + assertTrue(adapter.showConfirmation(player(playerId), request, { confirmed++ }, { declined++ })) + assertEquals(request, backend.lastConfirmationRequest) + backend.emit(DialogResponse.Confirmed(playerId)) + assertEquals(1, confirmed) + assertEquals(0, declined) + } + @Test fun `successful submission is delivered once`() { val backend = FakeDialogBackend() @@ -179,16 +309,22 @@ private class FakeDialogBackend( var closeCount: Int = 0 private set private lateinit var listener: (DialogResponse) -> Unit + var lastInputRequest: NativeDialogRequest? = null + private set + var lastConfirmationRequest: NativeDialogConfirmationRequest? = null + private set override fun register(listener: (DialogResponse) -> Unit) { this.listener = listener } override fun show(player: Player, request: NativeDialogRequest) { + lastInputRequest = request if (failShow) throw NoSuchMethodException("showDialog") } override fun showConfirmation(player: Player, request: NativeDialogConfirmationRequest) { + lastConfirmationRequest = request if (failShow) throw NoSuchMethodException("showDialog") } @@ -200,3 +336,20 @@ private class FakeDialogBackend( listener(response) } } + +private data class TestTextComponent( + val text: String, + val color: Int? = null, + val decorations: Set = emptySet(), + val children: List = emptyList(), +) + +private fun presentation() = NativeDialogPresentation( + title = PresentedMessage(listOf(MessageSegment("[Invite] ", 0x40C0FF, setOf(MessageDecoration.BOLD)), MessageSegment("Title"))), + body = listOf(PresentedMessage(listOf(MessageSegment("Invite from "), MessageSegment("Alice", 0x55FF55)))), + confirm = PresentedMessage(listOf(MessageSegment("Accept", 0x55FF55, setOf(MessageDecoration.BOLD)))), + cancel = PresentedMessage(listOf(MessageSegment("Cancel", 0xFF5555))), + inputLabel = PresentedMessage(listOf(MessageSegment("Invite Code: ", 0xAABBCC))), + confirmHint = PresentedMessage(listOf(MessageSegment("Confirm hint", 0x55FF55))), + cancelHint = PresentedMessage(listOf(MessageSegment("Cancel hint", 0xFF5555))), +) diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt index 4f99daa..01f82c8 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/AdminWorkflowController.kt @@ -74,37 +74,40 @@ class AdminWorkflowController( } } - private fun inspectPlayer(sender: CommandSender, reference: String): Boolean = query(sender) { store -> + private fun inspectPlayer(sender: CommandSender, reference: String): Boolean = query(sender, "admin.inspect-player-title") { store -> val playerId = resolvePlayer(store, reference) val state = store.claimState(playerId) val code = store.activeInviteCode(playerId)?.code?.displayValue() ?: "NONE" val stats = store.inviterInvitationStats(playerId) - listOf( - "Player=$playerId name=${store.player(playerId)?.lastKnownName ?: "UNKNOWN"}", - "firstSeen=${state.firstSeenAt} inviter=${state.isInviter} invitee=${state.hasInvitation} code=$code", - "claimed=${stats.claimed} qualified=${stats.qualified} audit=${store.auditHistoryByPlayer(playerId, 20).size}", - ) + AdminMessage("admin.inspect-player", mapOf( + "player" to playerId.toString(), "name" to (store.player(playerId)?.lastKnownName ?: "UNKNOWN"), + "first_seen" to state.firstSeenAt.toString(), "inviter" to state.isInviter.toString(), + "invitee" to state.hasInvitation.toString(), "code" to code, + "claimed" to stats.claimed.toString(), "qualified" to stats.qualified.toString(), + "audit" to store.auditHistoryByPlayer(playerId, 20).size.toString(), + )) } - private fun inspectInvitation(sender: CommandSender, reference: String): Boolean = query(sender) { store -> + private fun inspectInvitation(sender: CommandSender, reference: String): Boolean = query(sender, "admin.inspect-invitation-title") { store -> val id = parseUuid(reference, "Invitation ID") val invitation = requireNotNull(store.invitation(id)) { "Invitation $id 不存在。" } - listOf( - "Invitation=${invitation.id} status=${invitation.status}", - "inviter=${invitation.inviterId} invitee=${invitation.inviteeId} claimedAt=${invitation.claimedAt}", - "facts=${store.qualificationFacts(id).size} rewards=${store.rewardDeliveries(id).size} " + - "audit=${store.auditHistoryByInvitation(id, 20).size}", - ) + AdminMessage("admin.inspect-invitation", mapOf( + "invitation" to invitation.id.toString(), "status" to invitation.status.name, + "inviter" to invitation.inviterId.toString(), "invitee" to invitation.inviteeId.toString(), + "claimed_at" to invitation.claimedAt.toString(), "facts" to store.qualificationFacts(id).size.toString(), + "rewards" to store.rewardDeliveries(id).size.toString(), "audit" to store.auditHistoryByInvitation(id, 20).size.toString(), + )) } - private fun inspectReward(sender: CommandSender, reference: String): Boolean = query(sender) { store -> + private fun inspectReward(sender: CommandSender, reference: String): Boolean = query(sender, "admin.inspect-reward-title") { store -> val id = parseUuid(reference, "Reward Action ID") val action = requireNotNull(store.rewardAction(id)) { "Reward Action $id 不存在。" } - listOf( - "RewardAction=${action.id} delivery=${action.rewardDeliveryId} status=${action.status}", - "recipient=${action.recipientId} type=${action.type} updatedAt=${action.updatedAt}", - "lastError=${action.lastError ?: "NONE"} transitions=${store.rewardActionTransitions(id).size}", - ) + AdminMessage("admin.inspect-reward", mapOf( + "action" to action.id.toString(), "delivery" to action.rewardDeliveryId.toString(), + "status" to action.status.name, "recipient" to action.recipientId.toString(), "type" to action.type, + "updated_at" to action.updatedAt.toString(), "last_error" to (action.lastError ?: "NONE"), + "transitions" to store.rewardActionTransitions(id).size.toString(), + )) } private fun forceQualify( @@ -219,13 +222,17 @@ class AdminWorkflowController( private fun mutate( sender: CommandSender, onSuccess: (T) -> Unit = { - if (it is AdminMessage) send(sender, it) else sender.sendMessage(it.toString()) + if (it is AdminMessage) send(sender, it) + else BukkitMessageOutput.sendLiteral(sender, configuration.current().value.messages, it.toString()) }, operation: (InviteCodeStorage) -> T, ): Boolean = submit(sender, operation, onSuccess) - private fun query(sender: CommandSender, operation: (InviteCodeStorage) -> List): Boolean = - submit(sender, operation) { lines -> lines.forEach(sender::sendMessage) } + private fun query(sender: CommandSender, title: String, operation: (InviteCodeStorage) -> AdminMessage): Boolean = + submit(sender, operation) { result -> + BukkitMessageOutput.sendReport(sender, configuration.current().value.messages, title, + listOf(result.key to result.variables)) + } private fun submit( sender: CommandSender, @@ -275,8 +282,12 @@ class AdminWorkflowController( } private fun send(sender: CommandSender, message: AdminMessage) { - val locale = (sender as? Player)?.let(BukkitLocaleCompatibility::locale) - sender.sendMessage(configuration.current().value.messages.resolve(locale, message.key, message.variables)) + BukkitMessageOutput.send( + sender, + configuration.current().value.messages, + message.key, + message.variables, + ) } private data class AdminMessage( diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoader.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoader.kt index c729f45..a019eb5 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoader.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoader.kt @@ -5,6 +5,8 @@ import io.github.command1264.invitecode.platform.bukkit.RuntimeConfigurationAsse import org.bukkit.configuration.ConfigurationSection import org.bukkit.configuration.InvalidConfigurationException import org.bukkit.configuration.file.YamlConfiguration +import java.io.InputStream +import java.io.InputStreamReader import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path @@ -14,14 +16,21 @@ class BukkitConfigurationLoader( private val dataDirectory: Path, private val onMissingMessage: (String) -> Unit, ) { - fun load(): InviteCodeRuntimeConfiguration = RuntimeConfigurationAssembler.parse( - general = loadDocument(dataDirectory.resolve("config.yml")), - storage = loadDocument(dataDirectory.resolve("storage.yml")), - qualifications = loadDocument(dataDirectory.resolve("qualifications.yml")), - rewards = loadDocument(dataDirectory.resolve("rewards.yml")), - messageCatalogs = loadMessageCatalogs(), - onMissingMessage = onMissingMessage, - ) + fun load(): InviteCodeRuntimeConfiguration { + BundledConfigurationInstaller(dataDirectory, ::openBundledResource).installMissing() + return RuntimeConfigurationAssembler.parse( + general = loadDocument(dataDirectory.resolve("config.yml")), + storage = loadDocument(dataDirectory.resolve("storage.yml")), + qualifications = loadDocument(dataDirectory.resolve("qualifications.yml")), + rewards = loadDocument(dataDirectory.resolve("rewards.yml")), + messageCatalogs = loadMessageCatalogs(), + onMissingMessage = onMissingMessage, + bundledMessageCatalogs = loadBundledMessageCatalogs(), + ) + } + + private fun openBundledResource(resourcePath: String): InputStream? = + javaClass.classLoader.getResourceAsStream(resourcePath) private fun loadMessageCatalogs(): Map> { val messagesDirectory = dataDirectory.resolve("messages") @@ -35,6 +44,25 @@ class BukkitConfigurationLoader( } } + private fun loadBundledMessageCatalogs(): Map> = + BUNDLED_MESSAGE_CATALOGS.mapValues { (_, resourcePath) -> + val input = openBundledResource(resourcePath) + ?: throw IllegalArgumentException("Bundled message catalog resource does not exist: $resourcePath") + input.use { resource -> parseBundledMessageCatalog(resource, resourcePath) } + } + + private fun parseBundledMessageCatalog(input: InputStream, resourcePath: String): Map { + val yaml = YamlConfiguration() + try { + InputStreamReader(input, StandardCharsets.UTF_8).use { reader -> yaml.load(reader) } + } catch (error: InvalidConfigurationException) { + throw IllegalArgumentException("Bundled message catalog has invalid YAML: $resourcePath", error) + } + return restoreBooleanLikeMessageKeys( + yaml.getValues(false).mapValues { (_, value) -> normalize(value) }, + ) + } + private fun restoreBooleanLikeMessageKeys(document: Map): Map { val values = document["value"] as? Map<*, *> ?: return document if ("yes" in values || "no" in values || "true" !in values || "false" !in values) return document @@ -58,7 +86,7 @@ class BukkitConfigurationLoader( } catch (error: InvalidConfigurationException) { if (path.fileName.toString() == "storage.yml") { throw IllegalArgumentException( - "storage.yml has invalid YAML; check its syntax without sharing the file because it may contain credentials.", + "storage.yml has invalid YAML\ncheck its syntax without sharing the file because it may contain credentials.", ) } throw error @@ -76,4 +104,11 @@ class BukkitConfigurationLoader( is List<*> -> value.map(::normalize) else -> value } + + companion object { + private val BUNDLED_MESSAGE_CATALOGS = mapOf( + "zh_TW" to "config/messages/zh_TW.yml", + "en_US" to "config/messages/en_US.yml", + ) + } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt index 047d14e..4762991 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitInviteCodeTabCompleter.kt @@ -9,6 +9,7 @@ import org.bukkit.entity.Player internal class BukkitInviteCodeTabCompleter( private val tasks: PlatformTaskDispatcher, + private val qualificationProfileIds: () -> Collection = { emptyList() }, ) : TabCompleter { override fun onTabComplete( sender: CommandSender, @@ -20,5 +21,6 @@ internal class BukkitInviteCodeTabCompleter( player = sender is Player, hasPermission = sender::hasPermission, onlinePlayerNames = tasks.onlinePlayerNames().toList(), + qualificationProfileIds = qualificationProfileIds(), ) } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutput.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutput.kt new file mode 100644 index 0000000..ccd238a --- /dev/null +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutput.kt @@ -0,0 +1,113 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.LocalizedMessages +import io.github.command1264.invitecode.platform.bukkit.MessageAudience +import io.github.command1264.invitecode.platform.bukkit.MessageDecoration +import io.github.command1264.invitecode.platform.bukkit.MessagePresenter +import io.github.command1264.invitecode.platform.bukkit.PrefixPlacement +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage +import net.md_5.bungee.api.chat.BaseComponent +import net.md_5.bungee.api.chat.TextComponent +import net.md_5.bungee.api.ChatColor +import io.github.command1264.invitecode.core.InviteCodeColor +import io.github.command1264.invitecode.core.LegacyInviteCodeColor +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player + +internal object BukkitMessageOutput { + fun send( + sender: CommandSender, + messages: LocalizedMessages, + key: String, + variables: Map = emptyMap(), + prefix: PrefixPlacement = PrefixPlacement.INLINE, + ) { + val presenter = MessagePresenter(messages) + val audience = audience(sender) + val locale = (sender as? Player)?.let(BukkitLocaleCompatibility::locale) + if (sender is Player || prefix == PrefixPlacement.NONE) { + sendPresented(sender, presenter.render(locale, key, variables, audience, prefix)) + } else { + sendFormatted(sender, messages, presenter.render(locale, key, variables, audience, PrefixPlacement.NONE), prefix) + } + } + + fun sendReport(sender: CommandSender, messages: LocalizedMessages, title: String, + sections: List>>, + formatter: ((String, Map) -> PresentedMessage)? = null) { + send(sender, messages, title) + sections.forEach { (key, variables) -> + val placement = if (sender is Player) PrefixPlacement.NONE else PrefixPlacement.INLINE + if (formatter == null) send(sender, messages, key, variables, placement) + else sendFormatted(sender, messages, formatter(key, variables), placement) + } + } + + private fun sendFormatted(sender: CommandSender, messages: LocalizedMessages, + body: PresentedMessage, prefix: PrefixPlacement) { + if (prefix == PrefixPlacement.NONE) { + sendPresented(sender, body) + return + } + val heading = MessagePresenter(messages).render((sender as? Player)?.let(BukkitLocaleCompatibility::locale), + "presentation.prefix", audience = audience(sender), prefix = PrefixPlacement.NONE) + lines(body).forEach { line -> + sendPresented(sender, PresentedMessage(if (heading.plainText.isEmpty()) line.segments + else heading.segments + io.github.command1264.invitecode.platform.bukkit.MessageSegment(" ") + line.segments)) + } + } + + private fun lines(message: PresentedMessage): List { + val result = mutableListOf() + var current = mutableListOf() + message.segments.forEach { segment -> + segment.text.split(Regex("\\r\\n|\\r|\\n")).forEachIndexed { index, part -> + if (index > 0) { + result.add(PresentedMessage(current.toList())) + current = mutableListOf() + } + if (part.isNotEmpty()) current.add(segment.copy(text = part)) + } + } + result.add(PresentedMessage(current.toList())) + return result + } + + fun sendLiteral(sender: CommandSender, messages: LocalizedMessages, text: String, prefix: PrefixPlacement = PrefixPlacement.INLINE) = + send(sender, messages, "runtime.raw-output", mapOf("text" to text), prefix) + + fun sendPresented(sender: CommandSender, message: PresentedMessage) { + if (sender is Player) sender.spigot().sendMessage(*components(message)) + else lines(message).forEach { line -> sender.sendMessage(buildString { + line.segments.forEach { segment -> + append("§r") + segment.color?.let { append('§').append(InviteCodeColor.fromRgb(it).nearestLegacyColor().code) } + append(segment.text.replace('§', '&').replace(CONTROLS, "")) + } + append("§r") + }) } + } + + fun audience(sender: CommandSender): MessageAudience = if (sender !is Player) MessageAudience.CONSOLE + else if (rgbColor != null) MessageAudience.RGB_PLAYER else MessageAudience.LEGACY_PLAYER + + fun components(message: PresentedMessage): Array = message.segments.map { segment -> + // Legacy section signs and terminal controls must never be reinterpreted by a downstream renderer. + TextComponent(segment.text.replace('§', '&').replace(CONTROLS, "")).apply { + color = segment.color?.let { rgb -> + LegacyInviteCodeColor.entries.firstOrNull { it.color.rgb == rgb }?.let { ChatColor.getByChar(it.code) } + ?: rgbColor?.invoke(null, "#%06X".format(rgb)) as? ChatColor + ?: ChatColor.getByChar(InviteCodeColor.fromRgb(rgb).nearestLegacyColor().code) + } ?: ChatColor.WHITE + setBold(MessageDecoration.BOLD in segment.decorations) + setItalic(MessageDecoration.ITALIC in segment.decorations) + setUnderlined(MessageDecoration.UNDERLINE in segment.decorations) + setStrikethrough(MessageDecoration.STRIKETHROUGH in segment.decorations) + setObfuscated(MessageDecoration.OBFUSCATED in segment.decorations) + } + }.toTypedArray() + + private val rgbColor = try { ChatColor::class.java.getMethod("of", String::class.java) } + catch (_: NoSuchMethodException) { null } + private val CONTROLS = Regex("[\\u0000-\\u0008\\u000B-\\u001F\\u007F]") +} diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstaller.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstaller.kt index 0a30b22..85b40b3 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstaller.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstaller.kt @@ -1,8 +1,11 @@ package io.github.command1264.invitecode.plugin import java.io.InputStream +import java.io.IOException +import java.nio.file.FileAlreadyExistsException import java.nio.file.Files import java.nio.file.Path +import java.nio.file.StandardCopyOption internal class BundledConfigurationInstaller( private val dataDirectory: Path, @@ -12,11 +15,54 @@ internal class BundledConfigurationInstaller( RESOURCES.forEach { (resourcePath, outputPath) -> val target = dataDirectory.resolve(outputPath) if (Files.notExists(target)) { - Files.createDirectories(requireNotNull(target.parent)) + val parent = requireNotNull(target.parent) + try { + Files.createDirectories(parent) + } catch (error: IOException) { + throw IOException( + "Could not create directory '$parent' for bundled resource '$resourcePath'.", + error, + ) + } val resource = requireNotNull(openResource(resourcePath)) { "Bundled resource does not exist: $resourcePath" } - resource.use { Files.copy(it, target) } + var temporary: Path? = null + var installFailure: IOException? = null + try { + resource.use { input -> + val staged = Files.createTempFile(parent, ".invitecode-config-", ".tmp") + temporary = staged + Files.copy(input, staged, StandardCopyOption.REPLACE_EXISTING) + } + try { + Files.move(requireNotNull(temporary), target) + } catch (_: FileAlreadyExistsException) { + if (!Files.isRegularFile(target)) { + throw IOException("Cannot publish bundled resource '$resourcePath' to '$target'.") + } + } + } catch (error: IOException) { + val contextual = IOException( + "Could not install bundled resource '$resourcePath' at '$target'.", + error, + ) + installFailure = contextual + throw contextual + } finally { + temporary?.let { staged -> + try { + Files.deleteIfExists(staged) + } catch (error: IOException) { + val previous = installFailure + if (previous != null) { + previous.addSuppressed(error) + } else { + throw IOException("Could not remove temporary configuration file '$staged'.", error) + } + } + } + } } } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayouts.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayouts.kt new file mode 100644 index 0000000..6130d34 --- /dev/null +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayouts.kt @@ -0,0 +1,49 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.LocalizedMessages +import io.github.command1264.invitecode.platform.bukkit.MessageAudience +import io.github.command1264.invitecode.platform.bukkit.MessagePresenter +import io.github.command1264.invitecode.platform.bukkit.PrefixPlacement +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage +import java.util.Locale + +/** Trusted catalog fragments retain styling; runtime values remain literal diagnostic data. */ +internal class DoctorMessageLayouts( + messages: LocalizedMessages, + private val locale: String?, + private val audience: MessageAudience, +) { + private val presenter = MessagePresenter(messages) + + fun render(key: String, values: Map): PresentedMessage { + val body = presenter.render(locale, key, values, audience, PrefixPlacement.NONE) + val fragments = values.mapNotNull { (name, value) -> + val suffix = when (name) { + "phase" -> known("phase", value, setOf("ACTIVE", "STARTING", "MAINTENANCE", "STOPPING", "STOPPED")) + "executor" -> known("executor", value, setOf("ACCEPTING", "STOPPED")) + "placeholder" -> known("enabled", value, setOf("true", "false")) + "vault" -> known("available", value, setOf("true", "false")) + "rgb" -> known("supported", value, setOf("true", "false")) + "dialog" -> known("dialog", value, setOf("PAPER", "NONE")) + "backend" -> known("backend", value, setOf("SQLITE", "MYSQL", "JSON")) + "pending", "processing", "uncertain" -> { + val count = value.toLongOrNull() + when { + count == 0L -> "count.zero" + count != null && count > 0 -> "count.$name" + else -> "unknown" + } + } + else -> null + } + suffix?.let { name to presenter.render(locale, "admin.doctor-value.$it", + mapOf("value" to value), audience, PrefixPlacement.NONE) } + }.toMap() + return PresentedMessage(body.segments.flatMap { segment -> + fragments[segment.variable]?.segments?.map { it.copy(variable = null) } ?: listOf(segment) + }) + } + + private fun known(group: String, value: String, allowed: Set): String = + if (value in allowed) "$group.${value.lowercase(Locale.ROOT)}" else "unknown" +} diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt index 7136b63..7e0a6d6 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/InviteCodePlugin.kt @@ -10,10 +10,17 @@ import io.github.command1264.invitecode.api.InviteCodeApi import io.github.command1264.invitecode.platform.bukkit.AsyncOperationExecutor import io.github.command1264.invitecode.platform.bukkit.AtomicRuntimeSnapshot import io.github.command1264.invitecode.platform.bukkit.ClaimInteractionSessions +import io.github.command1264.invitecode.platform.bukkit.CommandHelpNavigation +import io.github.command1264.invitecode.platform.bukkit.HelpFrameLayout +import io.github.command1264.invitecode.platform.bukkit.HelpRow import io.github.command1264.invitecode.platform.bukkit.InvalidInviteCodeCommand import io.github.command1264.invitecode.platform.bukkit.InviteCodeCommandId import io.github.command1264.invitecode.platform.bukkit.InviteCodeCommandParser import io.github.command1264.invitecode.platform.bukkit.InviteCodeRuntimeConfiguration +import io.github.command1264.invitecode.platform.bukkit.LocalizedMessages +import io.github.command1264.invitecode.platform.bukkit.MessagePresenter +import io.github.command1264.invitecode.platform.bukkit.PrefixPlacement +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage import io.github.command1264.invitecode.platform.bukkit.ParsedInviteCodeCommand import io.github.command1264.invitecode.platform.bukkit.PluginRuntimeState import io.github.command1264.invitecode.platform.bukkit.RuntimePhase @@ -36,6 +43,9 @@ import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.ServicePriority +import net.md_5.bungee.api.chat.HoverEvent +import net.md_5.bungee.api.chat.TextComponent +import net.md_5.bungee.api.chat.ClickEvent import java.time.Duration import java.time.Instant import java.util.concurrent.atomic.AtomicReference @@ -109,7 +119,7 @@ class InviteCodePlugin : JavaPlugin() { command.setExecutor( RuntimeCommandExecutor( runtime, - configuration, + messages = { configuration.currentOrNull()?.value?.messages }, reload = ::reload, migrateStorage = ::migrateStorage, playerWorkflow = playerWorkflows::handle, @@ -117,7 +127,9 @@ class InviteCodePlugin : JavaPlugin() { doctor = ::doctor, ), ) - command.setTabCompleter(BukkitInviteCodeTabCompleter(tasks)) + command.setTabCompleter(BukkitInviteCodeTabCompleter(tasks) { + configuration.currentOrNull()?.value?.qualifications?.policies?.keys ?: emptySet() + }) } qualificationTask = tasks.repeatGlobal(20L * 60L, 20L * 60L) { if (runtime.phase == RuntimePhase.ACTIVE) { @@ -260,7 +272,7 @@ class InviteCodePlugin : JavaPlugin() { }, onFailure = { error -> sendLocalized(sender, "admin.reload-failed") - logger.log(Level.WARNING, "InviteCode reload 驗證失敗;仍使用原設定。", error) + logger.log(Level.WARNING, "InviteCode reload 驗證失敗\n仍使用原設定。", error) }, ) if (!accepted) sendLocalized(sender, "admin.reload-stopping") @@ -347,67 +359,56 @@ class InviteCodePlugin : JavaPlugin() { }, onFailure = { error -> sendLocalized(sender, "admin.storage-failed") - logger.log(Level.SEVERE, "$actor 執行 $target schema migration 失敗;理由:$reason", error) + logger.log(Level.SEVERE, "$actor 執行 $target schema migration 失敗\n理由:$reason", error) }, ) if (!accepted) sendLocalized(sender, "admin.storage-stopping") } private fun doctor(sender: CommandSender) { - val generation = configuration.currentOrNull()?.generation?.toString() ?: "尚未載入" + val snapshot = configuration.currentOrNull() + val messages = snapshot?.value?.messages + if (messages == null) { + sendLocalized(sender, "admin.doctor-runtime") + return + } val executor = operations val store = storage.get() - val placeholder = server.pluginManager.getPlugin("PlaceholderAPI")?.isEnabled == true - val vault = OptionalVaultIntegration.find(server, logger) != null val capabilities = modernIntegration?.capabilities - sendLocalized( - sender, - "admin.doctor-runtime", - mapOf( - "phase" to runtime.phase.name, - "generation" to generation, - "executor" to if (executor?.acceptingOperations == true) "ACCEPTING" else "STOPPED", - ), + val sections = mutableListOf( + "admin.doctor-runtime" to mapOf("phase" to runtime.phase.name, + "generation" to snapshot.generation.toString(), + "executor" to if (executor?.acceptingOperations == true) "ACCEPTING" else "STOPPED"), + "admin.doctor-integrations" to mapOf( + "placeholder" to (server.pluginManager.getPlugin("PlaceholderAPI")?.isEnabled == true).toString(), + "vault" to (OptionalVaultIntegration.find(server, logger) != null).toString(), + "dialog" to (capabilities?.dialogProvider ?: "NONE"), "rgb" to (capabilities?.rgbText ?: false).toString()), ) - sendLocalized( - sender, - "admin.doctor-integrations", - mapOf( - "placeholder" to placeholder.toString(), - "vault" to vault.toString(), - "dialog" to (capabilities?.dialogProvider ?: "NONE"), - "rgb" to (capabilities?.rgbText ?: false).toString(), - ), - ) - runtime.maintenanceReason?.let { - sendLocalized(sender, "admin.doctor-maintenance", mapOf("reason" to it)) + runtime.maintenanceReason?.let { sections.add("admin.doctor-maintenance" to mapOf("reason" to it)) } + fun deliver(key: String, values: Map = emptyMap()) { + val layout = DoctorMessageLayouts(messages, (sender as? Player)?.let(BukkitLocaleCompatibility::locale), + BukkitMessageOutput.audience(sender)) + BukkitMessageOutput.sendReport(sender, messages, "runtime.help-topic.doctor", sections + (key to values), layout::render) } if (store == null || executor == null) { - sendLocalized(sender, "admin.doctor-storage-offline") + deliver("admin.doctor-storage-offline") return } val accepted = executor.callbacksOn { callback -> dispatchSender(sender, callback) }.submit( operation = { store.rewardBacklogCounts() }, - onSuccess = { backlog -> - sendLocalized( - sender, - "admin.doctor-storage", - mapOf( - "backend" to configuration.current().value.storage.backend.name, - "schema" to when (configuration.current().value.storage.backend) { - StorageBackendType.SQLITE -> SqliteSchemaMigrator.currentVersion.toString() - StorageBackendType.MYSQL -> MysqlSchemaMigrator.CURRENT_VERSION.toString() - StorageBackendType.JSON -> JsonInviteCodeStorage.FORMAT_VERSION.toString() - }, - "pending" to backlog.pending.toString(), - "processing" to backlog.processing.toString(), - "uncertain" to backlog.uncertain.toString(), - ), - ) - }, - onFailure = { sendLocalized(sender, "admin.doctor-storage-failed") }, + onSuccess = { backlog -> deliver("admin.doctor-storage", mapOf( + "backend" to snapshot.value.storage.backend.name, + "schema" to when (snapshot.value.storage.backend) { + StorageBackendType.SQLITE -> SqliteSchemaMigrator.currentVersion.toString() + StorageBackendType.MYSQL -> MysqlSchemaMigrator.CURRENT_VERSION.toString() + StorageBackendType.JSON -> JsonInviteCodeStorage.FORMAT_VERSION.toString() + }, + "pending" to backlog.pending.toString(), "processing" to backlog.processing.toString(), + "uncertain" to backlog.uncertain.toString(), + )) }, + onFailure = { deliver("admin.doctor-storage-failed") }, ) - if (!accepted) sendLocalized(sender, "admin.doctor-executor-stopping") + if (!accepted) deliver("admin.doctor-executor-stopping") } private fun sendLocalized( @@ -417,11 +418,10 @@ class InviteCodePlugin : JavaPlugin() { ) { val messages = configuration.currentOrNull()?.value?.messages if (messages == null) { - sender.sendMessage("InviteCode configuration is not loaded.") + sender.sendMessage("[InviteCode] Configuration is not loaded.") return } - val locale = (sender as? Player)?.let(BukkitLocaleCompatibility::locale) - sender.sendMessage(messages.resolve(locale, key, variables)) + BukkitMessageOutput.send(sender, messages, key, variables) } private fun dispatchSender(sender: CommandSender, operation: () -> Unit) { @@ -453,9 +453,9 @@ private data class StorageMigrationResult( val networkHasher: NetworkAddressHasher?, ) -private class RuntimeCommandExecutor( +internal class RuntimeCommandExecutor( private val runtime: PluginRuntimeState, - private val configuration: AtomicRuntimeSnapshot, + private val messages: () -> LocalizedMessages?, private val reload: (CommandSender) -> Unit, private val migrateStorage: (CommandSender, ParsedInviteCodeCommand) -> Unit, private val playerWorkflow: (Player, ParsedInviteCodeCommand) -> Boolean, @@ -469,7 +469,10 @@ private class RuntimeCommandExecutor( args: Array, ): Boolean = when (val parsed = InviteCodeCommandParser.parse(args.toList())) { is InvalidInviteCodeCommand -> { - send(sender, "runtime.usage", mapOf("label" to label)) + if (args.firstOrNull().equals("help", ignoreCase = true)) { + send(sender, if (sender.hasPermission("invitecode.command.basic")) + "runtime.help-page-error" else "runtime.no-permission") + } else send(sender, "runtime.usage", mapOf("label" to label)) true } is ParsedInviteCodeCommand -> execute(sender, label, parsed) @@ -493,7 +496,7 @@ private class RuntimeCommandExecutor( return true } when (request.id) { - InviteCodeCommandId.HELP -> help(sender, label) + InviteCodeCommandId.HELP -> help(sender, label, request.operands) InviteCodeCommandId.ADMIN_RELOAD -> reload(sender) InviteCodeCommandId.ADMIN_STORAGE_MIGRATE -> migrateStorage(sender, request) InviteCodeCommandId.ADMIN_DOCTOR -> { @@ -511,34 +514,134 @@ private class RuntimeCommandExecutor( } private fun send(sender: CommandSender, key: String, variables: Map = emptyMap()) { - val messages = configuration.currentOrNull()?.value?.messages - if (messages == null) { - sender.sendMessage("InviteCode configuration is not loaded.") + val catalog = messages() + if (catalog == null) { + sender.sendMessage("[InviteCode] Configuration is not loaded.") + return + } + BukkitMessageOutput.send(sender, catalog, key, variables) + } + + private fun help(sender: CommandSender, label: String, arguments: List) { + val catalog = messages() + if (catalog == null) { + sender.sendMessage("[InviteCode] Configuration is not loaded.") + return + } + val query = CommandHelpNavigation.query(arguments) ?: return + val page = CommandHelpNavigation.resolve(query, label, sender is Player, sender::hasPermission) + if (page.error) { + send(sender, "runtime.help-page-error") return } val locale = (sender as? Player)?.let(BukkitLocaleCompatibility::locale) - sender.sendMessage(messages.resolve(locale, key, variables)) + val presenter = MessagePresenter(catalog) + val audience = BukkitMessageOutput.audience(sender) + val title = if (query.home) presenter.render(locale, if (sender is Player) "runtime.help-home-header" else "runtime.help-console-home-header", + audience = audience, prefix = PrefixPlacement.NONE) + else if (page.detail != null) presenter.render(locale, "runtime.help-header", + audience = audience, prefix = PrefixPlacement.NONE) + else { + val topic = if (sender !is Player && (query.path.isEmpty() || query.path == listOf("admin"))) "console" + else query.path.lastOrNull() ?: "player" + presenter.render(locale, "runtime.help-page-header", mapOf( + "topic" to presenter.render(locale, "runtime.help-topic.$topic", + audience = audience, prefix = PrefixPlacement.NONE).plainText, + "page" to query.page.toString(), "pages" to page.pages.toString(), + ), audience = audience, prefix = PrefixPlacement.NONE) + } + val prefix = presenter.render(locale, "presentation.prefix", audience = audience, prefix = PrefixPlacement.NONE) + val header = presenter.render(locale, "runtime.help-frame-header", + mapOf("prefix" to prefix.plainText + if (prefix.plainText.isEmpty()) "" else " ", "title" to title.plainText), audience = audience, prefix = PrefixPlacement.NONE) + val heading = PresentedMessage(header.segments.flatMap { segment -> + when (segment.variable) { + "prefix" -> prefix.segments.map { it.copy(variable = null) } + + if (prefix.plainText.isEmpty()) emptyList() else presenter.render(locale, "runtime.raw-output", + mapOf("text" to " "), audience = audience, prefix = PrefixPlacement.NONE).segments + "title" -> title.segments.map { it.copy(variable = null) } + else -> listOf(segment) + } + }) + val divider = presenter.render(locale, "runtime.help-frame-divider", audience = audience, prefix = PrefixPlacement.NONE) + val frame = HelpFrameLayout.align(heading, divider, audience) + BukkitMessageOutput.sendPresented(sender, frame.first) + val detail = page.detail + if (detail != null) { + val usage = (if (sender is Player) "/" else "") + "$label ${detail.usage}" + val message = presenter.render(locale, CommandHelpNavigation.detailKey(detail), + mapOf("usage" to usage, "example" to (if (sender is Player) CommandHelpNavigation.example(detail, label) else CommandHelpNavigation.example(detail, label).removePrefix("/"))), + audience = BukkitMessageOutput.audience(sender), prefix = PrefixPlacement.NONE) + sendHelpMessage(sender, message, mapOf("usage" to usage, + "example" to (if (sender is Player) CommandHelpNavigation.example(detail, label) else CommandHelpNavigation.example(detail, label).removePrefix("/"))), false) + } + page.rows.forEach { sendHelpRow(sender, catalog, locale, it) } + BukkitMessageOutput.sendPresented(sender, frame.second) + val slots = listOf("previous" to page.previous, "back" to page.back, "next" to page.next) + if (sender !is Player) { + val available = slots.filter { it.second != null } + if (available.isNotEmpty()) { + BukkitMessageOutput.send(sender, catalog, "runtime.help-console-navigation-title", prefix = PrefixPlacement.NONE) + available.forEach { (name, target) -> + val caption = presenter.render(locale, "runtime.help-$name", audience = audience, + prefix = PrefixPlacement.NONE).plainText + BukkitMessageOutput.sendLiteral(sender, catalog, "$caption: ${target!!.removePrefix("/")}", PrefixPlacement.NONE) + } + } + return + } + + val segments = slots.flatMapIndexed { index, (name, target) -> + val caption = presenter.render(locale, "runtime.help-$name", + audience = audience, prefix = PrefixPlacement.NONE).plainText + val text = caption + val item = presenter.render(locale, + if (target == null) "runtime.help-navigation-disabled" else "runtime.help-navigation-enabled", + mapOf("text" to text), audience = audience, prefix = PrefixPlacement.NONE) + val spacer = if (index == 0) emptyList() else presenter.render(locale, "runtime.raw-output", + mapOf("text" to " "), audience = audience, prefix = PrefixPlacement.NONE).segments + spacer + item.segments.map { it.copy(variable = if (target != null) name else null) } + } + val hover = presenter.render(locale, "runtime.help-navigation-hover", + audience = audience, prefix = PrefixPlacement.NONE).plainText + sendHelpMessage(sender, PresentedMessage(segments), slots.mapNotNull { (name, target) -> + target?.let { name to it } + }.toMap(), true, hover) } - private fun help(sender: CommandSender, label: String) { - send(sender, "runtime.help-header") - val routes = listOf( - Triple("invitecode.command.code", true, "/$label code"), - Triple("invitecode.command.claim", true, "/$label claim [code] | confirm | cancel"), - Triple("invitecode.command.status", true, "/$label status"), - Triple("invitecode.command.stats", true, "/$label stats"), - Triple("invitecode.admin.inspect", false, "/$label admin inspect player|invitation|reward ..."), - Triple("invitecode.admin.invitation", false, "/$label admin invitation unlink|transfer ..."), - Triple("invitecode.admin.qualification", false, "/$label admin invitation force-qualify ..."), - Triple("invitecode.admin.eligibility", false, "/$label admin eligibility reset ..."), - Triple("invitecode.admin.reward", false, "/$label admin reward retry|mark-delivered ..."), - Triple("invitecode.admin.code", false, "/$label admin code rotate ..."), - Triple("invitecode.admin.storage", false, "/$label admin storage migrate SQLITE "), - Triple("invitecode.admin.reload", false, "/$label reload"), - Triple("invitecode.admin.doctor", false, "/$label admin doctor"), - ) - routes.filter { (permission, playerOnly, _) -> - sender.hasPermission(permission) && (!playerOnly || sender is Player) - }.forEach { (_, _, usage) -> sender.sendMessage(usage) } + private fun sendHelpRow(sender: CommandSender, catalog: LocalizedMessages, locale: String?, entry: HelpRow) { + val presenter = MessagePresenter(catalog) + val audience = BukkitMessageOutput.audience(sender) + val description = presenter.render(locale, entry.descriptionKey, + audience = audience, prefix = PrefixPlacement.NONE) + val row = presenter.render(locale, "runtime.help-row", + mapOf("usage" to (if (sender is Player) entry.usage else entry.usage.removePrefix("/")), "description" to description.plainText), + audience = audience, prefix = PrefixPlacement.NONE) + // Description formatting stays independent from the usage and outer row template. + val presented = PresentedMessage(row.segments.flatMap { segment -> + if (segment.variable != "description") listOf(segment) + else description.segments.map { it.copy(variable = null) } + }) + val hover = if (entry.navigation) presenter.render(locale, "runtime.help-open-detail", + audience = audience, prefix = PrefixPlacement.NONE).plainText else null + sendHelpMessage(sender, presented, mapOf("usage" to entry.target), entry.navigation, hover) + } + + private fun sendHelpMessage(sender: CommandSender, message: PresentedMessage, + targets: Map, navigation: Boolean, hover: String? = null) { + if (sender !is Player) { + BukkitMessageOutput.sendPresented(sender, message) + return + } + val components = BukkitMessageOutput.components(message) + message.segments.forEachIndexed { index, segment -> + targets[segment.variable]?.let { target -> + // RUN_COMMAND targets are constructed exclusively by the read-only help tree. + components[index].clickEvent = ClickEvent( + if (navigation) ClickEvent.Action.RUN_COMMAND else ClickEvent.Action.SUGGEST_COMMAND, target) + if (hover != null) components[index].hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, + arrayOf(TextComponent(hover))) + } + } + sender.spigot().sendMessage(*components) } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlRuntimeBootstrap.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlRuntimeBootstrap.kt index 8fdac3e..c5a0a76 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlRuntimeBootstrap.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlRuntimeBootstrap.kt @@ -45,7 +45,7 @@ internal class MysqlRuntimeBootstrap( val catalog = requireNotNull(connection.catalog) { "MySQL database is not selected." } connection.metaData.getTables(catalog, null, "invitecode_transfer_guard", arrayOf("TABLE")).use { tables -> if (tables.next()) throw MysqlStorageException( - "MySQL backend transfer is incomplete; keep InviteCode stopped, inspect the destination " + + "MySQL backend transfer is incomplete\nkeep InviteCode stopped, inspect the destination " + "and restore or restart the offline transfer before enabling this database.", ) } @@ -78,7 +78,7 @@ internal class MysqlRuntimeBootstrap( "SQLState ${error.sqlState ?: "unknown"}, code ${error.errorCode}" } else error.javaClass.simpleName throw MysqlStorageException( - "MySQL initialization failed at ${config.host}:${config.port}/${config.database}; " + + "MySQL initialization failed at ${config.host}:${config.port}/${config.database}\n" + "check connectivity, schema and shared network secret ($diagnostic).", ) } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlTransferCoordinator.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlTransferCoordinator.kt index be36e0b..1cd13f2 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlTransferCoordinator.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/MysqlTransferCoordinator.kt @@ -19,7 +19,7 @@ internal object MysqlTransferCoordinator { statement.executeQuery().use { rows -> rows.next() && rows.getInt(1) == 1 } } if (!acquired) throw MysqlStorageException( - "MySQL backend transfer/startup lock timed out; stop all instances and retry.", + "MySQL backend transfer/startup lock timed out\nstop all instances and retry.", ) try { operation(connection) @@ -28,7 +28,7 @@ internal object MysqlTransferCoordinator { statement.setString(1, name) statement.executeQuery().use { rows -> if (!rows.next() || rows.getInt(1) != 1) throw MysqlStorageException( - "MySQL backend transfer/startup lock was lost; inspect the database before continuing.", + "MySQL backend transfer/startup lock was lost\ninspect the database before continuing.", ) } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineAnonymizeMain.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineAnonymizeMain.kt index bce33e9..51bb6ee 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineAnonymizeMain.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineAnonymizeMain.kt @@ -23,6 +23,10 @@ import java.util.Locale /** Invoke directly from the shaded plugin JAR while all InviteCode servers are stopped. */ object OfflineAnonymizeMain { + private fun printMessage(value: String) { + value.lineSequence().forEach { line -> println(if (line.startsWith("[InviteCode]")) line else "[InviteCode] $line") } + } + @JvmStatic fun main(args: Array) { try { @@ -42,7 +46,7 @@ object OfflineAnonymizeMain { val source = path(options.required("source")) makeBackup(source, path(options.required("backup"))) JsonInviteCodeStorage.migrateV8ToV9(source, BlockingOperationGuard { }) - println("JSON 快照已升級至 schema 9;請驗證快照並保留備份。") + printMessage("JSON 快照已升級至 schema 9\n請驗證快照並保留備份。") return } if ("migrate-sqlite" in options) { @@ -52,7 +56,7 @@ object OfflineAnonymizeMain { val source = path(options.required("source")) makeBackup(source, path(options.required("backup"))) val version = SqliteSchemaMigrator(source, BlockingOperationGuard { }).migrate() - println("SQLite schema 已升級至 $version;請驗證資料庫並保留備份。") + printMessage("SQLite schema 已升級至 $version\n請驗證資料庫並保留備份。") return } if ("migrate-mysql" in options) { @@ -66,7 +70,7 @@ object OfflineAnonymizeMain { pool.use { val version = MysqlSchemaMigrator(it, BlockingOperationGuard { }).migrate() it.connection.use { connection -> MysqlSchemaMigrator.bindNetworkKey(connection, hasher.keyId) } - println("MySQL schema 已升級至 $version;請驗證資料庫並保留 dump。") + printMessage("MySQL schema 已升級至 $version\n請驗證資料庫並保留 dump。") } } return @@ -94,7 +98,7 @@ object OfflineAnonymizeMain { if (apply) { requireBackupDump(path(options.required("backup"))) storage.anonymizePlayer(playerId) - println("玩家資料已匿名化;請驗證資料並保留備份。") + printMessage("玩家資料已匿名化\n請驗證資料並保留備份。") } } } @@ -112,7 +116,7 @@ object OfflineAnonymizeMain { if (apply) { makeBackup(source, path(options.required("backup"))) storage.anonymizePlayer(playerId) - println("玩家資料已匿名化;請驗證資料並保留備份。") + printMessage("玩家資料已匿名化\n請驗證資料並保留備份。") } } } else { @@ -122,7 +126,7 @@ object OfflineAnonymizeMain { if (apply) { makeBackup(source, path(options.required("backup"))) storage.anonymizePlayer(playerId) - println("玩家資料已匿名化;請驗證資料並保留備份。") + printMessage("玩家資料已匿名化\n請驗證資料並保留備份。") } } } @@ -131,7 +135,7 @@ object OfflineAnonymizeMain { } private fun printPreview(preview: AnonymizationPreview) { - println("影響範圍:邀請 ${preview.invitations} 筆、獎勵交付 ${preview.rewardDeliveries} 筆、舊邀請碼 ${preview.retiredCodes} 組。") + printMessage("[InviteCode] 影響範圍:\n邀請:${preview.invitations} 筆\n獎勵交付:${preview.rewardDeliveries} 筆\n舊邀請碼:${preview.retiredCodes} 組") } private fun mysqlConfig(options: Map): MysqlConfiguration = MysqlConfiguration( @@ -150,17 +154,17 @@ object OfflineAnonymizeMain { private fun makeBackup(source: Path, destination: Path) { require(Files.isRegularFile(source, NOFOLLOW_LINKS)) { "儲存來源必須是既有的一般檔案。" } require(source != destination) { "備份路徑不能與來源相同。" } - require(!Files.exists(destination, NOFOLLOW_LINKS)) { "備份檔已存在;請選擇新路徑。" } + require(!Files.exists(destination, NOFOLLOW_LINKS)) { "備份檔已存在\n請選擇新路徑。" } require(Files.isDirectory(destination.parent)) { "備份檔的上層資料夾必須存在。" } // A leftover WAL can contain committed rows absent from the main SQLite file. if (!source.fileName.toString().endsWith(".json", ignoreCase = true)) { require(!Files.exists(source.resolveSibling("${source.fileName}-wal")) && !Files.exists(source.resolveSibling("${source.fileName}-shm"))) { - "SQLite 仍有 WAL/SHM 檔案;請先確認實例已停止、執行 checkpoint 並完整備份。" + "SQLite 仍有 WAL/SHM 檔案\n請先確認實例已停止、執行 checkpoint 並完整備份。" } } Files.copy(source, destination, COPY_ATTRIBUTES) - require(digest(destination).contentEquals(digest(source))) { "備份與來源的 SHA-256 不一致;已停止操作。" } + require(digest(destination).contentEquals(digest(source))) { "備份與來源的 SHA-256 不一致\n已停止操作。" } } private fun digest(path: Path): ByteArray = MessageDigest.getInstance("SHA-256").let { sha -> diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMain.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMain.kt index 7e146d4..dc56c59 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMain.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMain.kt @@ -25,6 +25,10 @@ import java.util.Locale /** Explicit offline transfer entry point. It never changes storage.yml or deletes the source. */ object OfflineStorageTransferMain { + private fun printMessage(value: String) { + value.lineSequence().forEach { line -> println(if (line.startsWith("[InviteCode]")) line else "[InviteCode] $line") } + } + @JvmStatic fun main(args: Array) { try { @@ -54,25 +58,25 @@ object OfflineStorageTransferMain { hasher(source, options, environment).use { sourceHasher -> hasher(destination, options, environment).use { destinationHasher -> require(sourceHasher.keyId == destinationHasher.keyId) { - "兩端 anti-abuse 密鑰不同;請先提供相同密鑰。既有 IP hash 與舊邀請碼保留值不可重新計算。" + "兩端 anti-abuse 密鑰不同\n請先提供相同密鑰。既有 IP hash 與舊邀請碼保留值不可重新計算。" } val keyId = sourceHasher.keyId val snapshot = export(source, mysql, password, sourceHasher, guard) require(snapshot.networkKeyId == keyId) { "來源 metadata 與提供的密鑰不一致。" } preflightDestination(destination, mysql, password) - println("預檢通過:${source.backend} → ${destination.backend};" + - snapshot.tables.joinToString("、") { "${it.name.removePrefix("invitecode_")}=${it.rows.size}" }) + printMessage("預檢通過:${source.backend} → ${destination.backend}\n" + + snapshot.tables.joinToString("\n") { "${it.name.removePrefix("invitecode_")}=${it.rows.size}" }) if (!apply) { - println("本次只預覽;備份來源後,使用相同選項加 --apply --backup <路徑> 執行。") + printMessage("本次只預覽\n備份來源後,使用相同選項加 --apply --backup <路徑> 執行。") return } backup(source, requireNotNull(backupPath)) // Reject changes between preview and the final source read; the backup is made before publication. val finalSnapshot = export(source, mysql, password, sourceHasher, guard) - require(finalSnapshot == snapshot) { "來源在預檢後改變;目的地未寫入。停止所有寫入者並重新執行。" } + require(finalSnapshot == snapshot) { "來源在預檢後改變\n目的地未寫入。停止所有寫入者並重新執行。" } val checkSourceUnchanged = { require(export(source, mysql, password, sourceHasher, guard) == finalSnapshot) { - "搬移期間來源發生變化;目的地仍在 staging,禁止 cutover。請檢查所有寫入者。" + "搬移期間來源發生變化\n目的地仍在 staging,禁止 cutover。請檢查所有寫入者。" } } when (destination.backend) { @@ -80,7 +84,7 @@ object OfflineStorageTransferMain { "json" -> writeJson(requireNotNull(destination.file), destinationHasher, finalSnapshot, guard, checkSourceUnchanged) "mysql" -> writeMysql(requireNotNull(mysql), requireNotNull(password), finalSnapshot, guard, checkSourceUnchanged) } - println("目的地已完成全表驗證;來源未改動。確認 storage.yml 僅指向目的地後,再啟動一組 InviteCode 實例。") + printMessage("目的地已完成全表驗證\n來源未改動。確認 storage.yml 僅指向目的地後,再啟動一組 InviteCode 實例。") } } } @@ -98,7 +102,7 @@ object OfflineStorageTransferMain { require(Files.isRegularFile(file, NOFOLLOW_LINKS)) { "來源資料檔必須已存在。" } if (backend == "sqlite") requireNoWal(file) } else { - require(!Files.exists(file, NOFOLLOW_LINKS)) { "目的資料檔已存在;不可覆寫。" } + require(!Files.exists(file, NOFOLLOW_LINKS)) { "目的資料檔已存在\n不可覆寫。" } require(Files.isDirectory(requireNotNull(file.parent))) { "目的資料夾必須已存在。" } } return Endpoint(backend, file, secretFile) @@ -143,7 +147,7 @@ object OfflineStorageTransferMain { private fun preflightDestination(destination: Endpoint, mysql: MysqlConfiguration?, password: String?) { if (destination.backend != "mysql") { - require(!Files.exists(requireNotNull(destination.file), NOFOLLOW_LINKS)) { "目的資料檔已出現;停止操作。" } + require(!Files.exists(requireNotNull(destination.file), NOFOLLOW_LINKS)) { "目的資料檔已出現\n停止操作。" } return } MysqlInviteCodeStorage.createPool(requireNotNull(mysql), requireNotNull(password)).use { pool -> @@ -151,7 +155,7 @@ object OfflineStorageTransferMain { requireNoOtherMysqlSessions(connection) val catalog = requireNotNull(connection.catalog) { "MySQL 沒有選定 database。" } connection.metaData.getTables(catalog, null, "%", arrayOf("TABLE", "VIEW")).use { tables -> - require(!tables.next()) { "MySQL 目的 database 必須完全空白;不可覆寫或重試既有 staging。" } + require(!tables.next()) { "MySQL 目的 database 必須完全空白\n不可覆寫或重試既有 staging。" } } } } @@ -204,7 +208,7 @@ object OfflineStorageTransferMain { requireNoOtherMysqlSessions(connection) val catalog = requireNotNull(connection.catalog) connection.metaData.getTables(catalog, null, "%", arrayOf("TABLE", "VIEW")).use { - require(!it.next()) { "MySQL 目的 database 已有表格;停止操作。" } + require(!it.next()) { "MySQL 目的 database 已有表格\n停止操作。" } } // This marker blocks plugin startup if DDL, import, or verification is interrupted. OfflineStorageTransfer.createMysqlTransferGuard(connection) @@ -225,7 +229,7 @@ object OfflineStorageTransferMain { "SELECT COUNT(*) FROM information_schema.PROCESSLIST WHERE DB = DATABASE() AND ID <> CONNECTION_ID()", ).use { rows -> rows.next(); rows.getLong(1) } } - require(others == 0L) { "偵測到其他 MySQL 連線;請先停止所有使用這個 database 的程序。" } + require(others == 0L) { "偵測到其他 MySQL 連線\n請先停止所有使用這個 database 的程序。" } } private fun backup(source: Endpoint, backup: Path) { @@ -240,13 +244,13 @@ object OfflineStorageTransferMain { require(Files.isDirectory(requireNotNull(backup.parent))) { "備份資料夾必須已存在。" } if (source.backend == "sqlite") requireNoWal(file) Files.copy(file, backup, COPY_ATTRIBUTES) - require(digest(file).contentEquals(digest(backup))) { "來源與備份的 SHA-256 不同;停止搬移。" } + require(digest(file).contentEquals(digest(backup))) { "來源與備份的 SHA-256 不同\n停止搬移。" } } private fun requireNoWal(file: Path) { require(!Files.exists(file.resolveSibling("${file.fileName}-wal")) && !Files.exists(file.resolveSibling("${file.fileName}-shm"))) { - "SQLite 仍有 WAL/SHM;先停止實例、checkpoint 並做一致性備份。" + "SQLite 仍有 WAL/SHM\n先停止實例、checkpoint 並做一致性備份。" } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt index 393914c..3e239d5 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActions.kt @@ -5,48 +5,49 @@ import net.md_5.bungee.api.chat.BaseComponent import net.md_5.bungee.api.chat.ClickEvent import net.md_5.bungee.api.chat.HoverEvent import net.md_5.bungee.api.chat.TextComponent +import io.github.command1264.invitecode.platform.bukkit.MessageSegment +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage /** Interactive chat affordances isolated from the legacy text and RGB Invite Code formatter. */ internal object PlayerChatActions { fun codeMessage( - template: String, - displayedCode: String, + message: PresentedMessage, code: String, - copyHint: String, - selectHint: String, + copyHint: PresentedMessage, + selectHint: PresentedMessage, ): Array { // COPY_TO_CLIPBOARD is absent from the Bungee chat API bundled by Spigot 1.8.8. val clipboard = enumValues().firstOrNull { it.name == "COPY_TO_CLIPBOARD" } val action = clipboard ?: ClickEvent.Action.SUGGEST_COMMAND - val marker = "{code}" - val before = if (marker in template) template.substringBefore(marker) else template + " " - val after = if (marker in template) template.substringAfter(marker) else "" - val codeComponents = TextComponent.fromLegacyText(displayedCode) - codeComponents.forEach { component -> - component.clickEvent = ClickEvent(action, code) - component.hoverEvent = HoverEvent( - HoverEvent.Action.SHOW_TEXT, - arrayOf(TextComponent(if (clipboard != null) copyHint else selectHint)), - ) + val components = BukkitMessageOutput.components(message) + components.zip(message.segments).forEach { (component, segment) -> + if (segment.variable == "code") { + component.clickEvent = ClickEvent(action, code) + component.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, + BukkitMessageOutput.components(if (clipboard != null) copyHint else selectHint)) + } } - return TextComponent.fromLegacyText(before) + codeComponents + TextComponent.fromLegacyText(after) + return components } fun confirmation( - agreeLabel: String, - disagreeLabel: String, - agreeHint: String, - disagreeHint: String, - ): Array = arrayOf( - TextComponent("[$agreeLabel]").apply { - color = ChatColor.GREEN - clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/invitecode confirm") - hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, arrayOf(TextComponent(agreeHint))) - }, - TextComponent(" [$disagreeLabel]").apply { - color = ChatColor.RED - clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/invitecode cancel") - hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, arrayOf(TextComponent(disagreeHint))) - }, + agreeLabel: PresentedMessage, + disagreeLabel: PresentedMessage, + agreeHint: PresentedMessage, + disagreeHint: PresentedMessage, + ): Array = arrayOf( + button(agreeLabel, agreeHint, "/invitecode confirm", false), + button(disagreeLabel, disagreeHint, "/invitecode cancel", true), ) + + private fun button(label: PresentedMessage, hint: PresentedMessage, command: String, separated: Boolean): BaseComponent { + val bracketColor = if (separated) 0xFF5555 else 0x55FF55 + val content = PresentedMessage(listOf(MessageSegment(if (separated) " [" else "[", bracketColor)) + + label.segments + MessageSegment("]", bracketColor)) + return TextComponent(*BukkitMessageOutput.components(content)).apply { + color = if (separated) ChatColor.RED else ChatColor.GREEN + clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, command) + hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, BukkitMessageOutput.components(hint)) + } + } } diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayouts.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayouts.kt new file mode 100644 index 0000000..d8f7803 --- /dev/null +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayouts.kt @@ -0,0 +1,91 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.core.InviteCode +import io.github.command1264.invitecode.platform.bukkit.* + +/** Assembles user-visible layouts; none of these fragments are command or clipboard payloads. */ +internal class PlayerMessageLayouts( + private val messages: LocalizedMessages, + private val locale: String?, + private val audience: MessageAudience, +) { + private val presenter = MessagePresenter(messages) + + fun fragment(key: String, variables: Map = emptyMap()) = + presenter.render(locale, key, variables, audience, PrefixPlacement.NONE) + + fun code(code: InviteCode): PresentedMessage = colorCode(presenter.render( + locale, "command.code.value", mapOf("code" to code.displayValue()), audience, + ), code) + + fun status(eligible: Boolean, invitation: String, pendingRewards: Int, reasons: List): PresentedMessage { + val summary = presenter.render(locale, "command.status.summary", mapOf( + "eligible" to fragment(if (eligible) "value.yes" else "value.no").plainText, + "invitation" to fragment("value.invitation.$invitation").plainText, + "pending_rewards" to pendingRewards.toString(), + ), audience) + if (eligible || reasons.isEmpty()) return summary + val reason = fragment("command.status.ineligible-reason", mapOf( + "reasons" to reasons.first(), + )) + return PresentedMessage(summary.segments + MessageSegment("\n") + reason.segments) + } + + fun chatConfirmation(inviter: String, code: InviteCode, seconds: Long) = colorCode(presenter.render( + locale, "command.claim.confirmation", + mapOf("inviter" to inviter, "code" to code.displayValue(), "seconds" to seconds.toString()), + audience, PrefixPlacement.OWN_LINE, + ), code) + + fun inputDialog(): NativeDialogRequest { + val prefix = fragment("presentation.prefix") + val heading = fragment("command.claim.dialog-title") + val label = fragment("command.claim.dialog-label") + val confirm = fragment("command.claim.dialog-confirm") + val cancel = fragment("command.claim.dialog-cancel") + return NativeDialogRequest( + title = if (prefix.plainText.isEmpty()) heading.plainText else prefix.plainText, + label = label.plainText, confirm = confirm.plainText, cancel = cancel.plainText, maximumLength = 64, + presentation = NativeDialogPresentation( + title = if (prefix.plainText.isEmpty()) heading else prefix, + body = if (prefix.plainText.isEmpty()) emptyList() else listOf(heading), + confirm = confirm, cancel = cancel, inputLabel = label, + ), + ) + } + + fun confirmationDialog(inviter: String, code: InviteCode, seconds: Long): NativeDialogConfirmationRequest { + val prefix = fragment("presentation.prefix") + val heading = fragment("command.claim.confirmation-title") + val inviterLine = fragment("command.claim.confirmation-inviter", mapOf("inviter" to inviter)) + val codeLabel = fragment("command.claim.confirmation-code-label") + val codeLine = colorCode(PresentedMessage(codeLabel.segments + MessageSegment( + code.displayValue(), variable = "code", + )), code) + val question = fragment("command.claim.confirmation-question") + val prompt = fragment("command.claim.confirmation-prompt", mapOf("seconds" to seconds.toString())) + val agree = fragment("command.claim.agree") + val disagree = fragment("command.claim.disagree") + val agreeHint = fragment("command.claim.agree-hover") + val disagreeHint = fragment("command.claim.disagree-hover") + val hasPrefix = prefix.plainText.isNotEmpty() + val body = (if (hasPrefix) listOf(heading) else emptyList()) + listOf(inviterLine, codeLine, question, prompt) + return NativeDialogConfirmationRequest( + title = if (hasPrefix) prefix.plainText else heading.plainText, + inviterLine = inviterLine.plainText, codeLabel = codeLabel.plainText, + code = code.displayValue(), codeRgb = code.color?.rgb, question = question.plainText, + timeoutPrompt = prompt.plainText, agree = agree.plainText, disagree = disagree.plainText, + agreeHint = agreeHint.plainText, disagreeHint = disagreeHint.plainText, + presentation = NativeDialogPresentation( + title = if (hasPrefix) prefix else heading, body = body, + confirm = agree, cancel = disagree, confirmHint = agreeHint, cancelHint = disagreeHint, + ), + ) + } + + private fun colorCode(message: PresentedMessage, code: InviteCode): PresentedMessage { + val color = code.color ?: return message + val rgb = if (audience == MessageAudience.RGB_PLAYER) color.rgb else color.nearestLegacyColor().color.rgb + return PresentedMessage(message.segments.map { if (it.variable == "code") it.copy(color = rgb) else it }) + } +} diff --git a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt index 119b812..78b2593 100644 --- a/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt +++ b/invitecode-plugin/src/main/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowController.kt @@ -41,6 +41,9 @@ import io.github.command1264.invitecode.platform.bukkit.InviteCodeRuntimeConfigu import io.github.command1264.invitecode.platform.bukkit.NativeDialogInput import io.github.command1264.invitecode.platform.bukkit.NativeDialogConfirmationRequest import io.github.command1264.invitecode.platform.bukkit.NativeDialogRequest +import io.github.command1264.invitecode.platform.bukkit.MessagePresenter +import io.github.command1264.invitecode.platform.bukkit.MessageAudience +import io.github.command1264.invitecode.platform.bukkit.PrefixPlacement import io.github.command1264.invitecode.platform.bukkit.PlatformCapabilities import io.github.command1264.invitecode.platform.bukkit.generator import io.github.command1264.invitecode.platform.bukkit.parser @@ -227,12 +230,12 @@ class PlayerWorkflowController( val player = tasks.onlinePlayer(playerId) ?: return@submit val messages = configuration.current().value.messages val locale = BukkitLocaleCompatibility.locale(player) + val layout = PlayerMessageLayouts(messages, locale, BukkitMessageOutput.audience(player)) player.spigot().sendMessage(*PlayerChatActions.codeMessage( - messages.resolve(locale, "command.code.value"), - display(code.code), + layout.code(code.code), code.code.displayValue(), - messages.resolve(locale, "command.code.copy"), - messages.resolve(locale, "command.code.select"), + layout.fragment("command.code.copy"), + layout.fragment("command.code.select"), )) }, ) @@ -274,17 +277,18 @@ class PlayerWorkflowController( val messages = runtime.messages val shown = nativeDialogInput.show( player, - NativeDialogRequest( - title = messages.resolve(locale, "command.claim.dialog-title"), - label = messages.resolve(locale, "command.claim.dialog-label"), - confirm = messages.resolve(locale, "command.claim.dialog-confirm"), - cancel = messages.resolve(locale, "command.claim.dialog-cancel"), - maximumLength = 64, - ), + PlayerMessageLayouts(messages, locale, MessageAudience.RGB_PLAYER).inputDialog(), onSubmit = { rawCode -> tasks.player(player, operation = { if (tasks.onlinePlayer(playerId) === player) { - sessions.consumeDialogInput(playerId, rawCode)?.let { beginClaim(player, it) } + when (val input = sessions.consumeDialogInputResult(playerId, rawCode)) { + is io.github.command1264.invitecode.platform.bukkit.DialogInputResult.Code -> beginClaim(player, input.value) + io.github.command1264.invitecode.platform.bukkit.DialogInputResult.Expired -> { + nativeDialogInput.cancel(player) + send(playerId, "command.claim.dialog-timeout") + } + null -> Unit + } } }) }, @@ -343,29 +347,13 @@ class PlayerWorkflowController( val currentPlayer = tasks.onlinePlayer(playerId) ?: return@submit val messages = configuration.current().value.messages val locale = BukkitLocaleCompatibility.locale(currentPlayer) + val layout = PlayerMessageLayouts(messages, locale, BukkitMessageOutput.audience(currentPlayer)) if (snapshot.value.general.claim.inputMode.resolve(capabilities) == ClaimInputChannel.DIALOG) { val confirmation = prepared.confirmation val shown = nativeDialogInput.showConfirmation( currentPlayer, - NativeDialogConfirmationRequest( - title = messages.resolve(locale, "command.claim.confirmation-title"), - inviterLine = messages.resolve( - locale, "command.claim.confirmation-inviter", - mapOf("inviter" to confirmation.inviterName), - ), - codeLabel = messages.resolve(locale, "command.claim.confirmation-code-label"), - code = confirmation.inviteCode.displayValue(), - codeRgb = confirmation.inviteCode.color?.rgb, - question = messages.resolve(locale, "command.claim.confirmation-question"), - timeoutPrompt = messages.resolve( - locale, "command.claim.confirmation-prompt", - mapOf("seconds" to snapshot.value.general.claim.confirmationTimeout.seconds.toString()), - ), - agree = messages.resolve(locale, "command.claim.agree"), - disagree = messages.resolve(locale, "command.claim.disagree"), - agreeHint = messages.resolve(locale, "command.claim.agree-hover"), - disagreeHint = messages.resolve(locale, "command.claim.disagree-hover"), - ), + layout.confirmationDialog(confirmation.inviterName, confirmation.inviteCode, + snapshot.value.general.claim.confirmationTimeout.seconds), onConfirm = { tasks.player(currentPlayer, operation = { if (tasks.onlinePlayer(playerId) === currentPlayer) confirm(currentPlayer) @@ -379,21 +367,18 @@ class PlayerWorkflowController( ) if (shown) return@submit } - messages.resolve( - locale, - "command.claim.confirmation", - mapOf( - "inviter" to prepared.confirmation.inviterName, - "code" to display(prepared.confirmation.inviteCode), - "seconds" to snapshot.value.general.claim.confirmationTimeout.seconds.toString(), - ), - ).lines().forEach(currentPlayer::sendMessage) - currentPlayer.spigot().sendMessage(*PlayerChatActions.confirmation( - messages.resolve(locale, "command.claim.agree"), - messages.resolve(locale, "command.claim.disagree"), - messages.resolve(locale, "command.claim.agree-hover"), - messages.resolve(locale, "command.claim.disagree-hover"), - )) + val confirmation = prepared.confirmation + val body = PlayerChatActions.codeMessage( + layout.chatConfirmation(confirmation.inviterName, confirmation.inviteCode, + snapshot.value.general.claim.confirmationTimeout.seconds), + confirmation.inviteCode.displayValue(), layout.fragment("command.code.copy"), + layout.fragment("command.code.select"), + ) + val actions = PlayerChatActions.confirmation( + layout.fragment("command.claim.agree"), layout.fragment("command.claim.disagree"), + layout.fragment("command.claim.agree-hover"), layout.fragment("command.claim.disagree-hover"), + ) + currentPlayer.spigot().sendMessage(*(body + net.md_5.bungee.api.chat.TextComponent("\n") + actions)) } } }, @@ -496,27 +481,20 @@ class PlayerWorkflowController( PlayerStatus( eligibility = ClaimEligibilityPolicy(snapshot.value.general.claim.window).evaluate(state, now()), state = state, - invitationStatus = store.invitationsByInvitee(playerId).firstOrNull()?.status, + invitationStatus = store.currentInviteeInvitationStatus(playerId), pendingRewards = store.pendingRewardActions(playerId).size, ) }, onSuccess = { result -> - send( - playerId, - "command.status.summary", - mapOf( - "eligible" to resolve( - playerId, - if (result.eligibility.eligible) "value.yes" else "value.no", - ), - "invitation" to resolve( - playerId, - "value.invitation.${result.invitationStatus?.name?.lowercase() ?: "none"}", - ), - "pending_rewards" to result.pendingRewards.toString(), - ), - ) - if (!result.eligibility.eligible) sendEligibility(playerId, result.eligibility) + val current = tasks.onlinePlayer(playerId) ?: return@submit + val layout = PlayerMessageLayouts(configuration.current().value.messages, + BukkitLocaleCompatibility.locale(current), BukkitMessageOutput.audience(current)) + BukkitMessageOutput.sendPresented(current, layout.status( + result.eligibility.eligible, result.invitationStatus?.name?.lowercase() ?: "none", + result.pendingRewards, result.eligibility.reasons.map { + layout.fragment("command.claim.reason.${it.name.lowercase()}").plainText + }, + )) }, ) } @@ -537,7 +515,7 @@ class PlayerWorkflowController( } private fun sendEligibility(playerId: UUID, eligibility: ClaimEligibility) { - val reasons = eligibility.reasons.joinToString("、") { + val reasons = eligibility.reasons.joinToString(resolve(playerId, "value.reason-separator")) { resolve(playerId, "command.claim.reason.${it.name.lowercase()}") } send(playerId, "command.claim.ineligible", mapOf("reasons" to reasons)) @@ -726,13 +704,11 @@ class PlayerWorkflowController( val messages = configuration.current().value.messages val environment = BukkitRewardExecutionEnvironment( plugin.server, - RewardMessageResolver { playerId, localeKey -> - val locale = this.tasks.currentPlayer(playerId)?.let(BukkitLocaleCompatibility::locale) - messages.resolve(locale, localeKey) - }, + RewardMessageResolver { _, localeKey -> localeKey }, economyGateway(), isPrimaryThread = this.tasks::isManagedThread, playerLookup = this.tasks::currentPlayer, + messageDelivery = { player, key -> BukkitMessageOutput.send(player, messages, key) }, ) tasks.forEach { task -> val actionOperations = operations.callbacksOn { callback -> @@ -787,15 +763,18 @@ class PlayerWorkflowController( val player = tasks.onlinePlayer(playerId) ?: return val messages = configuration.currentOrNull()?.value?.messages if (messages == null) { - player.sendMessage("InviteCode 設定尚未載入。") + player.sendMessage("[InviteCode] 設定尚未載入。") return } - player.sendMessage(messages.resolve(BukkitLocaleCompatibility.locale(player), key, variables)) + BukkitMessageOutput.send(player, messages, key, variables) } private fun resolve(playerId: UUID, key: String): String { val player = tasks.onlinePlayer(playerId) ?: return "[offline]" - return configuration.current().value.messages.resolve(BukkitLocaleCompatibility.locale(player), key) + return MessagePresenter(configuration.current().value.messages).render( + BukkitLocaleCompatibility.locale(player), key, audience = BukkitMessageOutput.audience(player), + prefix = PrefixPlacement.NONE, + ).plainText } private fun display(code: InviteCode): String { @@ -803,8 +782,18 @@ class PlayerWorkflowController( } private fun scheduleTimeout(player: Player, duration: Duration, operation: () -> Unit) { - val ticks = ((duration.toMillis() + 49L) / 50L).coerceAtLeast(1L) - tasks.delayPlayer(player, ticks, operation) + val deadline = now().plus(duration) + fun scheduleRemaining() { + val remaining = Duration.between(now(), deadline) + if (remaining.isNegative || remaining.isZero) { + operation() + } else { + // Server ticks need not reach the wall-clock deadline on the first callback. + val ticks = ((remaining.toMillis() + 49L) / 50L).coerceAtLeast(1L) + tasks.delayPlayer(player, ticks, ::scheduleRemaining) + } + } + scheduleRemaining() } private sealed class PreparedClaim { diff --git a/invitecode-plugin/src/main/resources/config/messages/en_US.yml b/invitecode-plugin/src/main/resources/config/messages/en_US.yml index b852f0e..dac1071 100644 --- a/invitecode-plugin/src/main/resources/config/messages/en_US.yml +++ b/invitecode-plugin/src/main/resources/config/messages/en_US.yml @@ -1,89 +1,360 @@ +# InviteCode English messages. Existing custom files are preserved; missing keys use bundled defaults. +# The renderer adds the prefix to each complete reply, not to values or UI labels. messages-version: 1 +presentation: + prefix: "&7[&6InviteCode&7]&r" runtime: - usage: "Invalid usage. Use /{label} help to see available commands." - no-permission: "You do not have permission to run this command." - player-only: "Only a player can run this command." - unavailable: "InviteCode cannot run this operation right now: {detail}" - help-header: "Available InviteCode commands:" + raw-output: "{text}" + usage: "&cInvalid command usage, so use /{label} help for instructions." + no-permission: "&cYou do not have permission to use this command." + player-only: "&eOnly a player can run this command." + unavailable: "&cThis operation is currently unavailable: {detail}" + help-header: "&6Command help" + help-row: "&e{usage} &7— &f{description}" + help-player-section: "&6Player commands" + help-admin-section: "&6Administration" + help-description: + help: "View command help" + code: "View or create your Invite Code" + claim: "Use someone else's Invite Code" + confirm: "Accept the current invitation confirmation" + cancel: "Cancel code input or confirmation" + status: "View your invitation status" + stats: "View your referral statistics" + inspect-player: "Inspect a player record" + inspect-invitation: "Inspect an invitation" + inspect-reward: "Inspect a reward action" + unlink: "Unlink an invitation" + transfer: "Transfer an invitation" + force-qualify: "Force an invitation to qualify" + reset-eligibility: "Reset a player's claim eligibility" + retry-reward: "Retry a reward action" + mark-delivered: "Mark a reward action as delivered" + rotate-code: "Rotate a player's Invite Code" + migrate-storage: "Update the storage schema" + reload: "Reload configuration and messages" + doctor: "Check runtime and storage health" + help-frame-header: "&8──── {prefix}&6{title} &8────" + help-frame-divider: "&8────────────────────────" + help-navigation-enabled: "&e[{text}]" + help-navigation-disabled: "&8[{text}]" + help-navigation-hover: "Click to open the help page" + help-home-header: "&6Common commands" + help-console-home-header: "&6Common administration commands" + help-console-navigation-title: "Administration help topics" + help-page-header: "&6{topic} &7— Page {page}/{pages}" + help-topic: + console: "Console" + player: "Player" + admin: "Administration" + inspect: "Inspection" + invitation: "Invitations" + eligibility: "Claim eligibility" + reward: "Reward handling" + code: "Invite Codes" + storage: "Storage maintenance" + reload: "Configuration reload" + doctor: "Health check" + help-topic-description: + inspect: "Read-only details for players, Invitations, or Reward Actions." + invitation: |- + Unlink or transfer an Invitation + Changes are audited. + eligibility: |- + Manage claim eligibility + Reset advances its generation and keeps history. + reward: |- + Inspect or resolve UNCERTAIN Reward Actions + Check external delivery first. + code: |- + Rotate a player's Invite Code + The old code is retired and a new one is issued. + storage: |- + Maintain the current storage backend's schema + This does not move data. + reload: |- + Validate and apply configuration and messages + Storage cutover uses its own procedure. + doctor: "Read-only checks for runtime, integrations, and storage health." + help-previous: "&ePrevious" + help-next: "&eNext" + help-back: "&eBack" + help-open-detail: "Click to view command details" + help-page-error: "&cThat page or topic was not found, so use /ic help to return to common commands." + help-detail: + help: |- + &7Opens the player-command index + &7use /ic help admin [page], then a category and operation for management details. + &7Usage: &f{usage} + &7Example: &f{example} + code: |- + &7Views or creates your Invite Code + &7takes no arguments. Creating one makes you an inviter, so you cannot claim another code. + &7Usage: &f{usage} + &7Example: &f{example} + claim: |- + &7The code is optional + &7omitting it opens the configured input flow. A valid code starts a timed confirmation + &7only confirmation creates the Invitation. + &7Usage: &f{usage} + &7Example: &f{example} + confirm: |- + &7Takes no arguments. Accepts only a pending, unexpired confirmation and then creates the Invitation. + &7Usage: &f{usage} + &7Example: &f{example} + cancel: |- + &7Takes no arguments. Cancels active code input or confirmation + &7it does not create an Invitation. + &7Usage: &f{usage} + &7Example: &f{example} + status: |- + &7Takes no arguments. Shows claim eligibility, the latest recorded Invitation status, and pending reward count. Historical Invitations may still appear. + &7Usage: &f{usage} + &7Example: &f{example} + stats: |- + &7Takes no arguments. Shows Invitations awaiting qualification and those already qualified + &7historical qualified Invitations remain included. + &7Usage: &f{usage} + &7Example: &f{example} + inspect-player: |- + &7Use a player UUID or unique known name + &7unknown or ambiguous names are rejected. This query does not change data. + &7Usage: &f{usage} + &7Example: &f{example} + inspect-invitation: |- + &7Use an Invitation UUID, not a player UUID. Shows its status, qualification facts, and delivery records without changing data. + &7Usage: &f{usage} + &7Example: &f{example} + inspect-reward: |- + &7Use a Reward Action UUID, not a Reward Delivery ID. A Delivery records a reward to deliver + &7an Action tracks execution status. This query does not execute rewards. + &7Usage: &f{usage} + &7Example: &f{example} + unlink: |- + &7Requires an Invitation UUID and a non-empty reason, which may contain spaces. Marks that row UNLINKED and audits the change + &7history and rewards are retained. + &7Usage: &f{usage} + &7Example: &f{example} + transfer: |- + &7Requires an Invitation UUID, new inviter reference, and non-empty reason, which may contain spaces. Only CLAIMED Invitations can be transferred + &7the change is audited. + &7Usage: &f{usage} + &7Example: &f{example} + force-qualify: |- + &7Requires an Invitation UUID, configured qualification Policy ID, and non-empty reason, which may contain spaces. Only CLAIMED Invitations are accepted + &7conditions are bypassed and Reward Delivery/Action records are created, not delivered automatically. + &7Usage: &f{usage} + &7Example: &f{example} + reset-eligibility: |- + &7Requires a player reference and non-empty reason, which may contain spaces. Resets first-seen time and advances the eligibility generation + &7history is kept and other eligibility rules still apply. + &7Usage: &f{usage} + &7Example: &f{example} + retry-reward: |- + &7Requires a Reward Action UUID (not a Delivery ID) and non-empty reason, which may contain spaces. Only UNCERTAIN actions are accepted + &7check external results first because retrying may duplicate an effect. + &7Usage: &f{usage} + &7Example: &f{example} + mark-delivered: |- + &7Requires a Reward Action UUID and non-empty reason, which may contain spaces. Only UNCERTAIN actions are accepted + &7this does not execute the reward and should follow verification that the external effect occurred. + &7Usage: &f{usage} + &7Example: &f{example} + rotate-code: |- + &7Requires a player reference and non-empty reason, which may contain spaces. Retires that player's old Invite Code and creates a new one + &7existing Invitations remain. + &7Usage: &f{usage} + &7Example: &f{example} + migrate-storage: |- + &7Requires SQLITE or MYSQL and a non-empty reason, which may contain spaces + &7the target must match the configured backend. This updates schema and does not move data between backends. + &7Usage: &f{usage} + &7Example: &f{example} + reload: |- + &7Takes no arguments. Validates and applies configuration and messages. Changes to storage.yml backend are not applied here + &7admin reload is a compatibility alias. + &7Usage: &f{usage} + &7Example: &f{example} + doctor: |- + &7Takes no arguments. Read-only checks runtime, integrations, and storage health + &7it does not create a database or run a migration. + &7Usage: &f{usage} + &7Example: &f{example} command: code: - value: "Your Invite Code is {code}" + value: "&fYour Invite Code: {code}" copy: "Click to copy to clipboard" - select: "Click to insert the Invite Code into chat, then copy it" + select: "Click to insert into chat, then copy manually" claim: - command-only: "Use /invitecode claim ." - chat-started: "Enter the Invite Code in chat within {seconds} seconds. It will not be published. Type cancel to stop." - chat-timeout: "Invite Code chat input expired. Run /invitecode claim again." + command-only: "&fUse /invitecode claim ." + chat-started: |- + &fEnter the Invite Code in chat within {seconds} seconds. It will not be public. + &7Type cancel to stop. + chat-timeout: "&cCode input expired, so run /invitecode claim again." dialog-title: "Enter Invite Code" - dialog-label: "Six-character Invite Code" + dialog-label: "Invite code" dialog-confirm: "Continue" dialog-cancel: "Cancel" - dialog-timeout: "Invite Code dialog input expired. Run /invitecode claim again." - invalid-code: "The Invite Code format is invalid. Check it and try again." - unavailable: "That Invite Code does not exist, was rotated, or is no longer active." - self: "You cannot use your own Invite Code." - confirmation: "Inviter: {inviter}\nInvite Code: {code}\nUse this Invite Code?\nChoose within {seconds} seconds" + dialog-timeout: "&cCode input expired, so run /invitecode claim again." + invalid-code: "&cThe Invite Code format is invalid, so check it and enter the code again." + unavailable: "&cThis Invite Code does not exist or is no longer active, so ask the inviter for their current code." + self: "&cYou cannot use your own Invite Code." + # The renderer adds the prefix as line 1 and the action buttons as line 7. + confirmation: |- + &fConfirm Invite Code + &7Inviter: &f{inviter} + &7Invite Code: {code} + &fUse this Invite Code? + &7Choose within {seconds} seconds confirmation-title: "Confirm Invite Code" - confirmation-inviter: "Inviter: {inviter}" - confirmation-code-label: "Invite Code: " + confirmation-inviter: "&7Inviter: &f{inviter}" + confirmation-code-label: "&7Invite Code: " confirmation-question: "Use this Invite Code?" - confirmation-prompt: "Choose within {seconds} seconds" - agree: "Agree" - disagree: "Disagree" + confirmation-prompt: "&7Choose within {seconds} seconds" + agree: "&aAgree" + disagree: "&cDisagree" agree-hover: "Click to agree and use this Invite Code" disagree-hover: "Click to disagree and cancel" - confirmation-timeout: "The Claim Confirmation expired. Enter the Invite Code again." - no-confirmation: "There is no Claim to confirm, or it has expired." - claimed: "The Invitation has been created." - matching-network-warning: "You and the inviter recently used the same network. This Claim was allowed but may be reviewed by an administrator." - matching-network-denied: "You and the inviter recently used the same network, so this Claim was denied." - ineligible: "You cannot use an Invite Code right now. Reasons: {reasons}." + confirmation-timeout: "&cInvitation confirmation expired, so run /invitecode claim again." + no-confirmation: "&cThere is no invitation to confirm, or it has expired, so run /invitecode claim again." + claimed: |- + &aYour invitation has been registered. + &7View your status: /ic status + matching-network-warning: "&eYou and the inviter recently used the same network. This claim was allowed but may be reviewed by an administrator." + matching-network-denied: "&cServer rules prevent this claim because you and the inviter recently used the same network, so contact an administrator if you need help." + ineligible: "&cYou cannot use an Invite Code: {reasons}." reason: - already_inviter: "you are already an Inviter" - already_invitee: "you already have an Invitation" - claim_window_expired: "the Claim Window has expired" - cancelled: "The current Invite Code input or confirmation was cancelled." - nothing-to-cancel: "There is no Invite Code input or confirmation to cancel." + already_inviter: "you have already created your own Invite Code" + already_invitee: "you already have an invitation" + claim_window_expired: "the claim period has ended" + cancelled: "&fInvite Code input or confirmation cancelled." + nothing-to-cancel: "&7There is no active Invite Code input or confirmation." status: - summary: "Invitation status: eligible={eligible}, Invitation={invitation}, pending Rewards={pending_rewards}." + ineligible-reason: "&7Cannot register: &f{reasons}" + summary: |- + &fMy invitation status + &7Can use an Invite Code: &f{eligible} + &7Invitation: &f{invitation} + &7Pending rewards: &f{pending_rewards} stats: - summary: "Your Invitation stats: awaiting qualification={claimed}, qualified={qualified}." - error: "The operation failed. Check the server log or contact an administrator." - stopping: "InviteCode is stopping and cannot accept new operations." + summary: |- + &fMy referral statistics + &7Awaiting qualification: &f{claimed} + &7Qualified: &f{qualified} + error: "&cThe operation failed, so contact an administrator to check the server log." + stopping: "&cThe plugin is stopping and cannot accept operations, so try again later." value: + reason-separator: ", " 'yes': "yes" 'no': "no" invitation: - none: "none" + none: "not registered" claimed: "awaiting qualification" qualified: "qualified" unlinked: "unlinked" admin: - invitation-unlinked: "Invitation {invitation} was unlinked." - invitation-transferred: "Invitation {invitation} was transferred to {inviter}." - invitation-force-qualified: "Invitation {invitation} was force-qualified and {rewards} Reward Deliveries were created." - eligibility-reset: "Claim Eligibility was reset for player {player}." - reward-resolved: "Reward Action {action} was resolved as {status}." - code-rotated: "Player {player}'s Invite Code was rotated from {previous} to {current}." - error: "The administrative operation failed. Check the server log." - stopping: "InviteCode is stopping and cannot accept administrative operations." - reload-stopping: "InviteCode is stopping and cannot reload configuration." - reload-success: "InviteCode validated and applied the complete configuration snapshot." - reload-storage-restart: "storage.yml changes were not applied. Complete an explicit cutover and restart." - reload-failed: "Configuration validation failed. The previous snapshot remains active; check the server log." - storage-unsupported: "The migration target must match the configured SQLITE or MYSQL backend." - storage-config-unavailable: "Configuration is not loaded, so the storage location is unavailable." - storage-stopping: "InviteCode is stopping and cannot run the migration." - storage-success: "Storage schema migration completed at version {version}." - storage-failed: "Storage schema migration failed. Check the server log." - doctor-runtime: "Runtime={phase}, configuration generation={generation}, executor={executor}." - doctor-integrations: "Integrations: PlaceholderAPI={placeholder}, Vault Economy={vault}, Dialog={dialog}, RGB={rgb}." - doctor-maintenance: "Maintenance reason: {reason}" - doctor-storage-offline: "Storage is offline. Doctor did not create or modify data." - doctor-storage: "{backend} storage version={schema}; Reward backlog: PENDING={pending}, PROCESSING={processing}, UNCERTAIN={uncertain}." - doctor-storage-failed: "The storage health check failed. Check the server log." - doctor-executor-stopping: "The executor is stopping and cannot query the Reward backlog." + inspect-player-title: "&6Player record" + inspect-invitation-title: "&6Invitation record" + inspect-reward-title: "&6Reward Action record" + inspect-player: |- + &fPlayer: {player} + &7Name: {name} + &7First seen: {first_seen} + &7Is inviter: {inviter} + &7Has invitation: {invitee} + &7Invite Code: {code} + &7Awaiting qualification: {claimed} + &7Qualified: {qualified} + &7Audit: {audit} + inspect-invitation: |- + &fInvitation: {invitation} + &7Status: {status} + &7Inviter: {inviter} + &7Invitee: {invitee} + &7Claimed at: {claimed_at} + &7Qualification facts: {facts} + &7Rewards: {rewards} + &7Audit: {audit} + inspect-reward: |- + &fReward Action: {action} + &7Delivery: {delivery} + &7Status: {status} + &7Recipient: {recipient} + &7Type: {type} + &7Updated at: {updated_at} + &7Last error: {last_error} + &7Transitions: {transitions} + invitation-unlinked: "&aInvitation {invitation} unlinked." + invitation-transferred: "&aInvitation {invitation} transferred to inviter {inviter}." + invitation-force-qualified: |- + &aInvitation {invitation} marked as qualified + {rewards} reward delivery records created. + eligibility-reset: "&aClaim eligibility reset for player {player}." + reward-resolved: "&aReward action {action} resolved as {status}." + code-rotated: "&aPlayer {player}'s Invite Code rotated from {previous} to {current}." + error: "&cThe administrative operation failed, so check the server log." + stopping: "&eThe plugin is stopping and cannot accept administrative operations." + reload-stopping: "&eThe plugin is stopping and cannot reload configuration." + reload-success: "&aConfiguration and messages validated and applied." + reload-storage-restart: "&estorage.yml changes were not applied. &fFollow the storage cutover procedure, then restart the server." + reload-failed: "&cReload failed while the previous configuration remains active, so check the server log and fix the configuration." + storage-unsupported: "&cThe migration target must match the configured SQLITE or MYSQL storage backend." + storage-config-unavailable: "&cBecause configuration is not loaded, the storage location is unknown, so check the server log." + storage-stopping: "&eThe plugin is stopping and cannot update the storage schema." + storage-success: "&aStorage schema updated to version {version}." + storage-failed: "&cStorage schema update failed, so check the server log." + doctor-runtime: |- + &fRuntime: {phase} + &fConfiguration generation: {generation} + &fBackground tasks: {executor} + doctor-integrations: |- + &fPlaceholderAPI: {placeholder} + &fVault economy service: {vault} + &fNative dialog: {dialog} + &fRGB colors: {rgb} + doctor-maintenance: "&eMaintenance reason: {reason}" + doctor-storage-offline: "&eStorage is offline. This check did not create or modify data." + doctor-storage: |- + &fStorage backend: {backend} + &fSchema: {schema} + &fPending rewards: {pending} + &fProcessing rewards: {processing} + &fAwaiting result confirmation: {uncertain} + doctor-storage-failed: "&cThe storage health check failed, so check the server log." + doctor-executor-stopping: "&eThe executor is stopping and cannot query pending reward actions." + doctor-value: + phase: + active: "&aActive" + starting: "&eStarting" + maintenance: "&6Maintenance" + stopping: "&eStopping" + stopped: "&7Stopped" + executor: + accepting: "&aAccepting new work" + stopped: "&7Not accepting new work" + enabled: + 'true': "&aEnabled" + 'false': "&cNot enabled" + available: + 'true': "&aAvailable" + 'false': "&cUnavailable" + supported: + 'true': "&aSupported" + 'false': "&cNot supported" + dialog: + paper: "&fPaper" + none: "&7No native interface" + backend: + sqlite: "&fSQLite" + mysql: "&fMySQL" + json: "&fJSON" + count: + zero: "&7{value}" + pending: "&e{value}" + processing: "&b{value}" + uncertain: "&6{value}" + unknown: "&7Unknown ({value})" invite: qualified: - inviter: "Your invitation has qualified." - invitee: "You have qualified as an invitee." + inviter: "&aA player you invited has qualified." + invitee: "&aYou have met the invitation qualification requirements." diff --git a/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml b/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml index fd53733..a16a121 100644 --- a/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml +++ b/invitecode-plugin/src/main/resources/config/messages/zh_TW.yml @@ -1,89 +1,366 @@ +# InviteCode 繁體中文訊息;既有自訂檔不會自動覆寫,缺鍵使用內建備援。 +# prefix 自動套用;值、欄位、hover 與按鈕不各自加 prefix。 messages-version: 1 +presentation: + prefix: "&7[&6InviteCode&7]&r" runtime: - usage: "用法錯誤。請使用 /{label} help 查看可用指令。" - no-permission: "你沒有執行此指令的權限。" - player-only: "此指令只能由玩家執行。" - unavailable: "InviteCode 目前無法執行此操作:{detail}" - help-header: "InviteCode 可用指令:" + raw-output: "{text}" + usage: "&c指令用法不正確,請使用 /{label} help 查看說明。" + no-permission: "&c你沒有使用此指令的權限。" + player-only: "&e此指令只能由玩家執行。" + unavailable: "&c目前無法執行此操作:{detail}" + help-header: "&6指令說明" + help-row: "&e{usage} &7— &f{description}" + help-player-section: "&6玩家操作" + help-admin-section: "&6管理操作" + help-description: + help: "查看指令說明" + code: "查看或建立自己的邀請碼" + claim: "使用別人的邀請碼" + confirm: "同意目前的邀請確認" + cancel: "取消輸入或確認" + status: "查看自己的邀請狀態" + stats: "查看自己的邀請統計" + inspect-player: "查詢玩家紀錄" + inspect-invitation: "查詢邀請關係" + inspect-reward: "查詢獎勵動作" + unlink: "解除邀請關係" + transfer: "轉移邀請關係" + force-qualify: "強制達成邀請資格" + reset-eligibility: "重設玩家登記資格" + retry-reward: "重試獎勵動作" + mark-delivered: "標記獎勵動作已交付" + rotate-code: "輪替玩家邀請碼" + migrate-storage: "更新儲存結構版本" + reload: "重新載入設定與訊息" + doctor: "檢查執行狀態與儲存健康" + help-frame-header: "&8──── {prefix}&6{title} &8────" + help-frame-divider: "&8────────────────────────" + help-navigation-enabled: "&e[{text}]" + help-navigation-disabled: "&8[{text}]" + help-navigation-hover: "點擊切換說明頁" + help-home-header: "&6常用指令" + help-console-home-header: "&6管理員常用指令" + help-console-navigation-title: "管理員說明分類" + help-page-header: "&6{topic} &7— 第 {page}/{pages} 頁" + help-topic: + console: "主控台" + player: "玩家" + admin: "管理員" + inspect: "資料查詢" + invitation: "邀請關係" + eligibility: "登記資格" + reward: "獎勵處理" + code: "邀請碼" + storage: "儲存維護" + reload: "設定重新載入" + doctor: "健康檢查" + help-topic-description: + inspect: "唯讀查詢玩家、Invitation 或 Reward Action 的資料。" + invitation: |- + 解除或轉移邀請關係 + 變更會留下稽核紀錄。 + eligibility: |- + 管理登記資格 + 重設會推進世代,不刪除歷史資料。 + reward: |- + 檢查或處理 UNCERTAIN Reward Action + 先核對外部交付結果。 + code: |- + 輪替玩家邀請碼 + 舊碼停用並建立新碼。 + storage: |- + 維護目前儲存 backend 的結構 + 不搬移 backend。 + reload: |- + 驗證並套用設定與訊息 + 儲存切換仍須依維護流程處理。 + doctor: "唯讀檢查執行階段、整合與儲存健康。" + help-previous: "&e上一頁" + help-next: "&e下一頁" + help-back: "&e返回" + help-open-detail: "點擊查看指令詳細說明" + help-page-error: "&c找不到此頁面或主題,請使用 /ic help 返回常用指令。" + help-detail: + help: |- + &7查看玩家指令索引 + &7管理說明使用 /ic help admin [頁碼],再接分類與操作名稱。 + &7用法:&f{usage} + &7範例:&f{example} + code: |- + &7查看或首次建立自己的邀請碼 + &7不需參數。建立後即成為邀請人,不能再使用他人邀請碼。 + &7用法:&f{usage} + &7範例:&f{example} + claim: |- + &7邀請碼為選填 + &7省略時依輸入模式開啟輸入。驗證後會進入限時確認,只有確認才建立邀請關係。 + &7用法:&f{usage} + &7範例:&f{example} + confirm: |- + &7不需參數 + &7只會接受尚未逾時的待確認邀請,並建立邀請關係。 + &7用法:&f{usage} + &7範例:&f{example} + cancel: |- + &7不需參數 + &7取消目前的邀請碼輸入或待確認流程,不會建立邀請關係。 + &7用法:&f{usage} + &7範例:&f{example} + status: |- + &7不需參數 + &7查看登記資格、最近的邀請狀態與待補發獎勵數量。歷史 Invitation 仍可能顯示。 + &7用法:&f{usage} + &7範例:&f{example} + stats: |- + &7不需參數 + &7查看等待達成資格與已達成資格的邀請統計。歷史上已達成資格的 Invitation 仍會計入。 + &7用法:&f{usage} + &7範例:&f{example} + inspect-player: |- + &7玩家參照須為 UUID 或唯一的已知名稱 + &7未知或重複名稱會拒絕。此查詢不修改資料。 + &7用法:&f{usage} + &7範例:&f{example} + inspect-invitation: |- + &7參數是 Invitation UUID,不是玩家 UUID + &7查詢邀請狀態、資格事實與交付紀錄,不修改資料。 + &7用法:&f{usage} + &7範例:&f{example} + inspect-reward: |- + &7使用 Reward Action UUID,不是 Reward Delivery ID + &7Delivery 記錄應交付項目,Action 記錄執行狀態。此查詢不執行獎勵。 + &7用法:&f{usage} + &7範例:&f{example} + unlink: |- + &7需要 Invitation UUID 與非空原因(可含空格) + &7將該列標記為 UNLINKED 並留下稽核,不刪除歷史或獎勵紀錄。 + &7用法:&f{usage} + &7範例:&f{example} + transfer: |- + &7需要 Invitation UUID、新邀請人參照及非空原因(可含空格) + &7只可轉移 CLAIMED 邀請,並留下稽核紀錄。 + &7用法:&f{usage} + &7範例:&f{example} + force-qualify: |- + &7需要 Invitation UUID、已設定的資格 Policy ID 與非空原因(可含空格) + &7只接受 CLAIMED 邀請,略過條件檢查並建立 Reward Delivery/Action,不代表已送達。 + &7用法:&f{usage} + &7範例:&f{example} + reset-eligibility: |- + &7需要玩家參照與非空原因(可含空格) + &7更新首次記錄時間並推進資格世代,不刪除 Invitation、Reward 或已交付紀錄,也不保證符合其他登記條件。 + &7用法:&f{usage} + &7範例:&f{example} + retry-reward: |- + &7需要 Reward Action UUID(不是 Delivery ID)與非空原因(可含空格) + &7只接受 UNCERTAIN 動作。先查明外部結果,重試可能造成重複效果。 + &7用法:&f{usage} + &7範例:&f{example} + mark-delivered: |- + &7需要 Reward Action UUID 與非空原因(可含空格) + &7只接受 UNCERTAIN 動作。此操作不執行獎勵,僅在確認外部效果已發生後標記已交付。 + &7用法:&f{usage} + &7範例:&f{example} + rotate-code: |- + &7需要玩家參照與非空原因(可含空格) + &7停用該玩家舊邀請碼並建立新碼,不會刪除既有邀請關係。 + &7用法:&f{usage} + &7範例:&f{example} + migrate-storage: |- + &7需要 SQLITE 或 MYSQL 及非空原因(可含空格) + &7目標須與目前 backend 相同。此操作更新結構,不搬移資料到另一個 backend。 + &7用法:&f{usage} + &7範例:&f{example} + reload: |- + &7不需參數 + &7驗證並套用設定與訊息。storage.yml 的 backend 變更不會在此套用 + &7admin reload 為相容別名。 + &7用法:&f{usage} + &7範例:&f{example} + doctor: |- + &7不需參數 + &7唯讀檢查執行狀態、整合與儲存健康,不建立資料庫或執行 migration。 + &7用法:&f{usage} + &7範例:&f{example} command: code: - value: "你的邀請碼是 {code}" + value: "&f你的邀請碼:{code}" copy: "點擊複製到剪貼簿" - select: "點擊將邀請碼填入聊天列,再手動複製" + select: "點擊填入聊天列,再手動複製" claim: - command-only: "請使用 /invitecode claim <邀請碼>。" - chat-started: "請在 {seconds} 秒內於聊天輸入邀請碼;內容不會公開。輸入 cancel 可取消。" - chat-timeout: "邀請碼聊天輸入已逾時,請重新執行 /invitecode claim。" - dialog-title: "輸入 Invite Code" - dialog-label: "六位 Invite Code" + command-only: "&f請使用 /invitecode claim <邀請碼>。" + chat-started: |- + &f請在 {seconds} 秒內於聊天輸入邀請碼,內容不會公開。 + &7輸入 cancel 可取消。 + chat-timeout: "&c邀請碼輸入已逾時,請重新執行 /invitecode claim。" + dialog-title: "輸入邀請碼" + dialog-label: "邀請碼" dialog-confirm: "繼續" dialog-cancel: "取消" - dialog-timeout: "Invite Code 輸入框已逾時,請重新執行 /invitecode claim。" - invalid-code: "邀請碼格式無效,請檢查後再試一次。" - unavailable: "此邀請碼不存在、已輪替或已失效。" - self: "你不能使用自己的邀請碼。" - confirmation: "邀請人:{inviter}\n邀請碼:{code}\n是否使用這組邀請碼?\n請在 {seconds} 秒內選擇" + dialog-timeout: "&c邀請碼輸入已逾時,請重新執行 /invitecode claim。" + invalid-code: "&c邀請碼格式不正確,請檢查後重新輸入。" + unavailable: "&c這組邀請碼不存在或已失效,請向邀請人確認目前的邀請碼。" + self: "&c你不能使用自己的邀請碼。" + # 聊天 renderer 先單獨輸出 prefix,下列為第 2–6 行;互動按鈕為第 7 行。 + # Dialog 以 prefix 為標題,其他欄位使用等價內容。 + confirmation: |- + &f確認邀請碼 + &7邀請人:&f{inviter} + &7邀請碼:{code} + &f是否使用這組邀請碼? + &7請在 {seconds} 秒內選擇 confirmation-title: "確認邀請碼" - confirmation-inviter: "邀請人:{inviter}" - confirmation-code-label: "邀請碼:" + confirmation-inviter: "&7邀請人:&f{inviter}" + confirmation-code-label: "&7邀請碼:" confirmation-question: "是否使用這組邀請碼?" - confirmation-prompt: "請在 {seconds} 秒內選擇" - agree: "同意" - disagree: "不同意" + confirmation-prompt: "&7請在 {seconds} 秒內選擇" + agree: "&a同意" + disagree: "&c不同意" agree-hover: "點擊同意並使用邀請碼" disagree-hover: "點擊不同意並取消" - confirmation-timeout: "邀請確認已逾時,請重新輸入邀請碼。" - no-confirmation: "沒有可確認的邀請,或確認已逾時。" - claimed: "邀請關係已建立。" - matching-network-warning: "系統偵測到你與邀請人近期使用相同網路;本次登記已允許,但可能交由管理員檢查。" - matching-network-denied: "系統偵測到你與邀請人近期使用相同網路,因此拒絕本次登記。" - ineligible: "目前無法使用邀請碼,原因:{reasons}。" + confirmation-timeout: "&c邀請確認已逾時,請重新執行 /invitecode claim。" + no-confirmation: "&c目前沒有可確認的邀請,或確認已逾時,請重新執行 /invitecode claim。" + claimed: |- + &a邀請關係已建立。 + &7查看目前狀態:/ic status + matching-network-warning: "&e你與邀請人近期使用相同網路。本次登記已允許,但可能由管理員檢查。" + matching-network-denied: "&c你與邀請人近期使用相同網路,依伺服器規則無法登記,如需協助請聯絡管理員。" + ineligible: "&c目前無法使用邀請碼:{reasons}。" reason: - already_inviter: "你已成為邀請人" + already_inviter: "你已建立自己的邀請碼" already_invitee: "你已有邀請關係" claim_window_expired: "可登記期間已結束" - cancelled: "已取消目前的邀請碼輸入或確認。" - nothing-to-cancel: "目前沒有可取消的邀請碼輸入或確認。" + cancelled: "&f已取消邀請碼輸入或確認。" + nothing-to-cancel: "&7目前沒有進行中的邀請碼輸入或確認。" status: - summary: "邀請狀態:可使用邀請碼={eligible}、Invitation={invitation}、待補發獎勵={pending_rewards}。" + ineligible-reason: "&7無法登記原因:&f{reasons}" + summary: |- + &f我的邀請狀態 + &7可使用邀請碼:&f{eligible} + &7邀請關係:&f{invitation} + &7待補發獎勵:&f{pending_rewards} 筆 stats: - summary: "你的邀請統計:等待資格={claimed}、已達資格={qualified}。" - error: "操作失敗,請查看伺服器紀錄或聯絡管理員。" - stopping: "InviteCode 正在停止,暫時不接受新操作。" + summary: |- + &f我的邀請統計 + &7等待達成資格:&f{claimed} 人 + &7已達成資格:&f{qualified} 人 + error: "&c操作失敗,請聯絡管理員檢查伺服器紀錄。" + stopping: "&c插件正在停止,暫時無法操作,請稍後再試。" value: + reason-separator: "、" 'yes': "是" 'no': "否" invitation: - none: "無" - claimed: "等待資格" - qualified: "已達資格" + none: "尚未登記" + claimed: "等待達成資格" + qualified: "已達成資格" unlinked: "已解除連結" admin: - invitation-unlinked: "Invitation {invitation} 已解除連結。" - invitation-transferred: "Invitation {invitation} 已轉移至 {inviter}。" - invitation-force-qualified: "Invitation {invitation} 已強制達成資格,並建立 {rewards} 筆 Reward Delivery。" - eligibility-reset: "玩家 {player} 的 Claim Eligibility 已重設。" - reward-resolved: "Reward Action {action} 已處理為 {status}。" - code-rotated: "玩家 {player} 的邀請碼已從 {previous} 輪替為 {current}。" - error: "管理操作失敗,請查看伺服器紀錄。" - stopping: "InviteCode 正在停止,無法接受管理操作。" - reload-stopping: "InviteCode 正在停止,無法重新載入設定。" - reload-success: "InviteCode 設定已完整驗證並套用。" - reload-storage-restart: "storage.yml 的變更尚未套用;請完成明確 cutover 並重新啟動。" - reload-failed: "設定驗證失敗,仍保留上一份有效設定;請查看伺服器紀錄。" - storage-unsupported: "遷移目標必須與目前設定的 SQLITE 或 MYSQL backend 相同。" - storage-config-unavailable: "設定尚未成功載入,無法判定儲存位置。" - storage-stopping: "InviteCode 正在停止,無法執行 migration。" - storage-success: "Storage schema migration 已完成,目前版本為 {version}。" - storage-failed: "Storage schema migration 失敗,請查看伺服器紀錄。" - doctor-runtime: "Runtime={phase},設定世代={generation},executor={executor}。" - doctor-integrations: "Integration:PlaceholderAPI={placeholder},Vault Economy={vault},Dialog={dialog},RGB={rgb}。" - doctor-maintenance: "維護原因:{reason}" - doctor-storage-offline: "儲存未連線;doctor 未建立或修改資料。" - doctor-storage: "{backend} 儲存版本={schema};Reward backlog:PENDING={pending},PROCESSING={processing},UNCERTAIN={uncertain}。" - doctor-storage-failed: "儲存健康檢查失敗,請查看伺服器紀錄。" - doctor-executor-stopping: "Executor 正在停止,無法完成 Reward backlog 查詢。" + inspect-player-title: "&6玩家紀錄" + inspect-invitation-title: "&6邀請紀錄" + inspect-reward-title: "&6獎勵動作紀錄" + inspect-player: |- + &f玩家:{player} + &7名稱:{name} + &7首次記錄:{first_seen} + &7是否為邀請人:{inviter} + &7是否已有邀請登記:{invitee} + &7邀請碼:{code} + &7等待資格:{claimed} + &7已達成資格:{qualified} + &7稽核紀錄:{audit} + inspect-invitation: |- + &f邀請關係:{invitation} + &7狀態:{status} + &7邀請人:{inviter} + &7邀請對象:{invitee} + &7建立時間:{claimed_at} + &7資格事實:{facts} + &7獎勵:{rewards} + &7稽核紀錄:{audit} + inspect-reward: |- + &f獎勵動作:{action} + &7交付紀錄:{delivery} + &7狀態:{status} + &7接收者:{recipient} + &7類型:{type} + &7更新時間:{updated_at} + &7最近錯誤:{last_error} + &7狀態轉換:{transitions} + invitation-unlinked: "&a已解除邀請關係 {invitation}。" + invitation-transferred: "&a已將邀請關係 {invitation} 轉移至邀請人 {inviter}。" + invitation-force-qualified: |- + &a已將邀請關係 {invitation} 設為達成資格 + 並建立 {rewards} 筆獎勵交付紀錄。 + eligibility-reset: "&a已重設玩家 {player} 的邀請碼登記資格。" + reward-resolved: "&a已將獎勵動作 {action} 處理為 {status}。" + code-rotated: "&a玩家 {player} 的邀請碼已由 {previous} 輪替為 {current}。" + error: "&c管理操作失敗,請檢查伺服器紀錄。" + stopping: "&e插件正在停止,無法執行管理操作。" + reload-stopping: "&e插件正在停止,無法重新載入設定。" + reload-success: "&a設定與訊息已通過驗證並套用。" + reload-storage-restart: "&estorage.yml 的變更尚未套用。&f請依儲存切換流程操作,再重新啟動伺服器。" + reload-failed: "&c重新載入失敗,仍使用上一份有效設定,請檢查伺服器紀錄並修正設定。" + storage-unsupported: "&c遷移目標必須與目前設定的 SQLITE 或 MYSQL 儲存類型相同。" + storage-config-unavailable: "&c設定尚未成功載入,無法判定儲存位置,請檢查伺服器紀錄。" + storage-stopping: "&e插件正在停止,無法更新儲存結構。" + storage-success: "&a儲存結構更新完成,目前版本為 {version}。" + storage-failed: "&c儲存結構更新失敗,請檢查伺服器紀錄。" + doctor-runtime: |- + &f執行階段:{phase} + &f設定世代:{generation} + &f背景工作:{executor} + doctor-integrations: |- + &fPlaceholderAPI:{placeholder} + &fVault 經濟服務:{vault} + &f原生對話框:{dialog} + &fRGB 色彩:{rgb} + doctor-maintenance: "&e維護原因:{reason}" + doctor-storage-offline: |- + &e儲存尚未連線 + &f本次檢查未建立或修改資料。 + doctor-storage: |- + &f儲存類型:{backend} + &f結構版本:{schema} + &f待執行獎勵:{pending} + &f執行中獎勵:{processing} + &f結果待確認:{uncertain} + doctor-storage-failed: "&c儲存健康檢查失敗,請檢查伺服器紀錄。" + doctor-executor-stopping: "&e背景工作正在停止,無法查詢待處理的獎勵動作。" + doctor-value: + phase: + active: "&a運作中" + starting: "&e啟動中" + maintenance: "&6維護中" + stopping: "&e停止中" + stopped: "&7已停止" + executor: + accepting: "&a接受新工作" + stopped: "&7不接受新工作" + enabled: + 'true': "&a已啟用" + 'false': "&c未啟用" + available: + 'true': "&a可用" + 'false': "&c不可用" + supported: + 'true': "&a支援" + 'false': "&c不支援" + dialog: + paper: "&fPaper" + none: "&7無原生介面" + backend: + sqlite: "&fSQLite" + mysql: "&fMySQL" + json: "&fJSON" + count: + zero: "&7{value}" + pending: "&e{value}" + processing: "&b{value}" + uncertain: "&6{value}" + unknown: "&7未知({value})" invite: qualified: - inviter: "你的邀請已達成資格。" - invitee: "你已達成邀請資格。" + inviter: "&a你邀請的玩家已達成資格。" + invitee: "&a你已達成邀請資格。" diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoaderTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoaderTest.kt index 4a3bc2a..675d9d3 100644 --- a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoaderTest.kt +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitConfigurationLoaderTest.kt @@ -12,6 +12,45 @@ class BukkitConfigurationLoaderTest { @TempDir lateinit var dataDirectory: Path + @Test + fun `load restores missing bundled configuration and message catalogs from jar resources`() { + val configuration = BukkitConfigurationLoader(dataDirectory) {}.load() + + assertEquals(1, configuration.general.version) + assertEquals("是", configuration.messages.resolve("zh_TW", "value.yes")) + assertEquals("yes", configuration.messages.resolve("en_US", "value.yes")) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("config.yml"))) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("storage.yml"))) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("qualifications.yml"))) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("rewards.yml"))) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("messages/zh_TW.yml"))) + assertEquals(true, Files.isRegularFile(dataDirectory.resolve("messages/en_US.yml"))) + } + + @Test + fun `load fills missing message keys from bundled catalogs without replacing existing files`() { + BundledConfigurationInstaller(dataDirectory) { resourcePath -> + javaClass.classLoader.getResourceAsStream(resourcePath) + }.installMissing() + val config = dataDirectory.resolve("config.yml") + val configBefore = String(Files.readAllBytes(config), StandardCharsets.UTF_8) + val catalog = dataDirectory.resolve("messages/zh_TW.yml") + Files.write( + catalog, + "messages-version: 1\nvalue:\n 'yes': '自訂'\n".toByteArray(StandardCharsets.UTF_8), + ) + + val configuration = BukkitConfigurationLoader(dataDirectory) {}.load() + + assertEquals("自訂", configuration.messages.resolve("zh_TW", "value.yes")) + assertEquals("否", configuration.messages.resolve("zh_TW", "value.no")) + assertEquals(configBefore, String(Files.readAllBytes(config), StandardCharsets.UTF_8)) + assertEquals( + "messages-version: 1\nvalue:\n 'yes': '自訂'\n", + String(Files.readAllBytes(catalog), StandardCharsets.UTF_8), + ) + } + @Test fun `bundled message catalogs preserve yes and no keys`() { BundledConfigurationInstaller(dataDirectory) { resourcePath -> diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutputTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutputTest.kt new file mode 100644 index 0000000..10b07e3 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BukkitMessageOutputTest.kt @@ -0,0 +1,96 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.MessageDecoration +import io.github.command1264.invitecode.platform.bukkit.MessageSegment +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage +import net.md_5.bungee.api.ChatColor +import org.bukkit.command.CommandSender +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Test +import java.lang.reflect.Proxy + +class BukkitMessageOutputTest { + @Test + fun `player report has one heading prefix for all fields`() { + val sent = mutableListOf() + val spigot = object : org.bukkit.entity.Player.Spigot() { + override fun sendMessage(vararg components: net.md_5.bungee.api.chat.BaseComponent) { + sent.add(components.joinToString("") { it.toPlainText() }) + } + } + val player = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(org.bukkit.entity.Player::class.java)) { _, method, _ -> + when (method.name) { "spigot" -> spigot; "getLocale" -> "en_US"; else -> null } + } as org.bukkit.entity.Player + val catalog = io.github.command1264.invitecode.platform.bukkit.LocalizedMessages("en_US", false, + mapOf("en_US" to mapOf("presentation.prefix" to "[IC]", "title" to "Health", "body" to "Backend: SQLITE\nSchema: 9"))) + BukkitMessageOutput.sendReport(player, catalog, "title", listOf("body" to emptyMap())) + assertEquals(1, Regex("\\[IC]").findAll(sent.joinToString("\n")).count()) + assertEquals("[IC] Health", sent.first()) + assertEquals("Backend: SQLITE\nSchema: 9", sent.last()) + } + + @Test + fun `console report prefixes every field and leaves timestamps to the server`() { + val sent = mutableListOf() + val console = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(CommandSender::class.java)) { _, method, args -> + if (method.name == "sendMessage" && args?.firstOrNull() is String) sent.add(args[0] as String) + null + } as CommandSender + val catalog = io.github.command1264.invitecode.platform.bukkit.LocalizedMessages("en_US", false, + mapOf("en_US" to mapOf("presentation.prefix" to "[IC]", "title" to "Health", "body" to "Backend: SQLITE\nSchema: 9"))) + BukkitMessageOutput.sendReport(console, catalog, "title", listOf("body" to emptyMap())) + assertEquals(3, sent.size) + sent.forEach { line -> + assertEquals(1, Regex("\\[IC]").findAll(line).count()) + assertFalse(line.contains("INFO") || line.contains('\n')) + } + } + + @Test + fun `console sends each logical line separately with its own prefix and retained color`() { + val sent = mutableListOf() + val console = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(CommandSender::class.java)) { _, method, args -> + if (method.name == "sendMessage" && args?.firstOrNull() is String) sent.add(args[0] as String) + null + } as CommandSender + val messages = io.github.command1264.invitecode.platform.bukkit.LocalizedMessages("en_US", false, + mapOf("en_US" to mapOf("presentation.prefix" to "[InviteCode]", "test" to "&aFirst\n&cSecond\nThird"))) + BukkitMessageOutput.send(console, messages, "test") + assertEquals(3, sent.size) + assertFalse(sent.any { it.contains('\n') || it.contains('\r') }) + sent.forEach { assertEquals(1, Regex("\\[InviteCode]").findAll(it).count()) } + org.junit.jupiter.api.Assertions.assertTrue(sent[1].contains("§cSecond")) + org.junit.jupiter.api.Assertions.assertTrue(sent[2].contains("§cThird")) + } + + @Test + fun `console preserves color without decoration and never executes text controls`() { + val sent = mutableListOf() + val console = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(CommandSender::class.java)) { _, method, args -> + if (method.name == "sendMessage" && args?.firstOrNull() is String) sent.add(args[0] as String) + null + } as CommandSender + BukkitMessageOutput.sendPresented(console, PresentedMessage(listOf( + MessageSegment("OK", 0x55FF55, setOf(MessageDecoration.BOLD)), + MessageSegment(" &c literal §c text \u001B[31m", 0xAAAAAA), + ))) + assertEquals("§r§aOK§r§7 &c literal &c text [31m§r", sent.single()) + assertFalse(sent.single().contains("§l")) + } + + @Test + fun `player components retain literal values and explicit formatting independently`() { + val components = BukkitMessageOutput.components(PresentedMessage(listOf( + MessageSegment("&c{player} §c\u001B", 0x55FF55, setOf(MessageDecoration.BOLD)), + MessageSegment(" plain"), + ))) + assertEquals(2, components.size) + assertEquals("&c{player} &c", components[0].toPlainText()) + assertEquals(ChatColor.GREEN, components[0].color) + assertEquals(true, components[0].isBold) + assertEquals(false, components[1].isBold) + assertEquals(ChatColor.WHITE, components[1].color) + assertEquals(null, components[0].clickEvent) + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstallerTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstallerTest.kt index 005b207..ca17a20 100644 --- a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstallerTest.kt +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledConfigurationInstallerTest.kt @@ -4,8 +4,11 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.io.TempDir import java.io.ByteArrayInputStream +import java.io.IOException +import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path @@ -17,6 +20,7 @@ class BundledConfigurationInstallerTest { @Test fun `installs nested jar resources into the flat plugin data layout without overwriting settings`() { Files.write(dataDirectory.resolve("config.yml"), "existing".toByteArray(StandardCharsets.UTF_8)) + Files.write(dataDirectory.resolve("storage.yml"), "corrupt: [".toByteArray(StandardCharsets.UTF_8)) val requested = mutableListOf() val installer = BundledConfigurationInstaller(dataDirectory) { resourcePath -> requested += resourcePath @@ -26,17 +30,51 @@ class BundledConfigurationInstallerTest { installer.installMissing() assertEquals("existing", String(Files.readAllBytes(dataDirectory.resolve("config.yml")), StandardCharsets.UTF_8)) - assertEquals( - "config/storage.yml", - String(Files.readAllBytes(dataDirectory.resolve("storage.yml")), StandardCharsets.UTF_8), - ) + assertEquals("corrupt: [", String(Files.readAllBytes(dataDirectory.resolve("storage.yml")), StandardCharsets.UTF_8)) assertEquals( "config/messages/zh_TW.yml", String(Files.readAllBytes(dataDirectory.resolve("messages/zh_TW.yml")), StandardCharsets.UTF_8), ) assertFalse(Files.exists(dataDirectory.resolve("config/config.yml"))) assertTrue("config/config.yml" !in requested) - assertTrue("config/storage.yml" in requested) + assertFalse("config/storage.yml" in requested) + assertTrue("config/qualifications.yml" in requested) assertTrue("config/messages/en_US.yml" in requested) } + + @Test + fun `missing bundled resource fails clearly without creating its target`() { + val error = assertThrows { + BundledConfigurationInstaller(dataDirectory) { null }.installMissing() + } + + assertTrue(error.message.orEmpty().contains("Bundled resource does not exist: config/config.yml")) + assertFalse(Files.exists(dataDirectory.resolve("config.yml"))) + } + + @Test + fun `interrupted resource write leaves no partial target or temporary file`() { + val source = object : InputStream() { + private var firstRead = true + + override fun read(): Int { + if (firstRead) { + firstRead = false + return 'x'.code + } + throw IOException("simulated resource read failure") + } + } + + val error = assertThrows { + BundledConfigurationInstaller(dataDirectory) { source }.installMissing() + } + + assertTrue( + error.message.orEmpty().contains("simulated resource read failure") || + error.cause?.message.orEmpty().contains("simulated resource read failure") == true, + ) + assertFalse(Files.exists(dataDirectory.resolve("config.yml"))) + Files.list(dataDirectory).use { children -> assertEquals(0L, children.count()) } + } } diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledMessageCatalogTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledMessageCatalogTest.kt new file mode 100644 index 0000000..bd29e18 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/BundledMessageCatalogTest.kt @@ -0,0 +1,145 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.CommandHelp +import org.bukkit.configuration.file.YamlConfiguration +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import java.io.InputStreamReader + +class BundledMessageCatalogTest { + @Test + fun `complete bundled locales have matching keys variables and real help descriptions`() { + val chinese = catalog("zh_TW") + val english = catalog("en_US") + assertEquals(chinese.keys, english.keys) + chinese.forEach { (key, value) -> + assertEquals(variables(value), variables(english.getValue(key)), key) + assertTrue(value.isNotBlank(), key) + } + CommandHelp.entries.forEach { entry -> + assertTrue(chinese.containsKey(entry.descriptionKey), entry.descriptionKey) + assertTrue(english.containsKey(entry.descriptionKey), entry.descriptionKey) + val detailKey = entry.descriptionKey.replace("help-description", "help-detail") + listOf(chinese, english).forEach { locale -> + val detail = locale.getValue(detailKey) + assertEquals(setOf("usage", "example"), variables(detail), detailKey) + assertTrue(detail.lines().size in 3..7, detailKey) + } + } + assertFalse(chinese.getValue("command.claim.confirmation-prompt").endsWith(":")) + assertFalse(english.getValue("command.claim.confirmation-prompt").endsWith(":")) + } + + @Test + fun `bundled user messages avoid semicolon prose and diagnostics have one field per line`() { + listOf("zh_TW", "en_US").forEach { locale -> + val entries = catalog(locale) + entries.forEach { (key, value) -> assertFalse(value.contains(';') || value.contains(';'), "$locale:$key") } + listOf("admin.doctor-runtime", "admin.doctor-integrations", "admin.doctor-storage", + "admin.inspect-player", "admin.inspect-invitation", "admin.inspect-reward").forEach { key -> + val lines = entries.getValue(key).lines() + assertTrue(lines.size >= 3, key) + lines.forEach { assertEquals(1, variables(it).size, "$locale:$key:$it") } + } + } + } + + @Test + fun `claim labels and feedback follow locale and style contracts`() { + val chinese = catalog("zh_TW") + val english = catalog("en_US") + assertEquals("邀請碼", chinese.getValue("command.claim.dialog-label")) + assertFalse(chinese.getValue("command.claim.dialog-label").any { it.isDigit() }) + assertFalse(chinese.getValue("command.claim.dialog-label").contains("六位")) + assertEquals("Invite code", english.getValue("command.claim.dialog-label")) + assertFalse(english.getValue("command.claim.dialog-label").any { it.isDigit() }) + assertFalse(english.getValue("command.claim.dialog-label").contains("six", ignoreCase = true)) + + val claimRetryKeys = listOf( + "command.claim.chat-timeout", "command.claim.dialog-timeout", + "command.claim.confirmation-timeout", + ) + listOf("zh_TW" to chinese, "en_US" to english).forEach { (locale, entries) -> + claimRetryKeys.forEach { key -> + assertSingleRedSentence(entries.getValue(key), locale == "zh_TW", key) + assertTrue(entries.getValue(key).contains("/invitecode claim"), key) + } + assertSingleRedSentence(entries.getValue("command.stopping"), locale == "zh_TW", "command.stopping") + assertSingleRedSentence(entries.getValue("command.claim.invalid-code"), locale == "zh_TW", + "command.claim.invalid-code") + listOf("runtime.usage", "runtime.help-page-error", "command.claim.unavailable", + "command.claim.no-confirmation", "command.claim.matching-network-denied", "command.error", + "admin.error", "admin.reload-failed", "admin.storage-config-unavailable", "admin.storage-failed", + "admin.doctor-storage-failed").forEach { key -> + assertSingleRedSentence(entries.getValue(key), locale == "zh_TW", key) + } + } + + assertTrue(chinese.getValue("runtime.usage").contains("/{label} help")) + assertTrue(english.getValue("runtime.usage").contains("/{label} help")) + assertTrue(chinese.getValue("runtime.help-page-error").contains("/ic help")) + assertTrue(english.getValue("runtime.help-page-error").contains("/ic help")) + assertTrue(chinese.getValue("command.claim.unavailable").contains("不存在")) + assertTrue(chinese.getValue("command.claim.unavailable").contains("已失效")) + assertTrue(chinese.getValue("command.claim.unavailable").contains("邀請人")) + assertTrue(english.getValue("command.claim.unavailable").contains("does not exist")) + assertTrue(english.getValue("command.claim.unavailable").contains("no longer active")) + assertTrue(english.getValue("command.claim.unavailable").contains("inviter")) + assertTrue(chinese.getValue("command.claim.matching-network-denied").contains("相同網路")) + assertTrue(chinese.getValue("command.claim.matching-network-denied").contains("無法登記")) + assertTrue(chinese.getValue("command.claim.matching-network-denied").contains("聯絡管理員")) + assertTrue(english.getValue("command.claim.matching-network-denied").contains("same network")) + assertTrue(english.getValue("command.claim.matching-network-denied").contains("prevent this claim")) + assertTrue(english.getValue("command.claim.matching-network-denied").contains("contact an administrator")) + assertTrue(chinese.getValue("command.claim.no-confirmation").contains("沒有可確認的邀請")) + assertTrue(chinese.getValue("command.claim.no-confirmation").contains("已逾時")) + assertTrue(chinese.getValue("command.claim.no-confirmation").contains("/invitecode claim")) + assertTrue(english.getValue("command.claim.no-confirmation").contains("no invitation to confirm")) + assertTrue(english.getValue("command.claim.no-confirmation").contains("expired")) + assertTrue(english.getValue("command.claim.no-confirmation").contains("/invitecode claim")) + assertTrue(chinese.getValue("command.error").contains("操作失敗")) + assertTrue(chinese.getValue("command.error").contains("檢查伺服器紀錄")) + assertTrue(english.getValue("command.error").contains("operation failed")) + assertTrue(english.getValue("command.error").contains("check the server log")) + assertTrue(chinese.getValue("admin.error").contains("管理操作失敗")) + assertTrue(english.getValue("admin.error").contains("administrative operation failed")) + assertTrue(chinese.getValue("admin.reload-failed").contains("上一份有效設定")) + assertTrue(chinese.getValue("admin.reload-failed").contains("修正設定")) + assertTrue(english.getValue("admin.reload-failed").contains("previous configuration remains active")) + assertTrue(english.getValue("admin.reload-failed").contains("fix the configuration")) + assertTrue(chinese.getValue("admin.storage-config-unavailable").contains("設定尚未成功載入")) + assertTrue(chinese.getValue("admin.storage-config-unavailable").contains("無法判定儲存位置")) + assertTrue(english.getValue("admin.storage-config-unavailable").contains("configuration is not loaded")) + assertTrue(english.getValue("admin.storage-config-unavailable").contains("storage location is unknown")) + assertTrue(chinese.getValue("admin.storage-failed").contains("儲存結構更新失敗")) + assertTrue(english.getValue("admin.storage-failed").contains("storage schema update failed", ignoreCase = true)) + assertTrue(chinese.getValue("admin.doctor-storage-failed").contains("儲存健康檢查失敗")) + assertTrue(english.getValue("admin.doctor-storage-failed").contains("storage health check failed")) + + val chineseInvalidCode = chinese.getValue("command.claim.invalid-code") + assertEquals(1, chineseInvalidCode.count { it == '。' }) + assertTrue(chineseInvalidCode.contains(',')) + val englishInvalidCode = english.getValue("command.claim.invalid-code") + assertEquals(1, Regex("[.!?](?=\\s|\\z)").findAll(englishInvalidCode).count()) + } + + private fun assertSingleRedSentence(message: String, isChinese: Boolean, key: String) { + assertFalse(message.contains('\n') || message.contains('\r'), "$key must be one line") + assertTrue(message.startsWith("&c"), "$key must start red") + assertEquals(1, Regex("(?:&[0-9a-fk-or]|&#[0-9a-fA-F]{6})").findAll(message).count(), + "$key must contain only one style code") + val endings = if (isChinese) message.count { it == '。' } + else Regex("[.!?](?=\\s|\\z)").findAll(message).count() + assertEquals(1, endings, "$key must be one sentence") + } + + private fun catalog(locale: String): Map { + val yaml = YamlConfiguration() + InputStreamReader(requireNotNull(javaClass.getResourceAsStream("/config/messages/$locale.yml")), Charsets.UTF_8) + .use(yaml::load) + return yaml.getKeys(true).filter { yaml.isString(it) }.associateWith { requireNotNull(yaml.getString(it)) } + } + + private fun variables(text: String) = Regex("\\{([a-z][a-z0-9_]*)}") + .findAll(text).map { it.groupValues[1] }.toSet() +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayoutsTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayoutsTest.kt new file mode 100644 index 0000000..85b28c0 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/DoctorMessageLayoutsTest.kt @@ -0,0 +1,70 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.* +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.nio.file.Path + +class DoctorMessageLayoutsTest { + @TempDir lateinit var directory: Path + + @Test + fun `formatted doctor reaches console with one prefix per line and value colors intact`() { + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val lines = mutableListOf() + val console = java.lang.reflect.Proxy.newProxyInstance(javaClass.classLoader, + arrayOf(org.bukkit.command.CommandSender::class.java)) { _, method, args -> + if (method.name == "sendMessage" && args?.firstOrNull() is String) lines.add(args[0] as String) + null + } as org.bukkit.command.CommandSender + val layout = DoctorMessageLayouts(messages, null, MessageAudience.CONSOLE) + BukkitMessageOutput.sendReport(console, messages, "runtime.help-topic.doctor", + listOf("admin.doctor-runtime" to mapOf("phase" to "ACTIVE", "generation" to "9", "executor" to "ACCEPTING")), layout::render) + assertEquals(4, lines.size) + lines.forEach { assertEquals(1, Regex("\\[InviteCode]").findAll(it.replace(Regex("§[0-9a-fk-or]"), "")).count()) } + assertTrue(lines.any { it.contains("§a運作中") }) + assertFalse(lines.any { it.contains("ACTIVE") || it.contains('\n') }) + } + + @Test + fun `doctor localizes and colors semantic values without parsing dynamic formatting`() { + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val layout = DoctorMessageLayouts(messages, "zh_TW", MessageAudience.RGB_PLAYER) + val runtime = layout.render("admin.doctor-runtime", mapOf("phase" to "ACTIVE", "generation" to "9", "executor" to "ACCEPTING")) + assertTrue(runtime.plainText.contains("運作中")) + assertTrue(runtime.plainText.contains("接受新工作")) + assertFalse(runtime.plainText.contains("ACTIVE")) + assertTrue(runtime.segments.any { it.text == "運作中" && it.color == 0x55FF55 }) + val integrations = layout.render("admin.doctor-integrations", mapOf("placeholder" to "false", "vault" to "true", "dialog" to "PAPER", "rgb" to "true")) + assertTrue(integrations.plainText.contains("未啟用")) + assertTrue(integrations.plainText.contains("可用")) + assertTrue(integrations.plainText.contains("Paper")) + assertTrue(integrations.segments.any { it.text == "未啟用" && it.color == 0xFF5555 }) + assertTrue(integrations.segments.any { it.text == "支援" && it.color == 0x55FF55 }) + } + + @Test + fun `positive counts use distinct colors while zero stays gray and settings choose language`() { + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val values = mapOf("backend" to "SQLITE", "schema" to "9", "pending" to "1", "processing" to "2", "uncertain" to "3") + val report = DoctorMessageLayouts(messages, "en_US", MessageAudience.CONSOLE).render("admin.doctor-storage", values) + assertTrue(report.plainText.contains("SQLite")) + assertTrue(report.plainText.contains("Pending")) + assertTrue(report.segments.any { it.text == "1" && it.color == 0xFFFF55 }) + assertTrue(report.segments.any { it.text == "2" && it.color == 0x55FFFF }) + assertTrue(report.segments.any { it.text == "3" && it.color == 0xFFAA00 }) + val zero = DoctorMessageLayouts(messages, "zh_TW", MessageAudience.RGB_PLAYER).render("admin.doctor-storage", values.mapValues { if (it.key in setOf("pending","processing","uncertain")) "0" else it.value }) + assertEquals(3, zero.segments.count { it.text == "0" && it.color == 0xAAAAAA }) + val configured = LocalizedMessages("en_US", false, mapOf("en_US" to mapOf("x" to "{phase}", "admin.doctor-value.phase.active" to "&aActive"))) + assertEquals("Active", DoctorMessageLayouts(configured,"zh_TW",MessageAudience.CONSOLE).render("x",mapOf("phase" to "ACTIVE")).plainText) + } + + @Test + fun `unknown codes are neutral literal diagnostic values`() { + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val report = DoctorMessageLayouts(messages,"zh_TW",MessageAudience.RGB_PLAYER).render("admin.doctor-runtime",mapOf("phase" to "&c{executor}","generation" to "0","executor" to "STOPPED")) + assertTrue(report.plainText.contains("&c{executor}")) + assertTrue(report.segments.any { it.text.contains("&c{executor}") && it.color == 0xAAAAAA }) + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/MessageConfigurationStageOneTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/MessageConfigurationStageOneTest.kt new file mode 100644 index 0000000..5e30966 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/MessageConfigurationStageOneTest.kt @@ -0,0 +1,65 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.AtomicRuntimeSnapshot +import io.github.command1264.invitecode.platform.bukkit.MessagePresenter +import io.github.command1264.invitecode.platform.bukkit.PrefixPlacement +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.io.TempDir +import java.nio.charset.StandardCharsets.UTF_8 +import java.nio.file.Files +import java.nio.file.Path + +class MessageConfigurationStageOneTest { + @TempDir + lateinit var directory: Path + + @Test + fun `validated reload can disable prefix while malformed replacement keeps installed snapshot`() { + val loader = BukkitConfigurationLoader(directory) {} + val snapshots = AtomicRuntimeSnapshot(loader.load()) + val custom = "messages-version: 1\npresentation:\n prefix: ''\ncustom: '&aHello {player}'\n" + val catalog = directory.resolve("messages/zh_TW.yml") + Files.write(catalog, custom.toByteArray(UTF_8)) + snapshots.replace(loader.load()) + val presenter = MessagePresenter(snapshots.current().value.messages) + assertEquals("Hello &c{other}", presenter.render( + null, "custom", mapOf("player" to "&c{other}"), prefix = PrefixPlacement.OWN_LINE, + ).plainText) + assertArrayEquals(custom.toByteArray(UTF_8), Files.readAllBytes(catalog)) + + val damaged = "presentation: [\n" + Files.write(catalog, damaged.toByteArray(UTF_8)) + assertThrows { snapshots.replace(loader.load()) } + assertEquals(1L, snapshots.current().generation) + assertEquals("Hello Alex", MessagePresenter(snapshots.current().value.messages).render( + null, "custom", mapOf("player" to "Alex"), + ).plainText) + assertArrayEquals(damaged.toByteArray(UTF_8), Files.readAllBytes(catalog)) + } + + @Test + fun `restoring deleted built in catalog keeps unrelated files secrets and data untouched`() { + val loader = BukkitConfigurationLoader(directory) {} + loader.load() + val key = byteArrayOf(1, 2, 3, 4) + Files.write(directory.resolve("anti-abuse.key"), key) + Files.write(directory.resolve("invitecode.db"), byteArrayOf(7, 8, 9)) + Files.write(directory.resolve("messages/custom-locale.yml"), + "messages-version: 1\ncustom: keep\n".toByteArray(UTF_8)) + val storage = Files.readAllBytes(directory.resolve("storage.yml")) + Files.delete(directory.resolve("messages/en_US.yml")) + + val restored = loader.load() + + assertEquals("yes", restored.messages.resolve("en_US", "value.yes")) + assertArrayEquals(storage, Files.readAllBytes(directory.resolve("storage.yml"))) + assertArrayEquals(key, Files.readAllBytes(directory.resolve("anti-abuse.key"))) + assertArrayEquals(byteArrayOf(7, 8, 9), Files.readAllBytes(directory.resolve("invitecode.db"))) + assertEquals("keep", restored.messages.resolve("custom-locale", "custom")) + assertFalse(Files.exists(directory.resolve("config/config.yml"))) + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMysqlIntegrationTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMysqlIntegrationTest.kt index 41e23c1..adef563 100644 --- a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMysqlIntegrationTest.kt +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/OfflineStorageTransferMysqlIntegrationTest.kt @@ -380,7 +380,7 @@ class OfflineStorageTransferMysqlIntegrationTest { ), transitions.map { it.occurredAt }, ) - assertEquals("Interrupted while processing; delivery result is unknown.", transitions.last().lastError) + assertEquals("Interrupted while processing\ndelivery result is unknown.", transitions.last().lastError) val pendingActions = storage.pendingRewardActions(expected.recipientId) assertEquals(false, pendingActions.any { it.id == expected.id }) pendingExpected?.let { pending -> diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt index 4ce6108..2fddb98 100644 --- a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerChatActionsTest.kt @@ -2,6 +2,8 @@ package io.github.command1264.invitecode.plugin import net.md_5.bungee.api.ChatColor import net.md_5.bungee.api.chat.ClickEvent +import io.github.command1264.invitecode.platform.bukkit.MessageSegment +import io.github.command1264.invitecode.platform.bukkit.PresentedMessage import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Test @@ -10,7 +12,8 @@ class PlayerChatActionsTest { @Test fun `the displayed code itself offers the raw code to a legacy client`() { val components = PlayerChatActions.codeMessage( - "你的邀請碼是 {code}", "§aA1B2C3§r", "A1B2C3", "點擊複製到剪貼簿", "點擊填入聊天列", + PresentedMessage(listOf(MessageSegment("你的邀請碼是 "), MessageSegment("A1B2C3", 0x55FF55, variable = "code"))), + "A1B2C3", text("點擊複製到剪貼簿"), text("點擊填入聊天列"), ) val codeComponents = components.filter { it.toPlainText().contains("A1B2C3") } @@ -25,19 +28,23 @@ class PlayerChatActionsTest { @Test fun `confirmation actions execute only their respective commands`() { - val buttons = PlayerChatActions.confirmation("同意", "不同意", "點擊同意並使用邀請碼", "點擊不同意並取消") + val buttons = PlayerChatActions.confirmation( + text("同意", 0x55FF55), text("不同意", 0xFF5555), text("點擊同意並使用邀請碼"), text("點擊不同意並取消"), + ) assertEquals(2, buttons.size) - assertEquals("[同意]", buttons[0].text) + assertEquals("[同意]", buttons[0].toPlainText()) assertEquals(ChatColor.GREEN, buttons[0].color) assertEquals(ClickEvent.Action.RUN_COMMAND, buttons[0].clickEvent.action) assertEquals("/invitecode confirm", buttons[0].clickEvent.value) assertEquals("點擊同意並使用邀請碼", buttons[0].hoverEvent.value.single().toPlainText()) - assertEquals(" [不同意]", buttons[1].text) + assertEquals(" [不同意]", buttons[1].toPlainText()) assertEquals(ChatColor.RED, buttons[1].color) assertEquals(ClickEvent.Action.RUN_COMMAND, buttons[1].clickEvent.action) assertEquals("/invitecode cancel", buttons[1].clickEvent.value) assertEquals("點擊不同意並取消", buttons[1].hoverEvent.value.single().toPlainText()) assertFalse(buttons[0].clickEvent.value == buttons[1].clickEvent.value) } + + private fun text(value: String, color: Int? = null) = PresentedMessage(listOf(MessageSegment(value, color))) } diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayoutsTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayoutsTest.kt new file mode 100644 index 0000000..ff2ff44 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerMessageLayoutsTest.kt @@ -0,0 +1,73 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.core.InviteCode +import io.github.command1264.invitecode.core.InviteCodeFormats +import io.github.command1264.invitecode.platform.bukkit.* +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.nio.file.Path + +class PlayerMessageLayoutsTest { + @TempDir lateinit var directory: Path + + @Test + fun `status reports real reasons within the same prefixed reply`() { + val layout = PlayerMessageLayouts(BukkitConfigurationLoader(directory) {}.load().messages, "en_US", MessageAudience.LEGACY_PLAYER) + val status = layout.status(false, "claimed", 2, listOf("already registered", "claim period ended")) + assertEquals(1, Regex("\\[InviteCode]").findAll(status.plainText).count()) + assertTrue(status.plainText.endsWith("Cannot register: already registered")) + assertFalse(status.plainText.contains("claim period ended")) + assertFalse(layout.status(true, "none", 0, emptyList()).plainText.contains("Cannot register")) + } + + @Test + fun `bundled chat and native confirmation share the seven logical sections without trailing spaces`() { + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val layout = PlayerMessageLayouts(messages, "zh_TW", MessageAudience.RGB_PLAYER) + val code = InviteCode.parse("A1B2C3", InviteCodeFormats.colorHex) + val chat = layout.chatConfirmation("&c{code}", code, 60) + assertEquals(listOf("[InviteCode]", "確認邀請碼", "邀請人:&c{code}", "邀請碼:A1B2C3", "是否使用這組邀請碼?", "請在 60 秒內選擇"), chat.plainText.lines()) + assertTrue(chat.plainText.lines().none { it.endsWith(' ') }) + val dialog = layout.confirmationDialog("&c{code}", code, 60) + assertEquals("[InviteCode]", dialog.title) + assertEquals(chat.plainText.lines().drop(1), dialog.presentation!!.body.map { it.plainText }) + assertEquals("同意", dialog.presentation!!.confirm.plainText) + assertEquals(0xA1B2C3, dialog.presentation!!.body[2].segments.last().color) + } + + @Test + fun `empty prefix uses useful dialog title without duplicate heading and respects English locale`() { + BukkitConfigurationLoader(directory) {}.load() + val path = directory.resolve("messages/en_US.yml") + val text = java.nio.file.Files.readAllBytes(path).toString(Charsets.UTF_8) + .replace("prefix: \"&7[&6InviteCode&7]&r\"", "prefix: \"\"") + java.nio.file.Files.write(path, text.toByteArray(Charsets.UTF_8)) + val layout = PlayerMessageLayouts(BukkitConfigurationLoader(directory) {}.load().messages, "en_US", MessageAudience.RGB_PLAYER) + val dialog = layout.confirmationDialog("Alex", InviteCode.parse("A1B2C3", InviteCodeFormats.colorHex), 60) + assertEquals("Confirm Invite Code", dialog.title) + assertEquals(4, dialog.presentation!!.body.size) + assertEquals("Inviter: Alex", dialog.presentation!!.body.first().plainText) + val input = layout.inputDialog() + assertEquals("Enter Invite Code", input.title) + assertTrue(input.presentation!!.body.isEmpty()) + assertEquals("Invite code", input.presentation!!.inputLabel!!.plainText) + } + + @Test + fun `literal text identical to code is not clickable and real code payload stays raw`() { + val messages = LocalizedMessages("zh_TW", false, mapOf("zh_TW" to mapOf( + "presentation.prefix" to "[InviteCode]", "command.code.value" to "A1B2C3 {code}", + ))) + val code = InviteCode.parse("A1B2C3", InviteCodeFormats.colorHex) + val message = PlayerMessageLayouts(messages, null, MessageAudience.LEGACY_PLAYER).code(code) + val hint = PresentedMessage(listOf(MessageSegment("Copy &c{code}"))) + val components = PlayerChatActions.codeMessage(message, code.displayValue(), hint, hint) + val clicked = components.filter { it.clickEvent != null } + assertEquals(1, clicked.size) + assertEquals("A1B2C3", clicked.single().clickEvent.value) + assertEquals("A1B2C3", clicked.single().toPlainText()) + assertEquals("Copy &c{code}", clicked.single().hoverEvent.value.joinToString("") { it.toPlainText() }) + assertEquals("[InviteCode] A1B2C3 A1B2C3", components.joinToString("") { it.toPlainText() }) + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowPresentationIntegrationTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowPresentationIntegrationTest.kt new file mode 100644 index 0000000..a155aa1 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/PlayerWorkflowPresentationIntegrationTest.kt @@ -0,0 +1,363 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.core.ColorInviteCodeGenerator +import io.github.command1264.invitecode.core.InviteCodeLifecycleService +import io.github.command1264.invitecode.core.InvitationAdministrationContext +import io.github.command1264.invitecode.core.QualificationProviderRegistry +import io.github.command1264.invitecode.core.StoredPlayer +import io.github.command1264.invitecode.platform.bukkit.* +import io.github.command1264.invitecode.storage.sql.BlockingOperationGuard +import io.github.command1264.invitecode.storage.sql.SqliteInviteCodeStorage +import io.github.command1264.invitecode.storage.sql.SqliteSchemaMigrator +import net.md_5.bungee.api.chat.BaseComponent +import net.md_5.bungee.api.chat.ClickEvent +import org.bukkit.Server +import org.bukkit.entity.Player +import org.bukkit.event.player.AsyncPlayerChatEvent +import org.bukkit.plugin.Plugin +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.lang.reflect.Proxy +import java.nio.file.Path +import java.time.Duration +import java.time.Instant +import java.util.UUID +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicReference +import java.util.logging.Logger + +/** Exercises the player workflow boundary with real asynchronous SQLite operations and no server. */ +class PlayerWorkflowPresentationIntegrationTest { + @TempDir lateinit var directory: Path + + private var fixture: Fixture? = null + + @AfterEach + fun close() { fixture?.close() } + + @Test + fun `code command renders one clickable code segment with raw payload and prefix`() { + val f = fixture() + f.controller.handle(f.inviter, command("code")) + + val output = f.awaitOutput() + val clicked = output.flatMap { it.toList() }.filter { it.clickEvent != null } + assertEquals(1, clicked.size) + assertTrue(clicked.single().clickEvent!!.action == ClickEvent.Action.SUGGEST_COMMAND || + clicked.single().clickEvent!!.action.name == "COPY_TO_CLIPBOARD") + assertEquals(f.inviterCode, clicked.single().clickEvent!!.value) + assertTrue(output.flattenText().contains("[InviteCode]")) + assertEquals(f.inviterCode, clicked.single().toPlainText()) + } + + @Test + fun `chat claim confirmation consumes once and status and stats render through components`() { + val f = fixture() + val confirmation = f.startClaim(f.inviterCode).flattenText() + assertEquals(7, confirmation.lines().size) + assertEquals(1, confirmation.lines().count { it == "[InviteCode]" }) + assertTrue(confirmation.contains("Invite Code")) + assertTrue(confirmation.contains("Inviter: Inviter")) + assertTrue(confirmation.contains(f.inviterCode)) + + f.controller.handle(f.invitee, command("confirm")) + val claimed = f.awaitOutput().flattenText() + assertTrue(claimed.contains("Your invitation has been registered.")) + f.controller.handle(f.invitee, command("confirm")) + assertTrue(f.awaitOutput().flattenText().contains("There is no invitation to confirm")) + assertEquals(1, f.storage!!.invitationsByInvitee(f.inviteeId).size) + + f.controller.handle(f.invitee, command("status")) + val status = f.awaitOutput().flattenText() + assertTrue(status.contains("awaiting qualification")) + assertTrue(status.lines().first().contains("[InviteCode]")) + + f.controller.handle(f.inviter, command("stats")) + val stats = f.awaitOutput().flattenText() + assertTrue(stats.contains("1")) + assertTrue(stats.lines().first().contains("[InviteCode]")) + } + + @Test + fun `decline timeout and existing claim reject before another confirmation`() { + val f = fixture() + assertTrue(f.startClaim(f.inviterCode).flattenText().contains("Use this Invite Code?")) + f.controller.handle(f.invitee, command("cancel")) + assertTrue(f.awaitOutput().flattenText().contains("cancelled")) + f.controller.handle(f.invitee, command("confirm")) + assertTrue(f.awaitOutput().flattenText().contains("There is no invitation to confirm")) + + assertTrue(f.startClaim(f.inviterCode).flattenText().contains("Use this Invite Code?")) + f.advanceClock(Duration.ofSeconds(31)) + f.dispatcher.runAllDelays() + assertTrue(f.awaitOutput().flattenText().contains("expired")) + f.controller.handle(f.invitee, command("confirm")) + assertTrue(f.awaitOutput().flattenText().contains("There is no invitation to confirm")) + + assertTrue(f.startClaim(f.inviterCode).flattenText().contains("Use this Invite Code?")) + f.controller.handle(f.invitee, command("confirm")) + f.awaitOutput() + f.controller.handle(f.invitee, command("claim", f.inviterCode)) + assertTrue(f.awaitOutput().flattenText().contains("already")) + assertEquals(1, f.storage!!.invitationsByInvitee(f.inviteeId).size) + } + + @Test + fun `native input closes and explains timeout exactly at its deadline`() { + val dialog = FakeDialog() + val f = fixture(dialog) + f.controller.handle(f.invitee, command("claim")) + f.awaitDialog(dialog) + f.advanceClock(Duration.ofSeconds(30)) + f.dispatcher.runAllDelays() + assertEquals(1, dialog.closed) + assertTrue(f.awaitOutput().flattenText().contains("expired")) + assertTrue(f.storage.invitationsByInvitee(f.inviteeId).isEmpty()) + } + + @Test + fun `early native input timeout task reschedules until the wall clock deadline`() { + val dialog = FakeDialog() + val f = fixture(dialog) + f.controller.handle(f.invitee, command("claim")) + f.awaitDialog(dialog) + f.advanceClock(Duration.ofSeconds(29)) + f.dispatcher.runOneDelay() + assertEquals(0, dialog.closed) + f.advanceClock(Duration.ofSeconds(1)) + f.dispatcher.runAllDelays() + assertEquals(1, dialog.closed) + assertTrue(f.awaitOutput().flattenText().contains("expired")) + } + + @Test + fun `late native input submission reports expiration instead of silently consuming it`() { + val dialog = FakeDialog() + val f = fixture(dialog) + f.controller.handle(f.invitee, command("claim")) + f.awaitDialog(dialog) + f.advanceClock(Duration.ofSeconds(31)) + dialog.submit!!(f.inviterCode) + assertTrue(f.awaitOutput().flattenText().contains("expired")) + f.dispatcher.runAllDelays() + assertTrue(f.storage.invitationsByInvitee(f.inviteeId).isEmpty()) + } + + @Test + fun `expired inviter status displays the inviter reason without a second reason line`() { + val f = fixture() + f.advanceClock(Duration.ofHours(25)) + f.controller.handle(f.inviter, command("status")) + val text = f.awaitOutput().flattenText() + assertTrue(text.contains("you have already created your own Invite Code")) + assertFalse(text.contains("the claim period has ended")) + assertEquals(5, text.lines().size) + } + + @Test + fun `status reports only the current eligibility generation after reset`() { + val f = fixture() + fun register() { + f.startClaim(f.inviterCode) + f.controller.handle(f.invitee, command("confirm")) + assertTrue(f.awaitOutput().flattenText().contains("Your invitation has been registered.")) + } + register() + val context = InvitationAdministrationContext(UUID.randomUUID(), "console", "test reset", Instant.parse("2026-01-01T00:00:00Z")) + f.storage.saveAuditedClaimStateTransition(f.storage.claimState(f.inviteeId).adminResetEligibility(context)) + f.controller.handle(f.invitee, command("status")) + assertTrue(f.awaitOutput().flattenText().contains("not registered")) + assertEquals(1, f.storage.invitationsByInvitee(f.inviteeId).size) + register() + f.controller.handle(f.invitee, command("status")) + assertTrue(f.awaitOutput().flattenText().contains("awaiting qualification")) + } + + @Test + fun `late native input cancel remains an explicit cancellation if timer has not run`() { + val dialog = FakeDialog() + val f = fixture(dialog) + f.controller.handle(f.invitee, command("claim")) + f.awaitDialog(dialog) + f.advanceClock(Duration.ofSeconds(31)) + dialog.cancelInput!!() + assertTrue(f.awaitOutput().flattenText().contains("cancelled")) + f.dispatcher.runAllDelays() + assertTrue(f.storage.invitationsByInvitee(f.inviteeId).isEmpty()) + } + + private fun fixture(dialog: FakeDialog? = null): Fixture = Fixture(directory, dialog).also { fixture = it } + + private fun command(vararg args: String): ParsedInviteCodeCommand = + InviteCodeCommandParser.parse(args.toList()) as ParsedInviteCodeCommand + + private inner class Fixture(directory: Path, dialog: FakeDialog?) : AutoCloseable { + private val guard = BlockingOperationGuard { } + private val clock = AtomicReference(Instant.parse("2026-01-01T00:00:00Z")) + private val now: Instant get() = clock.get() + val inviterId = UUID.fromString("00000000-0000-0000-0000-000000000001") + val inviteeId = UUID.fromString("00000000-0000-0000-0000-000000000002") + val playerOutput = PlayerOutput() + val inviter: Player = player(inviterId, "Inviter", playerOutput) + val invitee: Player = player(inviteeId, "Invitee", playerOutput) + val dispatcher = ControlledDispatcher() + val storage: SqliteInviteCodeStorage + private val async = AsyncOperationExecutor("workflow-presentation-test", dispatcher::global) + private val config: InviteCodeRuntimeConfiguration + val inviterCode: String + val controller: PlayerWorkflowController + + init { + val database = directory.resolve("workflow.db") + SqliteSchemaMigrator(database, guard).migrate() + storage = SqliteInviteCodeStorage.open(database, guard) + storage.savePlayer(StoredPlayer(inviterId, now, "Inviter")) + storage.savePlayer(StoredPlayer(inviteeId, now, "Invitee")) + inviterCode = InviteCodeLifecycleService(storage, ColorInviteCodeGenerator(), 64) + .assign(inviterId, now).code.displayValue() + val data = directory.resolve("config") + val loaded = BukkitConfigurationLoader(data) {}.load() + config = loaded.copy( + general = loaded.general.copy( + claim = loaded.general.claim.copy( + inputMode = if (dialog == null) InputMode.CHAT else InputMode.DIALOG, + confirmationTimeout = Duration.ofSeconds(30), + chatInputTimeout = Duration.ofSeconds(30), + ), + ), + ) + dispatcher.players[inviterId] = inviter + dispatcher.players[inviteeId] = invitee + val plugin = proxy(Plugin::class.java) { method, _ -> + when (method.name) { "getLogger" -> Logger.getLogger("InviteCode-test"); "getServer" -> proxy(Server::class.java) { _, _ -> null }; else -> defaultValue(method.returnType) } + } + controller = PlayerWorkflowController( + plugin, + AtomicRuntimeSnapshot(config), + AtomicReference(storage), + async, + dispatcher, + ClaimInteractionSessions { now }, + QualificationProviderRegistry(), + AtomicReference(null), + PlatformCapabilities(nativeDialogInput = dialog != null, rgbText = false), + dialog ?: UnavailableNativeDialogInput, + LegacyInviteCodeDisplayFormatter, + now = { now }, + ) + } + + fun startClaim(code: String): List> { + controller.handle(invitee, command("claim")) + awaitOutput() + val event = AsyncPlayerChatEvent(true, invitee, code, mutableSetOf(invitee)) + controller.onChat(event) + assertTrue(event.isCancelled) + return awaitOutput() + } + + fun advanceClock(duration: Duration) { clock.updateAndGet { it.plus(duration) } } + + fun awaitDialog(dialog: FakeDialog) { + val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5) + while (dialog.submit == null && System.nanoTime() < deadline) { + dispatcher.runOneTask() + Thread.sleep(1) + } + assertNotNull(dialog.submit) + } + + fun awaitOutput(): List> = playerOutput.awaitOutput(dispatcher) + + override fun close() { + async.close(Duration.ofSeconds(2)) + storage.close() + } + } + + private class PlayerOutput { + private val available = java.util.concurrent.LinkedBlockingQueue>() + fun record(components: Array) { + val batch = components.toList() + available.put(batch) + } + fun awaitOutput(dispatcher: ControlledDispatcher): List> { + val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5) + var first: List? = null + while (first == null && System.nanoTime() < deadline) { + first = available.poll(20, TimeUnit.MILLISECONDS) + if (first == null) dispatcher.runOneTask() + } + val result = mutableListOf(first ?: fail("Timed out waiting for player output; no server is running in this test.")) + while (true) result += available.poll() ?: break + return result + } + } + + private class ControlledDispatcher : PlatformTaskDispatcher { + val players = ConcurrentHashMap() + private val callbacks = java.util.concurrent.LinkedBlockingQueue<() -> Unit>() + private val playerWork = java.util.concurrent.LinkedBlockingQueue<() -> Unit>() + private val delays = java.util.concurrent.LinkedBlockingQueue<() -> Unit>() + override fun track(player: Player) = Unit + override fun untrack(player: Player) = Unit + override fun onlinePlayers(): Collection = players.values + override fun onlinePlayerNames(): Collection = players.values.map(Player::getName) + override fun global(operation: () -> Unit) { callbacks.put(operation) } + override fun player(player: Player, operation: () -> Unit, retired: () -> Unit) { playerWork.put(operation) } + override fun repeatGlobal(delayTicks: Long, periodTicks: Long, operation: () -> Unit): AutoCloseable = AutoCloseable {} + override fun delayPlayer(player: Player, delayTicks: Long, operation: () -> Unit, retired: () -> Unit) { delays.put(operation) } + override fun onlinePlayer(playerId: UUID): Player? = players[playerId] + override fun currentPlayer(playerId: UUID): Player? = players[playerId] + override fun isManagedThread(): Boolean = true + fun runAllDelays() { + while (true) (delays.poll() ?: break).invoke() + } + fun runOneDelay() { delays.poll()?.invoke() } + fun runOneTask() { + (playerWork.poll() ?: callbacks.poll())?.invoke() + } + } + + private class FakeDialog : NativeDialogInput { + override val available = true + var submit: ((String) -> Unit)? = null + var cancelInput: (() -> Unit)? = null + var closed = 0 + override fun show(player: Player, request: NativeDialogRequest, onSubmit: (String) -> Unit, onCancel: () -> Unit): Boolean { + submit = onSubmit + cancelInput = onCancel + return true + } + override fun cancel(player: Player) { closed++ } + override fun disconnect(playerId: UUID) = Unit + override fun close() = Unit + } + + private fun player(id: UUID, name: String, output: PlayerOutput): Player { + val spigot = object : Player.Spigot() { + override fun sendMessage(vararg components: BaseComponent) = output.record(components) + override fun getLocale(): String = "en_US" + } + return proxy(Player::class.java) { method, _ -> + when (method.name) { + "getUniqueId" -> id; "getName" -> name; "isOnline" -> true; "spigot" -> spigot + "hasPlayedBefore" -> false; else -> defaultValue(method.returnType) + } + } + } + + private fun proxy(type: Class, handler: (java.lang.reflect.Method, Array?) -> Any?): T = + Proxy.newProxyInstance(type.classLoader, arrayOf(type)) { _, method, args -> handler(method, args) } as T + + private fun defaultValue(type: Class<*>): Any? = when (type) { + java.lang.Boolean.TYPE -> false; java.lang.Integer.TYPE -> 0; java.lang.Long.TYPE -> 0L + java.lang.Double.TYPE -> 0.0; java.lang.Float.TYPE -> 0f; java.lang.Short.TYPE -> 0.toShort() + java.lang.Byte.TYPE -> 0.toByte(); java.lang.Character.TYPE -> '\u0000'; else -> null + } + + private fun List>.flattenText(): String = flatten().joinToString("") { it.toPlainText() } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RewardMessagePresentationTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RewardMessagePresentationTest.kt new file mode 100644 index 0000000..9581ae9 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RewardMessagePresentationTest.kt @@ -0,0 +1,46 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.core.OnlineRewardActionResult +import io.github.command1264.invitecode.platform.bukkit.BukkitRewardExecutionEnvironment +import io.github.command1264.invitecode.platform.bukkit.RewardMessageResolver +import net.md_5.bungee.api.chat.BaseComponent +import org.bukkit.Server +import org.bukkit.entity.Player +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.lang.reflect.Proxy +import java.nio.file.Path +import java.util.UUID + +class RewardMessagePresentationTest { + @TempDir lateinit var directory: Path + + @Test + fun `MESSAGE reward uses the same formatted player output exactly once`() { + val sent = mutableListOf>() + val spigot = object : Player.Spigot() { + override fun sendMessage(vararg components: BaseComponent) { sent.add(components) } + override fun getLocale(): String = "zh_TW" + } + val player = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(Player::class.java)) { _, method, _ -> + when (method.name) { "spigot" -> spigot; "isOnline" -> true; else -> null } + } as Player + val server = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(Server::class.java)) { _, _, _ -> null } as Server + val messages = BukkitConfigurationLoader(directory) {}.load().messages + val environment = BukkitRewardExecutionEnvironment(server, RewardMessageResolver { _, key -> key }, + isPrimaryThread = { true }, playerLookup = { player }, + messageDelivery = { target, key -> BukkitMessageOutput.send(target, messages, key) }, + ) + + assertEquals(OnlineRewardActionResult.ACCEPTED, environment.sendMessage(UUID.randomUUID(), "invite.qualified.invitee")) + assertEquals(1, sent.size) + assertEquals("[InviteCode] 你已達成邀請資格。", sent.single().joinToString("") { it.toPlainText() }) + assertEquals(OnlineRewardActionResult.RECIPIENT_OFFLINE, + BukkitRewardExecutionEnvironment(server, RewardMessageResolver { _, key -> key }, + isPrimaryThread = { true }, playerLookup = { null }, + messageDelivery = { _, _ -> error("offline delivery must not run") }, + ).sendMessage(UUID.randomUUID(), "invite.qualified.invitee")) + assertEquals(1, sent.size) + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandHelpTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandHelpTest.kt new file mode 100644 index 0000000..7cf90c7 --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandHelpTest.kt @@ -0,0 +1,268 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.CommandHelp +import io.github.command1264.invitecode.platform.bukkit.InviteCodeCommandId +import io.github.command1264.invitecode.platform.bukkit.LocalizedMessages +import io.github.command1264.invitecode.platform.bukkit.PluginRuntimeState +import net.md_5.bungee.api.ChatColor +import net.md_5.bungee.api.chat.BaseComponent +import org.bukkit.command.Command +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test +import java.lang.reflect.Proxy + +class RuntimeCommandHelpTest { + @Test + fun `homepage keeps five entries and runs only read only help navigation`() { + val capture = Capture() + val player = permissionProxy(Player::class.java, basicPermissions, capture) + execute(player, "ic", capture = capture) + val clicks = capture.components.flatten().mapNotNull { it.clickEvent } + assertEquals(setOf("/ic code", "/ic claim", "/ic status", "/ic stats", "/ic help"), clicks.map { it.value }.toSet()) + assertTrue(clicks.filter { it.value != "/ic help" }.all { it.action.name == "SUGGEST_COMMAND" }) + assertTrue(clicks.filter { it.value == "/ic help" }.all { it.action.name == "RUN_COMMAND" }) + assertEquals(1, Regex("\\[InviteCode]").findAll(capture.plainText()).count()) + assertFalse(capture.plainText().contains("confirm")) + assertFalse(capture.plainText().contains("cancel")) + assertFalse(capture.plainText().contains("<")) + assertEquals(0, capture.operations) + } + + @Test + fun `admin homepage adds one read only help entrance rather than twenty usages`() { + val capture = Capture() + val player = permissionProxy(Player::class.java, CommandHelp.entries.map { it.permission }.toSet(), capture) + execute(player, "invitecode", capture = capture) + val clicks = capture.components.flatten().mapNotNull { it.clickEvent }.distinctBy { it.value } + assertEquals(6, clicks.size) + assertTrue(clicks.any { it.value == "/invitecode help admin" && it.action.name == "RUN_COMMAND" }) + assertTrue(clicks.none { it.value.contains("unlink") || it.value.contains("migrate") }) + assertEquals(0, capture.operations) + } + + @Test + fun `management page navigation runs only help while detail suggests operational usage`() { + val permissions = CommandHelp.entries.map { it.permission }.toSet() + val capture = Capture() + val player = permissionProxy(Player::class.java, permissions, capture) + execute(player, "ic", args = arrayOf("help", "admin"), capture = capture) + val clicks = capture.components.flatten().mapNotNull { it.clickEvent } + assertTrue(capture.plainText().contains("1/2")) + assertTrue(clicks.any { it.value == "/ic help admin 2" }) + assertTrue(clicks.all { it.action.name == "RUN_COMMAND" && (it.value.startsWith("/ic help") || it.value == "/ic") }) + val detail = Capture() + val detailPlayer = permissionProxy(Player::class.java, permissions, detail) + execute(detailPlayer, "ic", args = arrayOf("help", "admin", "invitation", "transfer"), capture = detail) + assertTrue(detail.plainText().contains("/ic admin invitation transfer ")) + assertTrue(detail.components.flatten().any { it.clickEvent?.value?.startsWith("/ic admin invitation transfer") == true && + it.clickEvent?.action?.name == "SUGGEST_COMMAND" }) + assertTrue(detail.components.flatten().filter { it.clickEvent?.action?.name == "RUN_COMMAND" } + .all { it.clickEvent!!.value.startsWith("/ic help") }) + assertEquals(0, capture.operations + detail.operations) + assertEquals(1, Regex("\\[InviteCode]").findAll(detail.plainText()).count()) + } + + @Test + fun `partial admin cannot see or open a forbidden help branch`() { + val permissions = basicPermissions + "invitecode.admin.qualification" + val capture = Capture() + val player = permissionProxy(Player::class.java, permissions, capture) + execute(player, "ic", args = arrayOf("help", "admin", "invitation"), capture = capture) + assertTrue(capture.plainText().contains("force-qualify")) + assertFalse(capture.plainText().contains("transfer")) + assertFalse(capture.plainText().contains("unlink")) + val denied = Capture() + execute(permissionProxy(Player::class.java, permissions, denied), "ic", + args = arrayOf("help", "admin", "invitation", "unlink"), capture = denied) + assertTrue(denied.plainText().contains("No such help page")) + assertFalse(denied.plainText().contains("")) + } + + @Test + fun `console gets short management index and explicit out of range failure`() { + val capture = Capture() + val sender = permissionProxy(CommandSender::class.java, CommandHelp.entries.map { it.permission }.toSet(), capture) + execute(sender, "ic", args = arrayOf("help", "admin", "2"), capture = capture) + assertTrue(capture.plainText().contains("2/2")) + assertTrue(capture.plainText().contains("storage")) + assertFalse(capture.plainText().contains("claim")) + assertTrue(capture.components.isEmpty()) + assertEquals(1, Regex("\\[InviteCode]").findAll(capture.plainText()).count()) + val invalid = Capture() + execute(permissionProxy(CommandSender::class.java, CommandHelp.entries.map { it.permission }.toSet(), invalid), + "ic", args = arrayOf("help", "admin", "999"), capture = invalid) + assertTrue(invalid.plainText().contains("No such help page")) + } + + @Test + fun `description formatting remains independent from the short usage row`() { + val capture = Capture() + val permissions = basicPermissions + "invitecode.admin.inspect" + val player = permissionProxy(Player::class.java, permissions, capture) + val key = CommandHelp.entries.single { it.id == InviteCodeCommandId.ADMIN_INSPECT_PLAYER }.descriptionKey + execute(player, "ic", messageCatalog(mapOf("runtime.help-row" to "&l{usage} &7— &l{description}", + key to "&cInspect &rPlayer")), args = arrayOf("help", "admin", "inspect"), capture = capture) + assertFalse(capture.plainText().contains("&c")) + assertTrue(capture.components.flatten().any { it.toPlainText() == "Inspect " && it.color == ChatColor.RED && !it.isBold }) + assertTrue(capture.components.flatten().any { it.toPlainText() == "Player" && it.color == ChatColor.WHITE && !it.isBold }) + } + + @Test + fun `invalid help topics pages and excess arguments use help error without executing anything`() { + listOf(arrayOf("help", "typo"), arrayOf("help", "admin", "0"), + arrayOf("help", "admin", "invitation", "transfer", "extra")).forEach { args -> + val capture = Capture() + execute(permissionProxy(Player::class.java, basicPermissions, capture), "ic", args = args, capture = capture) + assertTrue(capture.plainText().contains("No such help page")) + assertEquals(0, capture.operations) + } + } + + @Test + fun `help frames keep inline prefix and all navigation slots without disabled events`() { + listOf(emptyArray(), arrayOf("help", "admin"), arrayOf("help", "admin", "2"), + arrayOf("help", "admin", "invitation", "transfer")).forEach { args -> + val capture = Capture() + val permissions = CommandHelp.entries.map { it.permission }.toSet() + execute(permissionProxy(Player::class.java, permissions, capture), "ic", args = args, capture = capture) + val first = capture.components.first().joinToString("") { it.toPlainText() } + assertTrue(first.contains("[InviteCode]") && first.contains("────")) + val footer = capture.components.last() + assertEquals("[Previous] [Back] [Next]", footer.joinToString("") { it.toPlainText() }) + assertTrue(footer.filter { it.clickEvent != null }.all { + it.color == ChatColor.YELLOW && it.hoverEvent != null && + it.clickEvent.action.name == "RUN_COMMAND" && + (it.clickEvent.value.startsWith("/ic help") || it.clickEvent.value == "/ic") + }) + val disabled = if (args.isEmpty()) listOf("Previous", "Back", "Next") + else if (args.last() == "2") listOf("Next") else if (args.last() == "transfer") listOf("Previous", "Next") + else listOf("Previous") + disabled.forEach { name -> + val parts = footer.filter { it.toPlainText().contains(name) } + assertTrue(parts.isNotEmpty()) + assertTrue(parts.all { it.clickEvent == null && it.hoverEvent == null && it.color == ChatColor.DARK_GRAY }) + } + assertEquals(1, Regex("\\[InviteCode]").findAll(capture.plainText()).count()) + } + } + + @Test + fun `empty custom prefix stays empty and console root has one help entrance`() { + val capture = Capture() + execute(permissionProxy(CommandSender::class.java, basicPermissions, capture), "ic", + messageCatalog(mapOf("presentation.prefix" to "")), capture = capture) + assertFalse(capture.plainText().contains("[InviteCode]")) + assertTrue(capture.plainText().contains("──── Console home")) + assertFalse(capture.plainText().contains("[Previous]")) + assertFalse(capture.plainText().contains("/ic help admin")) + assertEquals(0, capture.operations) + } + + @Test + fun `reload detail return button points to its second management page`() { + val capture = Capture() + val player = permissionProxy(Player::class.java, CommandHelp.entries.map { it.permission }.toSet(), capture) + execute(player, "ic", args = arrayOf("help", "admin", "reload"), capture = capture) + assertTrue(capture.components.last().any { it.clickEvent?.value == "/ic help admin 2" }) + assertEquals(0, capture.operations) + } + + private val basicPermissions = setOf("invitecode.command.basic", "invitecode.command.code", "invitecode.command.claim", + "invitecode.command.status", "invitecode.command.stats") + + private fun execute(sender: CommandSender, label: String, catalog: LocalizedMessages = messageCatalog(), + args: Array = emptyArray(), capture: Capture = Capture()) { + val runtime = PluginRuntimeState().apply { activate() } + val executor = RuntimeCommandExecutor( + runtime = runtime, + messages = { catalog }, + reload = { capture.operations++ }, + migrateStorage = { _, _ -> capture.operations++ }, + playerWorkflow = { _, _ -> capture.operations++; true }, + adminWorkflow = { _, _ -> capture.operations++; true }, + doctor = { capture.operations++ }, + ) + val command = object : Command("invitecode") { + override fun execute(sender: CommandSender, commandLabel: String, args: Array) = true + } + assertTrue(executor.onCommand(sender, command, label, args)) + } + + private fun messageCatalog(overrides: Map = emptyMap()): LocalizedMessages { + val catalog = mutableMapOf( + "presentation.prefix" to "[InviteCode]", + "runtime.raw-output" to "{text}", + "runtime.help-header" to "Help", + "runtime.help-home-header" to "Home", + "runtime.help-console-home-header" to "Console home", + "runtime.help-console-navigation-title" to "Navigation", + "runtime.help-topic.console" to "Console", + "runtime.help-frame-header" to "&8──── {prefix}&6{title} &8────", + "runtime.help-frame-divider" to "&8────────────────────────", + "runtime.help-navigation-enabled" to "&e[{text}]", + "runtime.help-navigation-disabled" to "&8[{text}]", + "runtime.help-navigation-hover" to "Open help page", + "runtime.help-page-header" to "{topic} {page}/{pages}", + "runtime.help-page-error" to "No such help page", + "runtime.help-open-detail" to "Open help", + "runtime.help-previous" to "Previous", "runtime.help-next" to "Next", "runtime.help-back" to "Back", + "runtime.help-player-section" to "Players", + "runtime.help-admin-section" to "Administration", + "runtime.help-row" to "{usage} - {description} ({usage})", + ) + CommandHelp.entries.forEach { entry -> + catalog[entry.descriptionKey] = "Description:${entry.descriptionKey.substringAfterLast('.')}" + catalog[entry.descriptionKey.replace("help-description", "help-detail")] = "{usage}\nDetails\nExample: {example}" + } + listOf("player", "admin", "inspect", "invitation", "eligibility", "reward", "code", "storage", "reload", "doctor") + .forEach { topic -> catalog["runtime.help-topic.$topic"] = "Topic:$topic"; catalog["runtime.help-topic-description.$topic"] = "Category:$topic" } + catalog.putAll(overrides) + return LocalizedMessages("en_US", false, mapOf("en_US" to catalog)) + } + + private class Capture { + var operations = 0 + val lines = mutableListOf() + val components = mutableListOf>() + + fun playerSpigot(): Player.Spigot = object : Player.Spigot() { + override fun sendMessage(vararg components: BaseComponent) { + this@Capture.components.add(components.toList()) + } + } + + fun plainText() = (lines.joinToString("\n") + components.joinToString("\n") { row -> + row.joinToString("") { it.toPlainText() } }).replace(Regex("§[0-9a-fk-or]"), "") + } + + private fun permissionProxy(type: Class, permissions: Set, capture: Capture): T = + Proxy.newProxyInstance(javaClass.classLoader, arrayOf(type)) { _, method, args -> + when (method.name) { + "hasPermission" -> permissions.contains(args?.get(0)) + "spigot" -> capture.playerSpigot() + "sendMessage" -> { + if (args?.firstOrNull() is String) capture.lines.add(args[0] as String) + null + } + "getName" -> "Tester" + "isOnline" -> true + else -> defaultValue(method.returnType) + } + } as T + + private fun defaultValue(type: Class<*>): Any? = when (type) { + java.lang.Boolean.TYPE -> false + java.lang.Integer.TYPE -> 0 + java.lang.Long.TYPE -> 0L + java.lang.Double.TYPE -> 0.0 + java.lang.Float.TYPE -> 0.0f + java.lang.Short.TYPE -> 0.toShort() + java.lang.Byte.TYPE -> 0.toByte() + java.lang.Character.TYPE -> '\u0000' + else -> null + } +} diff --git a/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandOutputTest.kt b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandOutputTest.kt new file mode 100644 index 0000000..af9aada --- /dev/null +++ b/invitecode-plugin/src/test/kotlin/io/github/command1264/invitecode/plugin/RuntimeCommandOutputTest.kt @@ -0,0 +1,43 @@ +package io.github.command1264.invitecode.plugin + +import io.github.command1264.invitecode.platform.bukkit.LocalizedMessages +import io.github.command1264.invitecode.platform.bukkit.PluginRuntimeState +import org.bukkit.command.Command +import org.bukkit.command.CommandSender +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test +import java.lang.reflect.Proxy + +class RuntimeCommandOutputTest { + @Test + fun `console only rejects player routes while administrative command remains executable`() { + val sent = mutableListOf() + val console = Proxy.newProxyInstance(javaClass.classLoader, arrayOf(CommandSender::class.java)) { _, method, args -> + when (method.name) { + "hasPermission" -> true + "sendMessage" -> { if (args?.firstOrNull() is String) sent.add(args[0] as String); null } + else -> null + } + } as CommandSender + val messages = LocalizedMessages("zh_TW", false, mapOf("zh_TW" to mapOf( + "presentation.prefix" to "&7[&6InviteCode&7]&r", + "runtime.player-only" to "&e此指令只能由玩家執行。", + ))) + var doctorCalls = 0 + val executor = RuntimeCommandExecutor(PluginRuntimeState().apply { activate() }, { messages }, + reload = {}, migrateStorage = { _, _ -> }, + playerWorkflow = { _, _ -> error("console must not execute player workflow") }, + adminWorkflow = { _, _ -> true }, doctor = { doctorCalls++ }, + ) + val command = object : Command("invitecode") { + override fun execute(sender: CommandSender, commandLabel: String, args: Array) = true + } + executor.onCommand(console, command, "ic", arrayOf("code")) + assertEquals("[InviteCode] 此指令只能由玩家執行。", sent.single().replace(Regex("§."), "")) + assertTrue(sent.single().contains("§e")) + executor.onCommand(console, command, "ic", arrayOf("admin", "doctor")) + assertEquals(1, doctorCalls) + assertEquals(1, sent.size) + } +} diff --git a/invitecode-storage-json/src/main/kotlin/io/github/command1264/invitecode/storage/json/JsonInviteCodeStorage.kt b/invitecode-storage-json/src/main/kotlin/io/github/command1264/invitecode/storage/json/JsonInviteCodeStorage.kt index 935d5e6..110b74b 100644 --- a/invitecode-storage-json/src/main/kotlin/io/github/command1264/invitecode/storage/json/JsonInviteCodeStorage.kt +++ b/invitecode-storage-json/src/main/kotlin/io/github/command1264/invitecode/storage/json/JsonInviteCodeStorage.kt @@ -45,7 +45,7 @@ class JsonInviteCodeStorage private constructor( private var failed = false private fun persist(operation: () -> T): T = synchronized(this) { - check(!closed && !failed) { "JSON storage is closed or a previous write failed; restart after inspecting ${file.toAbsolutePath()}." } + check(!closed && !failed) { "JSON storage is closed or a previous write failed\nrestart after inspecting ${file.toAbsolutePath()}." } guard.checkAllowed() val result = operation() try { @@ -54,7 +54,7 @@ class JsonInviteCodeStorage private constructor( } catch (error: Exception) { failed = true throw JsonStorageException( - "JSON snapshot write failed for ${file.toAbsolutePath()}; writes are stopped. " + + "JSON snapshot write failed for ${file.toAbsolutePath()}\nwrites are stopped. " + "Preserve the JSON file and its .previous copy, then restart after fixing the cause.", error, ) } @@ -131,10 +131,10 @@ class JsonInviteCodeStorage private constructor( guard.checkAllowed() val target = file.toAbsolutePath().normalize() require(Files.isDirectory(requireNotNull(target.parent))) { "JSON destination directory must exist." } - require(!Files.exists(target)) { "JSON destination already exists; do not overwrite it." } + require(!Files.exists(target)) { "JSON destination already exists\ndo not overwrite it." } val lockChannel = FileChannel.open(target.resolveSibling("${target.fileName}.lock"), CREATE, WRITE) val lock = try { - lockChannel.tryLock() ?: throw JsonStorageException("JSON destination is already open; stop every instance.") + lockChannel.tryLock() ?: throw JsonStorageException("JSON destination is already open\nstop every instance.") } catch (error: Exception) { lockChannel.close() throw error @@ -174,7 +174,7 @@ class JsonInviteCodeStorage private constructor( require(Files.isRegularFile(target)) { "JSON storage must exist before migration." } val lockChannel = FileChannel.open(target.resolveSibling("${target.fileName}.lock"), CREATE, WRITE) val lock = try { - lockChannel.tryLock() ?: throw JsonStorageException("JSON storage is already open; stop every instance.") + lockChannel.tryLock() ?: throw JsonStorageException("JSON storage is already open\nstop every instance.") } catch (error: Exception) { lockChannel.close() throw error @@ -222,7 +222,7 @@ class JsonInviteCodeStorage private constructor( ?: throw JsonStorageException("JSON storage ${target} is already open by another process.") } catch (error: Exception) { lockChannel.close() - throw JsonStorageException("Cannot lock JSON storage ${target}; another instance may be using it.", error) + throw JsonStorageException("Cannot lock JSON storage ${target}\nanother instance may be using it.", error) } val workingDirectory = try { Files.createTempDirectory("invitecode-json-") @@ -319,18 +319,18 @@ class JsonInviteCodeStorage private constructor( Files.newBufferedReader(file, StandardCharsets.UTF_8).use { JsonParser.parseReader(it).asJsonObject } } catch (error: Exception) { throw JsonStorageException( - "JSON storage ${file.toAbsolutePath()} is damaged. Preserve it and inspect ${file.fileName}.previous; " + + "JSON storage ${file.toAbsolutePath()} is damaged. Preserve it and inspect ${file.fileName}.previous\n" + "no new database was created over it.", error, ) } try { val format = root.get("format-version")?.asString?.takeIf { it.matches(Regex("[0-9]+")) }?.toIntOrNull() require(format == FORMAT_VERSION) { - "JSON format version $format is unsupported; expected $FORMAT_VERSION. Preserve the file and upgrade InviteCode." + "JSON format version $format is unsupported\nexpected $FORMAT_VERSION. Preserve the file and upgrade InviteCode." } val schemaVersion = root.get("schema-version")?.asString?.takeIf { it.matches(Regex("[0-9]+")) }?.toIntOrNull() require(schemaVersion == expectedSchemaVersion) { - "JSON schema version $schemaVersion is unsupported; expected $expectedSchemaVersion. " + + "JSON schema version $schemaVersion is unsupported\nexpected $expectedSchemaVersion. " + "Preserve the file and run an explicit migration with a compatible InviteCode version." } require(root.keySet() == setOf("format-version", "schema-version", "tables")) { @@ -386,7 +386,7 @@ class JsonInviteCodeStorage private constructor( } catch (error: Exception) { throw JsonStorageException( "Cannot load JSON storage ${file.toAbsolutePath()}: ${error.message}. " + - "Preserve it and ${file.fileName}.previous; no existing JSON data was overwritten.", error, + "Preserve it and ${file.fileName}.previous\nno existing JSON data was overwritten.", error, ) } } diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlInviteCodeStorage.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlInviteCodeStorage.kt index 1e710af..69b0ff8 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlInviteCodeStorage.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlInviteCodeStorage.kt @@ -36,7 +36,7 @@ class MysqlInviteCodeStorage private constructor( return HikariDataSource(hikari) } catch (error: Exception) { throw MysqlStorageException( - "MySQL connection pool could not start at ${config.host}:${config.port}/${config.database}; " + + "MySQL connection pool could not start at ${config.host}:${config.port}/${config.database}\n" + "check server availability, TLS and credentials.", ) } diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlSchemaMigrator.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlSchemaMigrator.kt index 386465d..9c37ee4 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlSchemaMigrator.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/MysqlSchemaMigrator.kt @@ -23,7 +23,7 @@ class MysqlSchemaMigrator( statement.setString(1, lockName) statement.executeQuery().use { result -> result.next() && result.getInt(1) == 1 } } - if (!acquired) throw MysqlStorageException("MySQL schema lock timed out; retry when other plugin instances finish migration.") + if (!acquired) throw MysqlStorageException("MySQL schema lock timed out\nretry when other plugin instances finish migration.") try { migrateLocked(connection, schema) } finally { @@ -36,7 +36,7 @@ class MysqlSchemaMigrator( return CURRENT_VERSION } catch (error: SQLException) { throw MysqlStorageException( - "MySQL schema migration failed (SQLState ${error.sqlState ?: "unknown"}, code ${error.errorCode}); " + + "MySQL schema migration failed (SQLState ${error.sqlState ?: "unknown"}, code ${error.errorCode})\n" + "inspect the database before retrying. No secret was logged.", ) } @@ -49,7 +49,7 @@ class MysqlSchemaMigrator( buildSet { while (rows.next()) add(rows.getString("TABLE_NAME")) } } if (existingObjects.isNotEmpty() && existingObjects != setOf(TRANSFER_GUARD)) throw MysqlStorageException( - "MySQL database is not empty and has no migration ledger; preserve the database and inspect it manually.", + "MySQL database is not empty and has no migration ledger\npreserve the database and inspect it manually.", ) if (existingObjects == setOf(TRANSFER_GUARD)) OfflineStorageTransfer.verifyMysqlTransferGuard(connection) connection.createStatement().use { statement -> statement.execute(LEDGER_DDL) } @@ -61,7 +61,7 @@ class MysqlSchemaMigrator( } } if (otherVersions != 0) throw MysqlStorageException( - "MySQL schema contains another version; a separate explicit migration is required.", + "MySQL schema contains another version\na separate explicit migration is required.", ) val state = connection.prepareStatement( "SELECT checksum, state FROM $LEDGER WHERE version = ?", @@ -76,10 +76,10 @@ class MysqlSchemaMigrator( statement.executeQuery("SELECT 1 FROM $LEDGER WHERE version = 2").use { it.next() } } if (hasLaterVersion) throw MysqlStorageException( - "MySQL migration ledger contains version 2 without version 1; preserve the database.", + "MySQL migration ledger contains version 2 without version 1\npreserve the database.", ) if (TABLES.any { tableExists(connection, schema, it.name) }) { - throw MysqlStorageException("MySQL schema ledger has no version record, but InviteCode tables exist; inspect manually.") + throw MysqlStorageException("MySQL schema ledger has no version record, but InviteCode tables exist\ninspect manually.") } connection.prepareStatement( "INSERT INTO $LEDGER(version, checksum, state) VALUES (?, ?, 'APPLYING')", @@ -90,15 +90,15 @@ class MysqlSchemaMigrator( } } else { if (state.first != CHECKSUM) throw MysqlStorageException( - "MySQL schema checksum differs from the bundled migration; preserve the database and inspect manually.", + "MySQL schema checksum differs from the bundled migration\npreserve the database and inspect manually.", ) if (state.second !in setOf("APPLYING", "APPLIED")) throw MysqlStorageException( - "MySQL schema ledger has unknown state ${state.second}; preserve the database.", + "MySQL schema ledger has unknown state ${state.second}\npreserve the database.", ) } TABLES.forEach { table -> if (!tableExists(connection, schema, table.name)) { - if (state?.second == "APPLIED") throw MysqlStorageException("MySQL table ${table.name} is missing; preserve the database.") + if (state?.second == "APPLIED") throw MysqlStorageException("MySQL table ${table.name} is missing\npreserve the database.") connection.createStatement().use { statement -> statement.execute(table.ddl) } afterTable(table.name) } @@ -115,17 +115,17 @@ class MysqlSchemaMigrator( } if (second == null) { if (tableExists(connection, schema, V2_TABLE.name)) throw MysqlStorageException( - "MySQL reserved-code table exists without a migration record; inspect the database.", + "MySQL reserved-code table exists without a migration record\ninspect the database.", ) connection.prepareStatement("INSERT INTO $LEDGER(version, checksum, state) VALUES (2, ?, 'APPLYING')").use { it.setString(1, V2_CHECKSUM) it.executeUpdate() } } else if (second.first != V2_CHECKSUM || second.second !in setOf("APPLYING", "APPLIED")) { - throw MysqlStorageException("MySQL reserved-code migration checksum or state differs; preserve the database.") + throw MysqlStorageException("MySQL reserved-code migration checksum or state differs\npreserve the database.") } if (!tableExists(connection, schema, V2_TABLE.name)) { - if (second?.second == "APPLIED") throw MysqlStorageException("MySQL reserved-code table is missing; preserve the database.") + if (second?.second == "APPLIED") throw MysqlStorageException("MySQL reserved-code table is missing\npreserve the database.") connection.createStatement().use { it.execute(V2_TABLE.ddl) } afterTable(V2_TABLE.name) } @@ -181,7 +181,7 @@ class MysqlSchemaMigrator( fun requireCurrent(connection: Connection) { val schema = schemaName(connection) if (!tableExists(connection, schema, LEDGER)) throw MysqlStorageException( - "MySQL schema is not initialized; run explicit storage migration or use an empty database for first startup.", + "MySQL schema is not initialized\nrun explicit storage migration or use an empty database for first startup.", ) val otherVersions = connection.createStatement().use { statement -> statement.executeQuery("SELECT COUNT(*) FROM $LEDGER WHERE version NOT IN (1, 2)").use { rows -> @@ -190,7 +190,7 @@ class MysqlSchemaMigrator( } } if (otherVersions != 0) throw MysqlStorageException( - "MySQL schema contains another version; use a matching InviteCode version or explicit migration.", + "MySQL schema contains another version\nuse a matching InviteCode version or explicit migration.", ) val row = connection.prepareStatement("SELECT checksum, state FROM $LEDGER WHERE version = ?").use { statement -> statement.setInt(1, 1) @@ -199,7 +199,7 @@ class MysqlSchemaMigrator( } } if (row != (CHECKSUM to "APPLIED")) throw MysqlStorageException( - "MySQL schema version/checksum is not current; run explicit storage migration after inspecting the database.", + "MySQL schema version/checksum is not current\nrun explicit storage migration after inspecting the database.", ) TABLES.forEach { verifyTable(connection, schema, it) } val version2 = connection.prepareStatement("SELECT checksum, state FROM $LEDGER WHERE version = 2").use { statement -> @@ -208,7 +208,7 @@ class MysqlSchemaMigrator( } } if (version2 != (V2_CHECKSUM to "APPLIED")) throw MysqlStorageException( - "MySQL reserved-code migration is not current; run explicit migration after a backup.", + "MySQL reserved-code migration is not current\nrun explicit migration after a backup.", ) verifyTable(connection, schema, V2_TABLE) } @@ -228,7 +228,7 @@ class MysqlSchemaMigrator( } } if (stored != keyId) throw MysqlStorageException( - "MySQL network secret differs from the key used by another plugin instance; use the shared secret.", + "MySQL network secret differs from the key used by another plugin instance\nuse the shared secret.", ) } @@ -276,7 +276,7 @@ class MysqlSchemaMigrator( found == null || found.type != shape.type || found.nullable != shape.nullable || (shape.length != null && found.length != shape.length) }) { - throw MysqlStorageException("MySQL table ${table.name} has unexpected columns; preserve the database and inspect manually.") + throw MysqlStorageException("MySQL table ${table.name} has unexpected columns\npreserve the database and inspect manually.") } val collations = connection.prepareStatement( "SELECT COLUMN_NAME, COLLATION_NAME FROM information_schema.COLUMNS " + @@ -289,7 +289,7 @@ class MysqlSchemaMigrator( } } if (expected.any { (name, shape) -> shape.collation != null && collations[name] != shape.collation }) { - throw MysqlStorageException("MySQL table ${table.name} has an unsafe collation; preserve the database.") + throw MysqlStorageException("MySQL table ${table.name} has an unsafe collation\npreserve the database.") } val generated = Regex("(?m)^ ([a-z_]+) [^\\r\\n]*(?:\\r?\\n [^\\r\\n]*)?GENERATED ALWAYS AS") .findAll(table.ddl).map { it.groupValues[1] }.toSet() @@ -305,7 +305,7 @@ class MysqlSchemaMigrator( } } if (actualGenerated.keys != generated || actualGenerated.values.any(String::isNullOrBlank)) { - throw MysqlStorageException("MySQL table ${table.name} has unexpected generated columns; preserve the database.") + throw MysqlStorageException("MySQL table ${table.name} has unexpected generated columns\npreserve the database.") } } val indexes = connection.metaData.getIndexInfo(schema, null, table.name, false, false).use { rows -> @@ -332,7 +332,7 @@ class MysqlSchemaMigrator( ?.split(',')?.map(String::trim) if (primary == null || indexes["PRIMARY"] != IndexShape(primary, true) || requiredIndexes.any { (name, shape) -> indexes[name] != shape }) { - throw MysqlStorageException("MySQL table ${table.name} has unexpected indexes; preserve the database and inspect manually.") + throw MysqlStorageException("MySQL table ${table.name} has unexpected indexes\npreserve the database and inspect manually.") } val expectedForeignKeys = Regex( "(?m)^ CONSTRAINT ([a-z_]+) FOREIGN KEY \\(([^)]+)\\) REFERENCES ([a-z_]+)\\(([^)]+)\\)", @@ -348,7 +348,7 @@ class MysqlSchemaMigrator( } } if (expectedForeignKeys != actualForeignKeys) throw MysqlStorageException( - "MySQL table ${table.name} has unexpected foreign keys; preserve the database and inspect manually.", + "MySQL table ${table.name} has unexpected foreign keys\npreserve the database and inspect manually.", ) val checkCount = connection.prepareStatement( "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS " + @@ -360,7 +360,7 @@ class MysqlSchemaMigrator( } val expectedCheckCount = Regex("(?m)^ CONSTRAINT [a-z_]+ CHECK ").findAll(table.ddl).count() if (checkCount != expectedCheckCount) throw MysqlStorageException( - "MySQL table ${table.name} has unexpected check constraints; preserve the database.", + "MySQL table ${table.name} has unexpected check constraints\npreserve the database.", ) val properties = connection.prepareStatement( "SELECT ENGINE, TABLE_COLLATION FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?", @@ -372,7 +372,7 @@ class MysqlSchemaMigrator( } } if (!"InnoDB".equals(properties?.first, ignoreCase = true) || properties?.second != "utf8mb4_0900_ai_ci") throw MysqlStorageException( - "MySQL table ${table.name} must use InnoDB and utf8mb4_0900_ai_ci; preserve the database.", + "MySQL table ${table.name} must use InnoDB and utf8mb4_0900_ai_ci\npreserve the database.", ) } diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflinePlayerAnonymizer.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflinePlayerAnonymizer.kt index 637b109..7d6558c 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflinePlayerAnonymizer.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflinePlayerAnonymizer.kt @@ -38,13 +38,13 @@ internal object OfflinePlayerAnonymizer { statement.setString(1, playerId.toString()) statement.executeQuery().use { it.next() } } - check(locked) { "Player $playerId is absent; it may already be anonymized." } + check(locked) { "Player $playerId is absent\nit may already be anonymized." } } val scope = collect(connection, playerId) val old = playerId.toString() val historical = UUID.randomUUID().toString() check(row(connection, "invitecode_players", "player_id", historical) == null) { - "Generated historical ID collided with an existing player; retry after rollback." + "Generated historical ID collided with an existing player\nretry after rollback." } val player = requireNotNull(row(connection, "invitecode_players", "player_id", old)) insert(connection, "invitecode_players", player + ("player_id" to historical) + ("last_known_name" to null)) @@ -184,7 +184,7 @@ internal object OfflinePlayerAnonymizer { } statement.executeQuery().use { rows -> check(!rows.next()) { - "Player name remains in $table; anonymization was rolled back. " + + "Player name remains in $table\nanonymization was rolled back. " + "Inspect unrelated free text and unresolved rewards before retrying." } } @@ -222,7 +222,7 @@ internal object OfflinePlayerAnonymizer { textColumns.indices.forEach { index -> statement.setString(index + 1, "%$needle%") } statement.executeQuery().use { rows -> check(!rows.next()) { - "Original Minecraft UUID remains in $table; anonymization was rolled back. " + + "Original Minecraft UUID remains in $table\nanonymization was rolled back. " + "Inspect related text without exposing private data." } } @@ -239,7 +239,7 @@ internal object OfflinePlayerAnonymizer { private fun collect(connection: Connection, playerId: UUID): Scope { val id = playerId.toString() check(row(connection, "invitecode_players", "player_id", id) != null) { - "Player $id is absent; it may already be anonymized." + "Player $id is absent\nit may already be anonymized." } val invitations = queryIds(connection, "SELECT invitation_id FROM invitecode_invitations WHERE inviter_id = ? OR invitee_id = ?", id, id) @@ -255,11 +255,11 @@ internal object OfflinePlayerAnonymizer { deliveries.forEach { deliveryId -> val delivery = requireNotNull(row(connection, "invitecode_reward_deliveries", "delivery_id", deliveryId)) check(delivery["status"] !in unsettled) { - "Reward Delivery $deliveryId is unresolved; resolve it before anonymization." + "Reward Delivery $deliveryId is unresolved\nresolve it before anonymization." } queryIds(connection, "SELECT status FROM invitecode_reward_actions WHERE reward_delivery_id = ?", deliveryId) .forEach { status -> check(status !in unsettled) { - "Reward Delivery $deliveryId contains an unresolved action; resolve it before anonymization." + "Reward Delivery $deliveryId contains an unresolved action\nresolve it before anonymization." } } } val codes = queryIds(connection, "SELECT code FROM invitecode_codes WHERE inviter_id = ?", id) diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflineStorageTransfer.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflineStorageTransfer.kt index 7404872..6dc1ceb 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflineStorageTransfer.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/OfflineStorageTransfer.kt @@ -90,12 +90,12 @@ object OfflineStorageTransfer { } catch (rollbackError: SQLException) { error.addSuppressed(rollbackError) throw StorageTransferException( - "Storage import failed and rollback also failed; destination state is uncertain. " + + "Storage import failed and rollback also failed\ndestination state is uncertain. " + "Keep both backends offline and inspect the destination before retrying.", error, ) } throw if (error is StorageTransferException) error else StorageTransferException( - "Storage import failed; the destination transaction was rolled back. " + + "Storage import failed\nthe destination transaction was rolled back. " + "Inspect the cause before retrying.", error, ) } finally { @@ -103,7 +103,7 @@ object OfflineStorageTransfer { connection.autoCommit = originalAutoCommit } catch (restoreError: SQLException) { throw StorageTransferException( - "Storage import completed or rolled back, but the connection mode could not be restored; " + + "Storage import completed or rolled back, but the connection mode could not be restored\n" + "close the connection and inspect the destination state.", restoreError, ) } @@ -154,7 +154,7 @@ object OfflineStorageTransfer { } } check(columns == listOf(Triple("singleton", "INT", DatabaseMetaData.columnNoNulls))) { - "MySQL transfer guard table has an unexpected structure; preserve it and inspect the database." + "MySQL transfer guard table has an unexpected structure\npreserve it and inspect the database." } val primaryKey = connection.metaData.getPrimaryKeys(connection.catalog, null, MYSQL_TRANSFER_GUARD).use { rows -> if (rows.next()) rows.getString("COLUMN_NAME") else null @@ -219,7 +219,7 @@ object OfflineStorageTransfer { val table = tables.single { it.name == name } val keyColumn = table.columns.indexOf("key_id") check(keyColumn >= 0 && table.rows.all { it.values[keyColumn] == PortableValue.Text(keyId) }) { - "$name contains rows from another anti-abuse key; restore the matching key or resolve those rows before transfer." + "$name contains rows from another anti-abuse key\nrestore the matching key or resolve those rows before transfer." } } } @@ -229,7 +229,7 @@ object OfflineStorageTransfer { StorageDialect.SQLITE -> { val version = connection.createStatement().use { statement -> statement.executeQuery("SELECT version FROM invitecode_schema_version WHERE singleton = 1").use { rows -> - check(rows.next()) { "SQLite schema version row is missing; initialize the schema first." } + check(rows.next()) { "SQLite schema version row is missing\ninitialize the schema first." } rows.getInt(1).also { check(!rows.next()) { "SQLite schema version row is not unique." } } } } @@ -246,12 +246,12 @@ object OfflineStorageTransfer { connection.createStatement().use { statement -> statement.executeQuery("PRAGMA integrity_check").use { rows -> check(rows.next() && rows.getString(1) == "ok" && !rows.next()) { - "Source integrity check failed; keep the source offline and restore or repair a verified backup." + "Source integrity check failed\nkeep the source offline and restore or repair a verified backup." } } statement.executeQuery("PRAGMA foreign_key_check").use { rows -> check(!rows.next()) { - "Source foreign-key integrity check failed; restore or repair missing related records before transfer." + "Source foreign-key integrity check failed\nrestore or repair missing related records before transfer." } } } @@ -271,7 +271,7 @@ object OfflineStorageTransfer { val parent = BUSINESS_TABLES.singleOrNull { it.name == parentName } check(child.columns.any { it.name == childColumn } && parent != null && parent.columns.any { it.name == parentColumn }) { - "Source foreign-key layout is unsupported; inspect the schema before transfer." + "Source foreign-key layout is unsupported\ninspect the schema before transfer." } connection.createStatement().use { statement -> statement.executeQuery( @@ -280,7 +280,7 @@ object OfflineStorageTransfer { "WHERE child.$childColumn IS NOT NULL AND parent.$parentColumn IS NULL LIMIT 1", ).use { rows -> check(!rows.next()) { - "Source foreign-key integrity check failed in ${child.name}; " + + "Source foreign-key integrity check failed in ${child.name}\n" + "restore or repair missing related records before transfer." } } @@ -299,7 +299,7 @@ object OfflineStorageTransfer { ).use { statement -> statement.setInt(1, 1) statement.executeQuery().use { rows -> - check(rows.next()) { "MySQL network_key_id metadata is missing; bind it before transfer." } + check(rows.next()) { "MySQL network_key_id metadata is missing\nbind it before transfer." } rows.getString(1).also { check(!rows.next()) { "MySQL metadata singleton row is not unique." } } } } @@ -325,7 +325,7 @@ object OfflineStorageTransfer { val count = connection.createStatement().use { statement -> statement.executeQuery("SELECT COUNT(*) FROM ${spec.name}").use { rows -> rows.next(); rows.getLong(1) } } - check(count == 0L) { "Destination table ${spec.name} is not empty; refusing to overwrite existing data." } + check(count == 0L) { "Destination table ${spec.name} is not empty\nrefusing to overwrite existing data." } } if (dialect == StorageDialect.MYSQL) { val rows = connection.createStatement().use { statement -> diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteIdentityRecords.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteIdentityRecords.kt index a3895f3..10dc484 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteIdentityRecords.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteIdentityRecords.kt @@ -282,7 +282,7 @@ internal object SqliteInviteCodeRecords { val tombstonesExist = connection.createStatement().use { statement -> statement.executeQuery("SELECT 1 FROM invitecode_reserved_code_hashes LIMIT 1").use { it.next() } } - check(!tombstonesExist) { "Reserved Invite Codes exist, but their secret is unavailable; code allocation is disabled." } + check(!tombstonesExist) { "Reserved Invite Codes exist, but their secret is unavailable\ncode allocation is disabled." } return false } val foreignKey = connection.prepareStatement( @@ -291,7 +291,7 @@ internal object SqliteInviteCodeRecords { statement.setString(1, reservationKey.keyId) statement.executeQuery().use { it.next() } } - check(!foreignKey) { "Reserved Invite Codes use another anti-abuse key; restore the original secret." } + check(!foreignKey) { "Reserved Invite Codes use another anti-abuse key\nrestore the original secret." } return connection.prepareStatement( "SELECT 1 FROM invitecode_reserved_code_hashes WHERE code_hash = ?", ).use { statement -> diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInvitationRecords.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInvitationRecords.kt index 62417c8..3ca2b50 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInvitationRecords.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInvitationRecords.kt @@ -57,7 +57,7 @@ internal object SqliteInvitationRecords { val current = find(connection, transition.previousInvitation.id) if (current != transition.previousInvitation) { throw SqliteStorageException( - "Invitation ${transition.previousInvitation.id} changed before the audited transition; " + + "Invitation ${transition.previousInvitation.id} changed before the audited transition\n" + "reload it and retry the administrative operation.", ) } @@ -123,6 +123,24 @@ internal object SqliteInvitationRecords { } } + fun currentStatusByInvitee(connection: Connection, inviteeId: UUID): InvitationStatus? = + connection.prepareStatement( + """ + SELECT i.status + FROM invitecode_invitations i + JOIN invitecode_players p ON p.player_id = i.invitee_id + AND p.eligibility_generation = i.invitee_eligibility_generation + WHERE i.invitee_id = ? + ORDER BY i.claimed_at DESC, i.invitation_id DESC + LIMIT 1 + """.trimIndent(), + ).use { statement -> + statement.setString(1, inviteeId.toString()) + statement.executeQuery().use { result -> + if (result.next()) InvitationStatus.valueOf(result.getString("status")) else null + } + } + fun findByInvitee(connection: Connection, inviteeId: UUID): List = findByPlayerColumn(connection, "invitee_id", inviteeId) diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorage.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorage.kt index 0cd0e9c..214e494 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorage.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorage.kt @@ -110,6 +110,10 @@ internal class JdbcInviteCodeStorage private constructor( SqliteInvitationRecords.findByInviter(it, inviterId) } + override fun currentInviteeInvitationStatus(inviteeId: UUID) = read { + SqliteInvitationRecords.currentStatusByInvitee(it, inviteeId) + } + override fun inviterInvitationStats(inviterId: UUID): InviterInvitationStats = read { SqliteInvitationRecords.statsForInviter(it, inviterId) } @@ -216,7 +220,7 @@ internal class JdbcInviteCodeStorage private constructor( action.copy( status = RewardActionStatus.UNCERTAIN, updatedAt = recoveredAt, - lastError = "Interrupted while processing; delivery result is unknown.", + lastError = "Interrupted while processing\ndelivery result is unknown.", ), ) } @@ -235,7 +239,7 @@ internal class JdbcInviteCodeStorage private constructor( "Reward Action $actionId does not exist." } require(current.status == RewardActionStatus.UNCERTAIN) { - "Only an uncertain Reward Action can be resolved; current status is ${current.status}." + "Only an uncertain Reward Action can be resolved\ncurrent status is ${current.status}." } val resolved = current.copy( status = when (resolution) { @@ -436,7 +440,7 @@ internal class JdbcInviteCodeStorage private constructor( statement.setString(1, lockName) statement.executeQuery().use { rows -> rows.next() && rows.getInt(1) == 1 } } - check(acquired) { "MySQL anonymization lock timed out; check other maintenance processes." } + check(acquired) { "MySQL anonymization lock timed out\ncheck other maintenance processes." } try { write { OfflinePlayerAnonymizer.anonymize(it, playerId, key.keyId, key::hash) } } finally { @@ -495,7 +499,7 @@ internal class JdbcInviteCodeStorage private constructor( connection.rollback() } catch (rollbackError: Throwable) { throw MysqlStorageException( - "MySQL write and rollback both failed; state is uncertain. Stop writes and inspect the database.", + "MySQL write and rollback both failed\nstate is uncertain. Stop writes and inspect the database.", ) } throw error @@ -524,10 +528,10 @@ internal class JdbcInviteCodeStorage private constructor( private fun storageFailure(operation: String, cause: SQLException): IllegalStateException = if (mysqlSource != null) MysqlStorageException( - "MySQL $operation failed (SQLState ${cause.sqlState ?: "unknown"}, code ${cause.errorCode}); " + + "MySQL $operation failed (SQLState ${cause.sqlState ?: "unknown"}, code ${cause.errorCode})\n" + "check database availability, schema and pool capacity. The operation was rejected.", ) else SqliteStorageException( - "SQLite $operation failed for ${requireNotNull(database).toAbsolutePath()}; " + + "SQLite $operation failed for ${requireNotNull(database).toAbsolutePath()}\n" + "the storage operation was rejected and no fallback backend was used.", cause, ) @@ -555,7 +559,7 @@ internal class JdbcInviteCodeStorage private constructor( readSchemaVersion(connection) } catch (error: Exception) { throw SqliteStorageException( - "SQLite database ${database.toAbsolutePath()} is not initialized; " + + "SQLite database ${database.toAbsolutePath()} is not initialized\n" + "run the explicit schema migration before opening storage.", error, ) @@ -563,7 +567,7 @@ internal class JdbcInviteCodeStorage private constructor( if (version != SqliteSchemaMigrator.currentVersion) { throw SqliteStorageException( "SQLite schema version $version does not match required version " + - "${SqliteSchemaMigrator.currentVersion}; run the explicit schema migration.", + "${SqliteSchemaMigrator.currentVersion}\nrun the explicit schema migration.", ) } if (reservationKey != null) { @@ -573,7 +577,7 @@ internal class JdbcInviteCodeStorage private constructor( statement.setString(1, reservationKey.keyId) statement.executeQuery().use { it.next() } } - check(!otherKey) { "Reserved Invite Codes use another anti-abuse key; restore the original secret." } + check(!otherKey) { "Reserved Invite Codes use another anti-abuse key\nrestore the original secret." } } } return JdbcInviteCodeStorage(database, null, blockingOperationGuard, reservationKey) @@ -590,7 +594,7 @@ internal class JdbcInviteCodeStorage private constructor( } } check(storedKey == reservationKey.keyId) { - "MySQL anti-abuse secret does not match the database; restore the shared secret." + "MySQL anti-abuse secret does not match the database\nrestore the shared secret." } } } @@ -634,7 +638,7 @@ internal fun executeImmediateWrite( connection.createStatement().use { it.execute("ROLLBACK") } } catch (rollbackError: Throwable) { val uncertain = SqliteStorageException( - "SQLite write failed for ${database.toAbsolutePath()} and rollback also failed; " + + "SQLite write failed for ${database.toAbsolutePath()} and rollback also failed\n" + "the database state is uncertain. Preserve it and inspect both causes before retrying.", error, ) diff --git a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteSchemaMigrator.kt b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteSchemaMigrator.kt index 4b65fcf..8ad3ed1 100644 --- a/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteSchemaMigrator.kt +++ b/invitecode-storage-sql/src/main/kotlin/io/github/command1264/invitecode/storage/sql/SqliteSchemaMigrator.kt @@ -17,7 +17,7 @@ fun interface BlockingOperationGuard { fun rejectingServerMainThread(isServerMainThread: () -> Boolean): BlockingOperationGuard = BlockingOperationGuard { check(!isServerMainThread()) { - "SQL storage cannot run on the server main thread; " + + "SQL storage cannot run on the server main thread\n" + "schedule the operation on a dedicated storage executor." } } @@ -78,7 +78,7 @@ class SqliteSchemaMigrator( } if (current > ordered.size) { throw SqliteStorageException( - "SQLite schema version $current is newer than supported version ${ordered.size}; " + + "SQLite schema version $current is newer than supported version ${ordered.size}\n" + "upgrade InviteCode before opening ${database.toAbsolutePath()}.", ) } @@ -106,7 +106,7 @@ class SqliteSchemaMigrator( connection.rollback() } catch (rollbackError: SQLException) { val uncertain = SqliteStorageException( - "SQLite schema migration failed for ${database.toAbsolutePath()} and rollback also failed; " + + "SQLite schema migration failed for ${database.toAbsolutePath()} and rollback also failed\n" + "the database state is uncertain. Preserve it and inspect both causes before retrying.", error, ) @@ -115,7 +115,7 @@ class SqliteSchemaMigrator( } if (error is SqliteStorageException) throw error throw SqliteStorageException( - "SQLite schema migration failed for ${database.toAbsolutePath()}; " + + "SQLite schema migration failed for ${database.toAbsolutePath()}\n" + "the transaction was rolled back. Preserve the database and inspect the cause before retrying.", error, ) diff --git a/invitecode-storage-sql/src/test/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorageTest.kt b/invitecode-storage-sql/src/test/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorageTest.kt index bd7835a..2ec32ea 100644 --- a/invitecode-storage-sql/src/test/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorageTest.kt +++ b/invitecode-storage-sql/src/test/kotlin/io/github/command1264/invitecode/storage/sql/SqliteInviteCodeStorageTest.kt @@ -201,7 +201,7 @@ class SqliteInviteCodeStorageTest { } assertEquals( - "SQL storage cannot run on the server main thread; " + + "SQL storage cannot run on the server main thread\n" + "schedule the operation on a dedicated storage executor.", error.message, )