95 lines
3.0 KiB
Markdown
95 lines
3.0 KiB
Markdown
# Brigadier対応マイグレーション完了レポート
|
||
|
||
## 概要
|
||
|
||
kommand-libのBrigadier対応に合わせて、npc-mannequinプロジェクトのコマンドを更新しました。
|
||
|
||
## 実施日時
|
||
|
||
2025-12-07
|
||
|
||
## 変更内容
|
||
|
||
### 1. 影響範囲の調査
|
||
|
||
以下のファイルを調査しました:
|
||
|
||
- `src/main/kotlin/net/hareworks/npc-mannequin/commands/MannequinCommands.kt`
|
||
- その他のKotlinソースファイル
|
||
|
||
**調査結果:**
|
||
- `coordinates()` の使用: なし
|
||
- `Coordinates3` の使用: なし
|
||
- 破壊的変更の影響: **なし**(座標系APIは使用していない)
|
||
|
||
### 2. 必要な修正
|
||
|
||
kommand-libの内部APIが変更されたため、以下の修正が必要でした:
|
||
|
||
#### `remainingInput()` 関数の更新
|
||
|
||
**変更前:**
|
||
```kotlin
|
||
private fun KommandContext.remainingInput(offset: Int): String? {
|
||
if (args.size <= offset) return null
|
||
return args.drop(offset).joinToString(" ").trim().ifEmpty { null }
|
||
}
|
||
```
|
||
|
||
**変更後:**
|
||
```kotlin
|
||
private fun KommandContext.remainingInput(offset: Int): String? {
|
||
// Get the full raw input from Brigadier's CommandContext
|
||
val fullInput = internal.input
|
||
|
||
// Split by whitespace to get individual tokens
|
||
val tokens = fullInput.split(Regex("\\s+"))
|
||
|
||
// Check if we have enough tokens
|
||
if (tokens.size <= offset) return null
|
||
|
||
// Join the remaining tokens after the offset
|
||
return tokens.drop(offset).joinToString(" ").trim().ifEmpty { null }
|
||
}
|
||
```
|
||
|
||
**理由:**
|
||
- 旧版の `KommandContext.args` プロパティが削除された
|
||
- 新版では Brigadier の `CommandContext.getInput()` を使用して生の入力を取得
|
||
- `internal.input` で Brigadier の `CommandContext` にアクセス可能
|
||
|
||
### 3. ビルド検証
|
||
|
||
```bash
|
||
./gradlew build --no-daemon
|
||
```
|
||
|
||
**結果:** ✅ BUILD SUCCESSFUL
|
||
|
||
## マイグレーションガイドとの対応
|
||
|
||
kommand-lib/MIGRATION_GUIDE.md に記載されている変更点:
|
||
|
||
1. ✅ **`coordinates()` の型変更** - 該当なし(使用していない)
|
||
2. ✅ **内部処理の改善** - 新しいBrigadier Lifecycle APIに対応済み
|
||
3. ✅ **依存関係の確認** - Paper API 1.21以降を使用
|
||
|
||
## 影響を受ける機能
|
||
|
||
以下のコマンドで `remainingInput()` を使用しているため、動作確認が推奨されます:
|
||
|
||
- `/mannequin set <id> description text <text>` - MiniMessageテキストの設定
|
||
- `/mannequin set <id> command console set <command>` - コンソールコマンドの設定
|
||
- `/mannequin set <id> command player set <command>` - プレイヤーコマンドの設定
|
||
|
||
## 今後の注意点
|
||
|
||
- kommand-libの内部APIは今後も変更される可能性があるため、`internal` プロパティの使用は最小限に抑えることが望ましい
|
||
- 可能であれば、kommand-lib側で公式に `remainingInput` のようなユーティリティを提供することを検討
|
||
|
||
## まとめ
|
||
|
||
✅ マイグレーション完了
|
||
✅ ビルド成功
|
||
⚠️ 実機での動作確認を推奨(特にテキスト入力系のコマンド)
|