ぺこめも

困ったときとかにいろいろまとめてる

Nukkit プラグイン Tips - plugin.yml -

まだ、公式の開発者向けWikiが整備されていないので、plugin.yml の内容について解説しておく。

公式のサンプルコードをまずは載せる。

#name, main, version and api are required
name: ExamplePlugin
main: cn.nukkit.exampleplugin.ExamplePlugin
#remember version and api is string, don't write it like this: 1.0.0, or there will be an exception
version: "1.0.0"
api: ["1.0.5"]
load: POSTWORLD
author: Nukkit Project
# Authors and author will be added together in one list.
authors: ["Example", "Another"]
description: Example plugin showing the API
website: https://github.com/NukkitX/ExamplePlugin
# These dependencies are required for the plugin to start.
#depend: ["OtherPlugin", "ThisPlugin"]
# These dependencies are not required.
softdepend: ["PluginA", "PluginB"]
# Log prefix in console
prefix: "Example"
# Plugin will be loaded before these. Any cyclic loadbefore's or dependencies's will throw errors!
loadbefore: ["ImportantPlugin"]

commands:
  example:
    description: Example command
    usage: "/example"
    aliases: ["xample", "nukkitexample"]
    permission: exampleplugin.command.example
    permission-message: "You do not have the required permission to run /example"
permissions:
  exampleplugin.command.example:
    description: "Allows the user to run the example command"
    default: true
    children:
#     exampleplugin.command.example.test:
#       description: "Use the test feature in the example command"
#       default: true
  • name (必須)
    プラグインの名前(半角英数字、_.-、半角スペースが使用できる )
    半角スペースだけ(例えばname: " ")でも大丈夫なのが少し仕様としてもやっとしたりするけど、ちゃんと読み込める。
    f:id:pekomiya:20180817013631p:plain
  • main (必須)
    メインクラスまでのパス。このパスを使って、ClassLoader からロードする。なお、cn.nukkit. から始まるものは使用できない。
  • version (必須)
    プラグインのバージョン。
  • api (必須)
    対応するNukkit API のバージョン。どれに対応するかは、version コマンドで確認できる。
    f:id:pekomiya:20180817014016p:plain
    また、1.0.0 というような、「数字 . 数字 . 数字」という形式で書かなければいけない。文字列の配列を記入するが、書かれているAPI バージョンのいずれかが対応していれば、読み込むことができる。
  • load(初期値:POSTWORLD
    プラグインのロードされるタイミングを設定できる。現在、STARTUP, POSTWORLD を設定可能。
    pekomemo.hatenablog.jp

  • author
    プラグインの著者。version <plugin name> や、timings で表示される。authors と共存可能。

  • authors
    プラグインの著者(author だと一つだが、authors だと文字列の配列を記入できるので、複数著者がいるときは便利)。version <plugin name> や、timings で表示される。author と共存可能。
  • description
    プラグインの概要。version <plugin name> や、timings で表示される。
  • website
    プラグインのWebサイト。version <plugin name> や、timings で表示される。
  • depend
    このプラグインが依存しているプラグイン。依存するプラグインが読み込まれた後で、読み込まれる。(存在しない場合は以下のようなエラー)
    01:54:59 [CRITICAL] プラグイン'Sample'を読み込むことができませんでした: 不明な依存関係 01:54:59 [CRITICAL] プラグイン'Sample'を読み込むことができませんでした: 循環依存が検出されました
  • softdepend
    このプラグインが依存しているプラグインdepend と違って、エラーは出ない。
  • prefix
    コンソールに出力されるログの先頭につく文字を設定できる。標準はプラグインname
    [Sample] onEnableSample の部分。
  • loadbefore
    どのプラグインよりも前に呼ばれるべきか設定できる。そのプラグインが存在しなくてもエラーは出ない。

  • commands

    • description コマンドの概要 help コマンドで表示されるコマンドの説明で表示。
    • usage
      コマンドのリスナーが false を戻すときに、表示されるデフォルトのメッセージ。
    • aliases
      コマンドのエイリアスsample というコマンドで sエイリアスに設定していたら、 /s でこのコマンドの処理が呼ばれる。
    • permission
      このコマンドを使用するための権限
    • permission-message
      コマンドの送信元に、必要な権限がない時に表示されるメッセージ。
  • permissions

    • description(必須)
      権限の名前
    • default (デフォルト:false) 標準でだれが権限を所有するか。

      権限
      op op
      isop op
      operator op
      isoperator op
      isopadmin op
      isadmin op
      !op notop
      notop notop
      !operator notop
      !admin notop
      notadmin notop
      true true
    • children