← ClaudeAtlas

generate-placeholder-expansionlisted

為 Bukkit/Paper 插件產生 PlaceholderAPI Expansion 類別,依使用者提供的 placeholder 清單產生對應的處理邏輯,含 pom.xml 依賴設定、plugin.yml 軟依賴宣告、PlaceholderAPI 是否安裝的檢查,以及測試方法。當使用者說「PlaceholderAPI」、「PAPI 擴充」、「幫我寫 placeholder」、「%myplugin_xxx%」時自動應用。
MrPippi/MJP-Claude-Skills · ★ 1 · Data & Documents · score 70
Install: claude install-skill MrPippi/MJP-Claude-Skills
# Generate Placeholder Expansion Skill ## 目標 產生符合 PlaceholderAPI 規範的 `PlaceholderExpansion` 子類別,依使用者提供的 placeholder 清單,自動產生 `onRequest()` 方法中的分派邏輯,並附上完整的整合說明。 --- ## 使用流程 1. **詢問基本資訊**:插件名稱(用於 identifier)、placeholder 清單(名稱 + 說明) 2. **產生 Expansion 類別**:依 placeholder 清單產生 switch 分派 3. **說明 plugin.yml 設定**:`softdepend` 宣告 4. **說明在主類中的註冊方式** 5. **提供測試指令說明** --- ## 輸入參數說明 | 參數 | 範例 | 說明 | |------|------|------| | `plugin_name` | `MyPlugin` | 用於 Expansion 類別命名 | | `identifier` | `myplugin` | Placeholder 前綴,即 `%myplugin_xxx%` 中的 `myplugin` | | `package` | `com.example.myplugin.hooks` | 類別放置的套件 | | `placeholders` | `balance, rank, playtime` | Placeholder 名稱清單 | --- ## pom.xml 依賴 ```xml <!-- PlaceholderAPI(provided,由伺服器提供) --> <dependency> <groupId>me.clip</groupId> <artifactId>placeholderapi</artifactId> <version>2.11.6</version> <scope>provided</scope> </dependency> ``` 需要加入 PlaceholderAPI 的 Maven repository: ```xml <repository> <id>placeholderapi</id> <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> </repository> ``` --- ## plugin.yml 設定 ```yaml # 硬依賴(若 PAPI 不存在插件不啟動) # depend: [PlaceholderAPI] # 軟依賴(若 PAPI 不存在插件仍啟動,功能降級) softdepend: [PlaceholderAPI] ``` --- ## 代碼範本 ### MyPluginExpansion.java ```java package com.example.myplugin.hooks; import com.example.myplugin.MyPlugin; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.OfflinePlayer; import org.jetbrains.annotations.NotNull;