HOCON の入門¶
HOCON (Human-Optimized Config Object Notation) is an easy-to-use configuration format. It is used by Sponge and
individual plugins utilizing SpongeAPI to store important data, such as configuration or player data. HOCON files
typically use the suffix .conf
.
コンポーネント¶
- 「キー」とは、値の前に来る文字列です
- 「値」とは、「キー」の次にある、文字列、数値、オブジェクト、配列及び論理値です
- 「セパレーター」は、キーと値を分離します。``:``もしくは``=``が使用できます。
- 「コメント」は、フィードバック、および指示を提供するために使用される。コメントは、」#」または」//」で始まる
例:
yellow-thing: "Sponge"
この例では、「キー」は「yellow-thing」で、 「値」は「Sponge」です。「セパレーター」は「:」です。
HOCONでの作業¶
HOCONは、JSON(JavaScript Object Notation)フォーマットよりも多くのオプションがあります。有効なHOCONファイルを書き込むための多くの方法があります。有効HOCONの2つの例は以下の通りである:
例#1:
player: {
name: "Steve",
level: 30
}
例#2:
player {
name = "Steve"
level = 30
}
In practice, it is best to follow the formatting conventions of the HOCON configuration you are editing. When editing a HOCON configuration for Sponge or an individual plugin utilizing SpongeAPI, the values are likely the only thing you will be changing unless otherwise specified.
コンフィギュレーションのデバッグ¶
HOCON構成が動作しているように表示されない場合は、ここでいくつかのヒントがあります:
- カーリーブレースはバランスをとらなければならない
- 引用符は、バランスをとらなければならない
- 重複したキーは、最後のキーが使用されます。