0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Nukkit]Configを使う

Posted at

はじめに

備忘録です

setup

resourceにconfig.ymlを作る

config.yml
Test:
  Message: "てすとめっせーじ"
  Wallet: 1000

起動時にconfig.ymlを保存する

この時点でresourceに書いたconfig.ymlがプラグインのデータファイルにコピーされます
二回目以降の起動では行われません

override fun onEnable() {
    saveDefaultConfig()
}

つかう

configの取得

Pluginクラスから取得できます

val plugin = Main()
val config = plugin.config

値の取得

config.getT("key")(文字列ならgetString("key"))を使います
階層はドット(.)で表すことができます

val message = config.getString("Test.Message")
logger.info(message) // てすとめっせーじ
val wallet = config.getInt("Test.Wallet")
logger.info(wallet) // 1000
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?