• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

“Plugin.yml”的版本间的差异

来自Minecraft插件百科
跳转至: 导航搜索
Plugin.yml
 
(未显示同一用户的4个中间版本)
第1行: 第1行:
<!--
+
{{DocsInclude}}
=== 创建plugin.yml ===
+
当Bukkit读取一个插件时,它需要知道插件的一些基础属性.它从plugin.yml中读取. 这个文件由一组元素组成,并且没有缩进必需在新行定义.  
  
你已经创建了项目和主类,如果你想要Bukkit能够加载你的插件,你还必须创建 '''[[Plugin YAML|plugin.yml]]''' 文件. 这个文件包含有基础的插件信息,如果缺失这个文件,你的插件也将会失效. 此时你需要右键''src/main/resources''. 选择''New &gt; File''. 命名为"'''plugin.yml'''" 并右键完成新文件的创建.Eclipse会打开默认的文本编辑窗口来显示'''plugin.yml'''文件中空白的内容并提供编辑. ''(Hint:&nbsp;如果你想要使得你的工作空间更加规整,关闭文本编辑器并将'''plugin.yml''' 文件拖到主工作空间(拖到文件目录的右边) 之后你就可以在eclipse中编辑文件了.)''
+
{| cellspacing="0" cellpadding="4" border="1" class="wikitable"
 +
|+ 属性
 +
|-
 +
! 属性
 +
! 必需
 +
! 描述
 +
! 示例
 +
! 笔记
 +
|- style="font-weight: bold;"
 +
| name
 +
| 是
 +
| 插件的名字.
 +
| <code>name: MyPlugin</code>
 +
|  
 +
*Must consist of all alphanumeric characters and underscores (a-z,A-Z,0-9, _)
 +
*Used to determine the name of the plugin's data folder. Data folders are placed in the ./plugins/ directory by default.  
 +
*It is good practice to name your jar the same as this, for example 'MyPlugin.jar'
  
有三个基础的内容需要在plugin.yml写明.  
+
|- style="font-weight: bold;"
: name:  插件名称.  
+
| version
: main: [http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#jls-6.7 插件主类的完整,合法名称] .  
+
| yes
: version: 插件当前版本号.
+
| The version of this plugin.  
 +
| <code>version: 1.4.1</code>
 +
|
 +
*Version is an arbitrary string, however the most common format is MajorRelease.MinorRelease.Build (eg: 1.4.1).  
 +
*Typically you will increment this every time you release a new feature or bug fix.  
 +
*Displayed when a user types <code>/version PluginName</code>
  
最简单的 '''plugin.yml''' 文件内就像这样&nbsp;:  
+
|-
 +
| description
 +
| no
 +
| A human friendly description of the functionality your plugin provides.  
 +
| <code>description: This plugin is so 31337. You can set yourself on fire.</code>
 +
|
 +
*The description can have multiple lines.
 +
*Displayed when a user types <code>/version PluginName</code>
  
name: {插件名称}
+
|-
main: {包名}.{主类}
+
| load
version: {版本号}
+
| no
 +
| Explicitly state when the plugin should be loaded. if not supplied will default to postworld
 +
| <code> load: STARTUP </code>
 +
| Has two possible values
 +
* STARTUP
 +
* POSTWORLD
 +
|-
 +
| author
 +
| no
 +
| Uniquely identifies who developed this plugin.
 +
| <code>author: CaptainInflamo</code>
 +
|
 +
*Gives credit to the developer.
 +
*Used in some server error messages to provide helpful feedback on who to contact when an error occurs.  
 +
*A bukkit.org forum handle or email address is recommended.
 +
*Is displayed when a user types /version PluginName
  
PS:插件的包名经常会包括插件的名称,所以看到这个的时候不要感到惊讶。
+
|-
    你的主类是否是你的插件名取决于你之前的命名方式,时刻记住这一点很重要。
+
| authors
 +
| no
 +
| Allows you to list multiple authors, if it is a collaborative project. See author.
 +
| <code>authors: [Cogito, verrier, EvilSeph]</code>
 +
|
 +
*You can define both author and authors, however they will be merged into one list internally.
  
'''''更多例子''', 请看[[#Example_Files_and_Templates]]''
+
|-
 +
| website
 +
| no
 +
| The plugin's or author's website.
 +
| <code>website: http://forums.bukkit.org/threads/MyPlugin.31337/</code>
 +
|
 +
*If you have no dedicated website, a link to the Bukkit forum post where this plugin is listed is highly recommended.
 +
*Displayed when a user types <code>/version PluginName</code>
  
此时你的插件已经可以被Bukkit加载了,同时服务端日志也会开始记录你的插件. 不过它现在什么用都没有!
+
|- style="font-weight: bold;"
 +
| main
 +
| yes
 +
| Points to the class that extends JavaPlugin
 +
| <code>main: org.bukkit.plugin.MyPlugin</code>
 +
|
 +
*Note that this must contain the full namespace including the class file itself.
 +
*If your namespace is <code>org.bukkit.plugin</code>, and your class file is called <code>MyPlugin</code> then this must be <code>org.bukkit.plugin.MyPlugin</code>
  
*以上内容来自 [[Bukkit/插件开发教程]] 4.6 创建plugin.yml
+
|-
-->
+
| database
=== Plugin.yml ===
+
| no
 +
| Set to true if this plugin uses a database.
 +
| <code>database: false</code>
 +
|
 +
*Using a database is non-trivial. See [[Plugin_Databases]]
  
 +
|-
 +
| depend
 +
| no
 +
| A list of plugins that your plugin requires to load.
 +
| <code>depend: [OnePlugin, AnotherPlugin]</code>
 +
|
 +
*The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
 +
*Use the "name" attribute of the required plugin in order to specify the dependency.
 +
*If any plugin listed here is not found your plugin will fail to load.
 +
*If multiple plugins list each other as a depend, so that there are no plugins without an unloadable dependency, all will fail to load.
 +
*(See: Wiki: Plugin_Dependencies)
 +
|-
 +
| prefix
 +
| no
 +
| The name to use when logging to console instead of the plugin's name.
 +
| <code>prefix: ex-why-zee</code>
 +
|
 +
|-
 +
| softdepend
 +
| no
 +
| A list of plugins that are required for your plugin to have full functionality.
 +
| <code>softdepend: [OnePlugin, AnotherPlugin]</code>
 +
|
 +
*The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
 +
*Use the "name" atrribute of the desired plugin in order to specify the dependancy.
 +
*Your plugin will load after any plugins listed here.
 +
*Circular soft dependencies are loaded arbitrarily.
 +
*(See: Wiki: Plugin_Dependencies)
  
-----
+
|-
 +
| loadbefore
 +
| no
 +
| A list of plugins should be loaded after your plugin.
 +
| <code>loadbefore: [OnePlugin, AnotherPlugin]</code>
 +
|
 +
*The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
 +
*Treated as if the listed plugin soft depends on the specifying plugin.
 +
*Use the "name" atrribute of the desired plugin in order to specify the target.
 +
*Your plugin will load before any plugins listed here.
 +
*Circular soft dependencies are loaded arbitrarily.
 +
*(See: Wiki: Plugin_Dependencies)
  
Plugin.yml 文件包含了你的插件信息,没有这个文件,你的插件将'''不会正常工作''',它由一组属性组成,'''注意!!!''' 这些属性是严格区分大小写的。接下来粗体是必需属性(缺了就会有问题),斜体是可选属性(但有一些在一些特定的情况下必须要有)
+
|-
 +
| commands
 +
| no
 +
| The name of a command the plugin wishes to register, as well as an optional list of command attributes.  
 +
|
 +
<code>
 +
commands:
 +
  flagrate:
 +
    [optional command attributes]
 +
</code>
  
<h3>
+
|
目录:
+
*The command name should not contain the leading '/' required to issue a command.
</h3>
+
*You can choose any command name you wish, however 'common' commands such as <code>/kick</code> are often already registered. Use the 'alias' command attribute to supply alternate names. @TODO: verify we're happy with this
* [[#Required|必需属性]]
 
* [[#Optional|可选属性]]
 
* 命令
 
* 权限
 
* 实例
 
  
<h4 id="Required">
+
|-
必需属性
+
| permissions
</div>
+
| no
要想 plugin.yml 有效 则有三个属性 必须存在
+
| Permissions that the plugin whishes to register. Each node represents a permission to register. Each permission can have additional attributes.
 +
| <pre>permissions:
 +
  inferno.*:
 +
    [optional permission attributes]
 +
  inferno.flagate:
 +
    [optional permission attributes]
 +
  inferno.burningdeaths:
 +
    [optional permission attributes]</pre>  
 +
|
 +
*Permission registration is optional, can also be done from code
 +
*Permission registration allows you to set descriptions, defaults, and child parent relationships
 +
*Permission names should be kept in the style of &lt;pluginname&gt;.[category].[category].&lt;permission&gt;
  
<u>'''main:'''</u>
+
|}
  
* 指插件的主类名
 
* 在插件中主类名有且仅有一个,而且需要继承<code>JavaPlugin</code>类
 
* 主类名是插件的“入口” 反正这玩意在插件启动时执行
 
  
''例:''
+
A command block starts with the command's name, and then has a list of attributes.
  
<syntaxhighlight lang="yaml">main: org.mineplugin.testplugin.Test
+
{| cellspacing="0" cellpadding="4" border="1" class="wikitable"
# 格式是包名加上主类名  你可别说你不知道什么是包和主类</syntaxhighlight>
+
|-
<u>'''name:'''</u>
+
! Command Attribute
 +
! Required
 +
! Description
 +
! Example
 +
! Notes
 +
|-
 +
| description
 +
| no
 +
| A short description of what the command does.
 +
| <code>description: Set yourself on fire</code>  
 +
|
 +
*Can be used in conjunction with /help
  
* 插件的名称
+
|-
* 必须由(a-z,A-Z,0-9, _)组成 这里建议写“''一个特殊''”一点名字避免和其它插件重名
+
| aliases
 +
| no
 +
| Alternate command names a user may use instead
 +
|
 +
<code>aliases: combust_me</code> OR
 +
<code>aliases: [combust_me, combustMe, cm]</code>
  
''例:''
+
|
 +
*You can specify any of none, 1 or many aliases.
 +
*If you specify more than one alias, they must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
  
<syntaxhighlight lang="yaml">name: MinePlugin</syntaxhighlight>
+
|-
<u>'''version'''</u>
+
| permission
 +
| no
 +
| The most basic permission node required to use the command
 +
|
 +
<code>permission: inferno.flagrate</code>
  
* 这是你插件的版本
+
|
* 理论上可以填写任何String类型 [[https://semver.org/lang/zh-CN/|参考]]
+
*This permissions node can be used to determine if a user should be able to see this command
 +
*Some plugins will use this node to construct a personalized /help
 +
|-
 +
| permission-message
 +
| no
 +
| A no-permission message
 +
| <code>permission-message: You do not have /&lt;permission&gt;</code>
 +
|
 +
*Displayed to a player that attempts to use a command but does not have the associated permission
 +
*&lt;permission&gt; is a macro that is replaced with the permission node that is required to use the command.
 +
*You may use empty quotes to indicate nothing should be displayed.
  
<syntaxhighlight lang="yaml">version: 1.0.0</syntaxhighlight>
+
|-
<h4 class="Optional">
+
| usage
可选属性
+
| no
</h4>
+
| A short description of how to use this command.
 +
| <code>usage: Syntax error! Perhaps you meant /&lt;command&gt; PlayerName?</code>
 +
|
 +
*Displayed to whoever issued the command when the plugin's command handler (onCommand typically) does not return true.
 +
*&lt;command&gt; is a macro that is replaced with the command issued wherever it occurs.
 +
*To use the string "Usage:" (i.e. <code>usage: Usage: /god [player]</code>, surround the text after the usage: label with double-quotes:<br> <code>usage: "Usage: /god [player]"</code>
 +
 
 +
|}
 +
 
 +
 
 +
A permission block starts with the permission's name and is followed by nodes of attributes
 +
 
 +
{| cellspacing="0" cellpadding="4" border="1" class="wikitable"
 +
|-
 +
! Permission Attribute
 +
! Required
 +
! Description
 +
! Example
 +
! Notes
 +
|-
 +
| description
 +
| no
 +
| A short description of what this permission allows
 +
| <pre>description: Allows you to set yourself on fire</pre>  
 +
|
 +
*Allows programmatic access, and helps server administrators
 +
 
 +
|-
 +
| default
 +
| no
 +
| Sets the default value of the permission
 +
| <pre>default: true</pre>
 +
|
 +
*If node does not exist the permission defaults to op
 +
*allowed defaults are: true, false, op, not op
 +
*op default will be true if player is op
 +
*no op default is the opposite behavior (of op)
 +
 
 +
|-
 +
| children
 +
| no
 +
| allows you to set children for the permission. Child nodes are permission names
 +
| <pre>children:
 +
  inferno.flagrate: true
 +
  inferno.burningdeaths: true</pre>  
 +
|
 +
*Each child node must be either set to true or false
 +
**a child node of true inherits the parent permission
 +
**a child node of false inherits the inverse parent permission
 +
* Can also contain other permission nodes [https://github.com/bukkit/bukkit/commit/326f2aca9b98d1d096842d3410000ed9d84611f5 {1}]
 +
 
 +
|}
 +
 
 +
 
 +
Example:
 +
 
 +
<blockquote><source lang="yaml" style="border: 1px #aaa solid;">
 +
name: Inferno
 +
version: 1.4.1
 +
description: This plugin is so 31337. You can set yourself on fire.
 +
# We could place every author in the authors list, but chose not to for illustrative purposes
 +
# Also, having an author distinguishes that person as the project lead, and ensures their
 +
# name is displayed first
 +
author: CaptainInflamo
 +
authors: [Cogito, verrier, EvilSeph]
 +
website: http://forums.bukkit.org/threads/MyPlugin.31337/
 +
 +
main: com.captaininflamo.bukkit.inferno.Inferno
 +
database: false
 +
depend: [NewFire, FlameWire]
 +
 +
commands:
 +
  flagrate:
 +
    description: Set yourself on fire.
 +
    aliases: [combust_me, combustMe]
 +
    permission: inferno.flagrate
 +
    usage: Syntax error! Simply type /&lt;command&gt; to ignite yourself.
 +
  burningdeaths:
 +
    description: List how many times you have died by fire.
 +
    aliases: [burning_deaths, burningDeaths]
 +
    permission: inferno.burningdeaths
 +
    usage: |
 +
      /&lt;command&gt; [player]
 +
      Example: /&lt;command&gt; - see how many times you have burned to death
 +
      Example: /&lt;command&gt; CaptainIce - see how many times CaptainIce has burned to death
 +
 +
permissions:
 +
  inferno.*:
 +
    description: Gives access to all Inferno commands
 +
    children:
 +
      inferno.flagrate: true
 +
      inferno.burningdeaths: true
 +
      inferno.burningdeaths.others: true
 +
  inferno.flagrate:
 +
    description: Allows you to ignite yourself
 +
    default: true
 +
  inferno.burningdeaths:
 +
    description: Allows you to see how many times you have burned to death
 +
    default: true
 +
  inferno.burningdeaths.others:
 +
    description: Allows you to see how many times others have burned to death
 +
    default: op
 +
    children:
 +
      inferno.burningdeaths: true
 +
</source></blockquote>
 +
 
 +
{{Languages|Plugin YAML}}

2021年5月5日 (三) 10:21的最新版本

模板:DocsInclude 当Bukkit读取一个插件时,它需要知道插件的一些基础属性.它从plugin.yml中读取. 这个文件由一组元素组成,并且没有缩进必需在新行定义.

属性
属性 必需 描述 示例 笔记
name 插件的名字. name: MyPlugin
  • Must consist of all alphanumeric characters and underscores (a-z,A-Z,0-9, _)
  • Used to determine the name of the plugin's data folder. Data folders are placed in the ./plugins/ directory by default.
  • It is good practice to name your jar the same as this, for example 'MyPlugin.jar'
version yes The version of this plugin. version: 1.4.1
  • Version is an arbitrary string, however the most common format is MajorRelease.MinorRelease.Build (eg: 1.4.1).
  • Typically you will increment this every time you release a new feature or bug fix.
  • Displayed when a user types /version PluginName
description no A human friendly description of the functionality your plugin provides. description: This plugin is so 31337. You can set yourself on fire.
  • The description can have multiple lines.
  • Displayed when a user types /version PluginName
load no Explicitly state when the plugin should be loaded. if not supplied will default to postworld load: STARTUP Has two possible values
  • STARTUP
  • POSTWORLD
author no Uniquely identifies who developed this plugin. author: CaptainInflamo
  • Gives credit to the developer.
  • Used in some server error messages to provide helpful feedback on who to contact when an error occurs.
  • A bukkit.org forum handle or email address is recommended.
  • Is displayed when a user types /version PluginName
authors no Allows you to list multiple authors, if it is a collaborative project. See author. authors: [Cogito, verrier, EvilSeph]
  • You can define both author and authors, however they will be merged into one list internally.
website no The plugin's or author's website. website: http://forums.bukkit.org/threads/MyPlugin.31337/
  • If you have no dedicated website, a link to the Bukkit forum post where this plugin is listed is highly recommended.
  • Displayed when a user types /version PluginName
main yes Points to the class that extends JavaPlugin main: org.bukkit.plugin.MyPlugin
  • Note that this must contain the full namespace including the class file itself.
  • If your namespace is org.bukkit.plugin, and your class file is called MyPlugin then this must be org.bukkit.plugin.MyPlugin
database no Set to true if this plugin uses a database. database: false
depend no A list of plugins that your plugin requires to load. depend: [OnePlugin, AnotherPlugin]
  • The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
  • Use the "name" attribute of the required plugin in order to specify the dependency.
  • If any plugin listed here is not found your plugin will fail to load.
  • If multiple plugins list each other as a depend, so that there are no plugins without an unloadable dependency, all will fail to load.
  • (See: Wiki: Plugin_Dependencies)
prefix no The name to use when logging to console instead of the plugin's name. prefix: ex-why-zee
softdepend no A list of plugins that are required for your plugin to have full functionality. softdepend: [OnePlugin, AnotherPlugin]
  • The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
  • Use the "name" atrribute of the desired plugin in order to specify the dependancy.
  • Your plugin will load after any plugins listed here.
  • Circular soft dependencies are loaded arbitrarily.
  • (See: Wiki: Plugin_Dependencies)
loadbefore no A list of plugins should be loaded after your plugin. loadbefore: [OnePlugin, AnotherPlugin]
  • The value must be in YAML list format (See http://en.wikipedia.org/wiki/YAML#Lists )
  • Treated as if the listed plugin soft depends on the specifying plugin.
  • Use the "name" atrribute of the desired plugin in order to specify the target.
  • Your plugin will load before any plugins listed here.
  • Circular soft dependencies are loaded arbitrarily.
  • (See: Wiki: Plugin_Dependencies)
commands no The name of a command the plugin wishes to register, as well as an optional list of command attributes.

commands:
 flagrate:
   [optional command attributes]

  • The command name should not contain the leading '/' required to issue a command.
  • You can choose any command name you wish, however 'common' commands such as /kick are often already registered. Use the 'alias' command attribute to supply alternate names. @TODO: verify we're happy with this
permissions no Permissions that the plugin whishes to register. Each node represents a permission to register. Each permission can have additional attributes.
permissions:
  inferno.*:
    [optional permission attributes]
  inferno.flagate:
    [optional permission attributes]
  inferno.burningdeaths:
    [optional permission attributes]
  • Permission registration is optional, can also be done from code
  • Permission registration allows you to set descriptions, defaults, and child parent relationships
  • Permission names should be kept in the style of <pluginname>.[category].[category].<permission>


A command block starts with the command's name, and then has a list of attributes.

Command Attribute Required Description Example Notes
description no A short description of what the command does. description: Set yourself on fire
  • Can be used in conjunction with /help
aliases no Alternate command names a user may use instead
aliases: combust_me OR 
aliases: [combust_me, combustMe, cm]
permission no The most basic permission node required to use the command
permission: inferno.flagrate
  • This permissions node can be used to determine if a user should be able to see this command
  • Some plugins will use this node to construct a personalized /help
permission-message no A no-permission message permission-message: You do not have /<permission>
  • Displayed to a player that attempts to use a command but does not have the associated permission
  • <permission> is a macro that is replaced with the permission node that is required to use the command.
  • You may use empty quotes to indicate nothing should be displayed.
usage no A short description of how to use this command. usage: Syntax error! Perhaps you meant /<command> PlayerName?
  • Displayed to whoever issued the command when the plugin's command handler (onCommand typically) does not return true.
  • <command> is a macro that is replaced with the command issued wherever it occurs.
  • To use the string "Usage:" (i.e. usage: Usage: /god [player], surround the text after the usage: label with double-quotes:
    usage: "Usage: /god [player]"


A permission block starts with the permission's name and is followed by nodes of attributes

Permission Attribute Required Description Example Notes
description no A short description of what this permission allows
description: Allows you to set yourself on fire
  • Allows programmatic access, and helps server administrators
default no Sets the default value of the permission
default: true
  • If node does not exist the permission defaults to op
  • allowed defaults are: true, false, op, not op
  • op default will be true if player is op
  • no op default is the opposite behavior (of op)
children no allows you to set children for the permission. Child nodes are permission names
children:
  inferno.flagrate: true
  inferno.burningdeaths: true
  • Each child node must be either set to true or false
    • a child node of true inherits the parent permission
    • a child node of false inherits the inverse parent permission
  • Can also contain other permission nodes {1}


Example:

 name: Inferno
 version: 1.4.1
 description: This plugin is so 31337. You can set yourself on fire.
 # We could place every author in the authors list, but chose not to for illustrative purposes
 # Also, having an author distinguishes that person as the project lead, and ensures their 
 # name is displayed first
 author: CaptainInflamo
 authors: [Cogito, verrier, EvilSeph] 
 website: http://forums.bukkit.org/threads/MyPlugin.31337/
 
 main: com.captaininflamo.bukkit.inferno.Inferno
 database: false
 depend: [NewFire, FlameWire]
 
 commands:
   flagrate:
     description: Set yourself on fire.
     aliases: [combust_me, combustMe]
     permission: inferno.flagrate
     usage: Syntax error! Simply type /&lt;command&gt; to ignite yourself.
   burningdeaths:
     description: List how many times you have died by fire.
     aliases: [burning_deaths, burningDeaths]
     permission: inferno.burningdeaths
     usage: |
       /&lt;command&gt; [player]
       Example: /&lt;command&gt; - see how many times you have burned to death
       Example: /&lt;command&gt; CaptainIce - see how many times CaptainIce has burned to death
 
 permissions:
   inferno.*:
     description: Gives access to all Inferno commands
     children:
       inferno.flagrate: true
       inferno.burningdeaths: true
       inferno.burningdeaths.others: true
   inferno.flagrate:
     description: Allows you to ignite yourself
     default: true
   inferno.burningdeaths:
     description: Allows you to see how many times you have burned to death
     default: true
   inferno.burningdeaths.others:
     description: Allows you to see how many times others have burned to death
     default: op
     children:
       inferno.burningdeaths: true
Language   中文English日本語