generate-command-handlerlisted
Install: claude install-skill MrPippi/MJP-Claude-Skills
# Generate Command Handler Skill
## 目標
依使用者提供的指令名稱與子指令清單,產生完整的 `CommandExecutor` + `TabCompleter` 實作類別。
---
## 使用流程
1. **詢問基本資訊**:插件名稱(小寫)、主指令名稱、子指令清單
2. **產生主指令類別**:`CommandExecutor` + `TabCompleter` 合併實作
3. **輸出 plugin.yml 片段**:`commands` 節點範例
4. **說明註冊方式**:在 `onEnable()` 中綁定
---
## 代碼範本
### 基礎單層指令(無子指令)
```java
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class MyCommand implements CommandExecutor, TabCompleter {
private final MyPlugin plugin;
public MyCommand(MyPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
@NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage("此指令僅限玩家使用。");
return true;
}
if (!player.hasPermission("myplugin.command")) {
player.sendMessage(Component.text("你沒有權限執行此指令。").color(NamedTextColor.RED));
return true;
}
player.sendMessage(Component.text("指令執行成功!").color(NamedTextColor.GREEN));
return true;
}
@Override
public List<Strin