public class PluginDescription extends Object
在jar格式的插件中,插件的描述内容可以在plugin.yml中定义。比如这个:
The description of a jar-packed plugin can be defined in the 'plugin.yml' file. For example:
在使用plugin.yml来定义插件时,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
name、main、version、api这几个字段是必需的,
要让Nukkit能够正常加载你的插件,必须要合理地填写这几个字段。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 @粉鞋大妈)
getDepend()getDepend()getPrefix()getPrefix()PluginLoadOrderPluginLoadOrderPlugin,
PluginLoadOrder| Constructor and Description |
|---|
PluginDescription(Map<String,Object> yamlMap) |
PluginDescription(String yamlString) |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getAuthors()
返回这个插件的作者列表。
Returns all the authors of this plugin. |
Map<String,Object> |
getCommands()
返回这个插件定义的命令列表。
Returns all the defined commands of this plugin. |
List<String> |
getCompatibleAPIs()
返回这个插件支持的Nukkit API版本列表。
Returns all Nukkit API versions this plugin supports. |
List<String> |
getDepend()
返回这个插件所依赖的插件名字。
The names of the plugins what is depended by this plugin. |
String |
getDescription()
返回这个插件的描述文字。
Returns the description text of this plugin. |
String |
getFullName()
返回这个插件完整的名字。
Returns the full name of this plugin. |
List<String> |
getLoadBefore()
TODO finish javadoc
|
String |
getMain()
返回这个插件的主类名。
Returns the main class name of this plugin. |
String |
getName()
返回这个插件的名字。
Returns the name of this plugin. |
PluginLoadOrder |
getOrder()
返回这个插件加载的顺序,即插件应该在什么时候加载。
Returns the order the plugin loads, or when the plugin is loaded. |
List<Permission> |
getPermissions()
返回这个插件定义的权限列表。
Returns all the defined permissions of this plugin. |
String |
getPrefix()
返回这个插件的信息前缀。
Returns the message title of this plugin. |
List<String> |
getSoftDepend()
TODO finish javadoc
|
String |
getVersion()
返回这个插件的版本号。
Returns the version string of this plugin. |
String |
getWebsite()
返回这个插件的网站。
Returns the website of this plugin. |
public PluginDescription(String yamlString)
public String getFullName()
一个插件完整的名字由名字+" v"+版本号组成。比如:
A full name of a plugin is composed by name+" v"+version.for example:
HelloWorld v1.0.0
PluginDescriptionpublic List<String> getCompatibleAPIs()
PluginDescriptionpublic List<String> getAuthors()
PluginDescriptionpublic String getPrefix()
插件的信息前缀在记录器记录信息时,会作为信息头衔使用。如果没有定义记录器,会使用插件的名字作为信息头衔。
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.
null。null if undefined.PluginLogger,
PluginDescriptionpublic Map<String,Object> getCommands()
PluginDescriptionpublic List<String> getDepend()
Nukkit插件的依赖有这些注意事项:
Here are some note for Nukkit plugin depending:
举个例子,如果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.
List对象。List object carries the plugin names.PluginDescriptionpublic String getDescription()
PluginDescriptionpublic String getMain()
一个插件的加载都是从主类开始的。主类的名字在插件的配置文件中定义后可以通过这个函数返回。一个返回值例子:
The load action of a Nukkit plugin begins from main class. The name of primary class should be defined
in the plugin configuration, and it can be returned by this function. An example for return value:
"com.example.ExamplePlugin"
PluginDescriptionpublic String getName()
PluginDescriptionpublic PluginLoadOrder getOrder()
PluginDescription,
PluginLoadOrderpublic List<Permission> getPermissions()
PluginDescriptionpublic String getVersion()
PluginDescriptionpublic String getWebsite()
PluginDescriptionCopyright © 2020. All rights reserved.