Class PluginDescription

java.lang.Object
cn.nukkit.plugin.PluginDescription

public class PluginDescription extends Object
描述一个Nukkit插件的类。
Describes a Nukkit plugin.

在jar格式的插件中,插件的描述内容可以在plugin.yml中定义。比如这个:
The description of a jar-packed plugin can be defined in the 'plugin.yml' file. For example:

 name: HelloWorldPlugin
 main: com.cnblogs.xtypr.helloworldplugin.HelloWorldPlugin
 version: "1.0.0"
 api: ["1.0.0"]
 load: POSTWORLD
 author: 粉鞋大妈
 description: A simple Hello World plugin for Nukkit
 website: http://www.cnblogs.com/xtypr
 permissions:
  helloworldplugin.command.helloworld:
   description: Allows to use helloworld command.
   default: true
 commands:
  helloworld:
   description: the helloworld command
   usage: "/helloworld"
   permission: helloworldplugin.command.helloworld
 depend:
 - TestPlugin1
 
在使用plugin.yml来定义插件时,namemainversionapi这几个字段是必需的, 要让Nukkit能够正常加载你的插件,必须要合理地填写这几个字段。
When using plugin.yml file to define your plugin, it's REQUIRED to fill these items: name,main,version and api.You are supposed to fill these items to make sure your plugin can be normally loaded by Nukkit.

接下来对所有的字段做一些说明,加粗的字段表示必需,斜体表示可选:(来自 粉鞋大妈的博客文章
Here are some instructions for there items, bold means required, italic means optional: (From a blog article of @粉鞋大妈)

  • name
    字符串,表示这个插件的名字,名字是区分不同插件的标准之一。 插件的名字不能包含“nukkit”“minecraft”“mojang”这几个字符串,而且不应该包含空格。
    String, the plugin name. Name is one of the ways to distinguish different plugins. A plugin name can't contain 'nukkit' 'minecraft' 'mojang', and shouldn't contain spaces.
  • version
    字符串,表示这个插件的版本号。使用类似于1.0.0这样的版本号时,应该使用引号包围来防止误识别。
    String, the version string of plugin. When using the version string like "1.0.0", quotation marks are required to add, or there will be an exception.
  • api
    字符串序列,表示这个插件支持的Nukkit API版本号列表。插件作者应该调试能支持的API,然后把版本号添加到这个列表。
    A set of String, the Nukkit API versions that the plugin supports. Plugin developers should debug in different Nukkit APIs and try out the versions supported, and add them to this list.
  • main
    字符串,表示这个插件的主类。插件的主类不能放在“cn.nukkit”包下
    String, the main class of plugin. The main class can't be placed at 'cn.nukkit' package.
  • author or authors
    字符串/字符串序列,两个任选一个,表示这个插件的作者/作者列表。
    String or A set of String. One of two is chosen, to describe the author or the list of authors.
  • website
    字符串,表示这个插件的网站。插件使用者或者开发者可以访问这个网站来获取插件更多的信息。 这个网站可以是插件发布帖子或者插件官网等。
    String, the website of plugin. More information can be found by visiting this website. The website can be a forum post or the official website.
  • description
    字符串,表示这个插件的一些描述。
    String, some description of plugin.
  • depend
    序列,表示这个插件所依赖的一个或一些插件的名字的列表。参见:getDepend()
    List, strings for plugin names, what is depended on by this plugin. See: getDepend()
  • prefix
    字符串,表示这个插件的消息头衔。参见:getPrefix()
    String, the message title of the plugin. See: getPrefix()
  • load
    字符串,表示这个插件的加载顺序,或者说在什么时候加载。参见:PluginLoadOrder
    String, the load order of plugin, or when the plugin loads. See: PluginLoadOrder
  • commands
    序列,表示这个插件的命令列表。
    List, the command list.
  • permissions
    序列,表示这个插件的权限组列表。
    List, the list of permission groups defined.
  • features
    序列,表示这个插件的所使用的特征列表。
    List, the list of features used.
Since:
Nukkit 1.0 | Nukkit API 1.0.0
Author:
MagicDroidX(code) @ Nukkit Project, iNevet(code and javadoc) @ Nukkit Project, 粉鞋大妈(javadoc) @ Nukkit Project, superice666(code) @ PowerNukkitX Project
See Also:
  • Constructor Details

    • PluginDescription

      public PluginDescription(Map<String,Object> yamlMap)
    • PluginDescription

      public PluginDescription(String yamlString)
  • Method Details

    • getFullName

      public String getFullName()
      返回这个插件完整的名字。
      Returns the full name of this plugin.

      一个插件完整的名字由名字+" v"+版本号组成。比如:
      A full name of a plugin is composed by name+" v"+version.for example:

      HelloWorld v1.0.0

      Returns:
      这个插件完整的名字。
      The full name of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getCompatibleAPIs

      public List<String> getCompatibleAPIs()
      返回这个插件支持的Nukkit API版本列表。
      Returns all Nukkit API versions this plugin supports.
      Returns:
      这个插件支持的Nukkit API版本列表。
      A list of all Nukkit API versions String this plugin supports.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getAuthors

      public List<String> getAuthors()
      返回这个插件的作者列表。
      Returns all the authors of this plugin.
      Returns:
      这个插件的作者列表。
      A list of all authors of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getPrefix

      public String getPrefix()
      返回这个插件的信息前缀。
      Returns the message title of this plugin.

      插件的信息前缀在记录器记录信息时,会作为信息头衔使用。如果没有定义记录器,会使用插件的名字作为信息头衔。
      When a PluginLogger logs, the message title is used as the prefix of message. If prefix is undefined, the plugin name will be used instead.

      Returns:
      这个插件的作信息前缀。如果没定义,返回null
      The message title of this plugin, ornull if undefined.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getCommands

      public Map<String,Object> getCommands()
      返回这个插件定义的命令列表。
      Returns all the defined commands of this plugin.
      Returns:
      这个插件定义的命令列表。
      A map of all defined commands of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getDepend

      public List<String> getDepend()
      返回这个插件所依赖的插件名字。
      The names of the plugins what is depended by this plugin.

      Nukkit插件的依赖有这些注意事项:
      Here are some note for Nukkit plugin depending:

      • 一个插件不能依赖自己(否则会报错)。
        A plugin can not depend on itself (or there will be an exception).
      • 如果一个插件依赖另一个插件,那么必须要安装依赖的插件后才能加载这个插件。
        If a plugin relies on another one, the another one must be installed at the same time, or Nukkit won't load this plugin.
      • 当一个插件所依赖的插件不存在时,Nukkit不会加载这个插件,但是会提醒用户去安装所依赖的插件。
        When the required dependency plugin does not exists, Nukkit won't load this plugin, but will tell the user that this dependency is required.

      举个例子,如果A插件依赖于B插件,在没有安装B插件而安装A插件的情况下,Nukkit会阻止A插件的加载。 只有在安装B插件前安装了它所依赖的A插件,Nukkit才会允许加载B插件。
      For example, there is a Plugin A which relies on Plugin B. If you installed A without installing B, Nukkit won't load A because its dependency B is lost. Only when B is installed, A will be loaded by Nukkit.

      Returns:
      插件名字列表的 List对象。
      A List object carries the plugin names.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getDescription

      public String getDescription()
      返回这个插件的描述文字。
      Returns the description text of this plugin.
      Returns:
      这个插件的描述文字。
      The description text of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getLoadBefore

      public List<String> getLoadBefore()
      TODO finish javadoc
    • getMain

      public String getMain()
      返回这个插件的主类名。
      Returns the main class name of this plugin.

      一个插件的加载都是从主类开始的。主类的名字在插件的配置文件中定义后可以通过这个函数返回。一个返回值例子:
      The load action of a Nukkit plugin begins from main class. The name of main class should be defined in the plugin configuration, and it can be returned by this function. An example for return value:
      "com.example.ExamplePlugin"

      Returns:
      这个插件的主类名。
      The main class name of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getName

      public String getName()
      返回这个插件的名字。
      Returns the name of this plugin.
      Returns:
      这个插件的名字。
      The name of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getOrder

      public PluginLoadOrder getOrder()
      返回这个插件加载的顺序,即插件应该在什么时候加载。
      Returns the order the plugin loads, or when the plugin is loaded.
      Returns:
      这个插件加载的顺序。
      The order the plugin loads.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getPermissions

      public List<Permission> getPermissions()
      返回这个插件定义的权限列表。
      Returns all the defined permissions of this plugin.
      Returns:
      这个插件定义的权限列表。
      A map of all defined permissions of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getSoftDepend

      public List<String> getSoftDepend()
      TODO finish javadoc
    • getVersion

      public String getVersion()
      返回这个插件的版本号。
      Returns the version string of this plugin.
      Returns:
      这个插件的版本号。
      The version string od this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getWebsite

      public String getWebsite()
      返回这个插件的网站。
      Returns the website of this plugin.
      Returns:
      这个插件的网站。
      The website of this plugin.
      Since:
      Nukkit 1.0 | Nukkit API 1.0.0
      See Also:
    • getFeatures

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public List<String> getFeatures()
      返回这个插件的所使用的特征。
      Returns the author of this plugin.
      Returns:
      这个插件所使用的特征。
      The features of this plugin.
      Since:
      PowerNukkitX 1.6.0.0-PNX | Nukkit API 1.0.14
      See Also: