<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://mineplugin.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SAlNO3</id>
	<title>Minecraft插件百科 - 用户贡献 [zh-cn]</title>
	<link rel="self" type="application/atom+xml" href="https://mineplugin.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=SAlNO3"/>
	<link rel="alternate" type="text/html" href="https://mineplugin.org/%E7%89%B9%E6%AE%8A:%E7%94%A8%E6%88%B7%E8%B4%A1%E7%8C%AE/SAlNO3"/>
	<updated>2026-08-06T02:28:03Z</updated>
	<subtitle>用户贡献</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1594</id>
		<title>Developing a permissions plugin</title>
		<link rel="alternate" type="text/html" href="https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1594"/>
		<updated>2015-10-22T19:21:17Z</updated>

		<summary type="html">&lt;p&gt;SAlNO3：​&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Developing a permissions plugin/en|点击此处查看原文]]&lt;br /&gt;
{{待翻译}}&lt;br /&gt;
== 引言  ==&lt;br /&gt;
&lt;br /&gt;
这篇教程将会带领你了解有关怎么基于新的BukkitPermissionsAPI给你插件创建权限。&lt;br /&gt;
&lt;br /&gt;
=== 前提  ===&lt;br /&gt;
&lt;br /&gt;
这篇教程需要你掌握很好的Java知识和一些插件开发知识。这篇教程只会涵盖有关Bukkit Permissions API的各种细节。&lt;br /&gt;
&lt;br /&gt;
== Permissible  ==&lt;br /&gt;
&lt;br /&gt;
Everything that can have permissions set must inherit the &#039;&#039;Permissible&#039;&#039; class. Currently these only include the &#039;&#039;Player&#039;&#039; and &#039;&#039;CommandSender&#039;&#039; classes, however in theory anything could have permissions. For the future of this tutorial we will mention the player rather than a permissible object.&amp;lt;br /&amp;gt;&lt;br /&gt;
所有拥有权限集的类都必须继承自Permissible类。&amp;lt;br /&amp;gt;&lt;br /&gt;
目前这些只包含Player和CommandSender类，然而理论上任何事物都应该拥有“权限”。&amp;lt;br /&amp;gt;在接下来的教程里我们将更多的提到玩家而不是permissible对象。&lt;br /&gt;
&lt;br /&gt;
== PermissionAttachments  ==&lt;br /&gt;
&lt;br /&gt;
=== What is a PermissionAttachment?  ===&lt;br /&gt;
&amp;lt;br/&amp;gt;什么是PermissionAttachment？&lt;br /&gt;
&amp;lt;br/&amp;gt;A permission attachment is a way for a plugin to manage a player&#039;s permissions, and even better, allows multiple plugins to manage the player&#039;s permissions without interference, unless of course they want to set the same permission.&amp;lt;br/&amp;gt;“权限附属物”[PermissionAttachment]是插件管理玩家权限的一种手段，更胜一筹的是，它允许多插件管理玩家权限而不需要接口，除非它想要设置同样的权限。&lt;br /&gt;
&lt;br /&gt;
=== How to create and remove them  ===&lt;br /&gt;
&amp;lt;br/&amp;gt;如何创建和移除一个PermissionAttachment&lt;br /&gt;
&amp;lt;br/&amp;gt;Every player must first be &amp;quot;attached&amp;quot; to the plugin so that it can be managed. To create a PermissionAttachment, use the following: &lt;br /&gt;
&amp;lt;br/&amp;gt;每一位玩家必须先被“附着”在插件上，这样才能使用他们。用如下代码来创建一个PermissionAttachment:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can even create an attachment that will only last for a limited number of ticks: &lt;br /&gt;
&amp;lt;br/&amp;gt;你甚至可以创建一个仅仅只维持很短时间的attachment&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin,ticks);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This attachment needs to be stored somewhere though. The best solution is to create a &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;HashMap&amp;lt;UUID,PermissionAttachment&amp;gt;&amp;lt;/source&amp;gt;&amp;amp;nbsp;and store it in there with the player&#039;s Unique ID. That will later allow you to manage a particular player&#039;s permissions via their Unique ID, and remove the attachment when it&#039;s no longer needed. The best places to remove the attachment are in the &#039;&#039;onPlayerQuit&#039;&#039; event, &#039;&#039;onPlayerKick&#039;&#039; event, and remove them all in the plugin&#039;s &#039;&#039;onDisable&#039;&#039; event. Removing the attachment is as follows: &lt;br /&gt;
&amp;lt;br/&amp;gt;attachment需要被储存起来。最好的解决方案是用哈希表HashMap&amp;lt;UUID,PermissionAttachment&amp;gt; 来储存。用玩家的UniqueID作为键值。之后你就可以用玩家的UniqueID来管理指定玩家的权限了。 并且在不需要的时候移除它。移除attachment的地方最好是onPlayerQuit event, onPlayerKick event。并且总是在插件的onDisable中移除所有的attachment。使用下面的代码移除attachment：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;player.removeAttachment(attachment);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning permissions  ==&lt;br /&gt;
&lt;br /&gt;
There are two main ways to set a player&#039;s permission: &lt;br /&gt;
&amp;lt;br/&amp;gt;这有两种主要的方法去配置玩家的权限：&lt;br /&gt;
&lt;br /&gt;
#Via a string. This is probably the easiest method, and the one which I will explain first. &lt;br /&gt;
通过字符串。这大概是最简单的方法了，所以我最先解释它。&lt;br /&gt;
#Via a permission Object. This is slightly more complicated, however it works in exactly the same way as the first internally, so I won&#039;t bother going over this.&lt;br /&gt;
通过permission对象。这就有点复杂了，然而他内部的工作方式与第一个完全一样。所以我并不打算重温它。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
To set a player&#039;s permission you firstly have to get the PermissionAttachment you created earlier from the HashMap. Once you have this then setting a player&#039;s permissions is easy via the following: &lt;br /&gt;
&amp;lt;br/&amp;gt;想要设置玩家的权限你必须先获取之前通过哈希表创建的PermissionAttachment。一旦你取得了PermissionAttachment，你就可以通过一种简单的方式来设置权限。代码如下：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.setPermission(permissionName,permissionValue);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The permissionName is a String, and permissionValue is a boolean. You can later unset a player&#039;s permission (different to setting it to false) through the following: &lt;br /&gt;
&amp;lt;br/&amp;gt;permissionName是一个字符串，permissionValue则是布尔类型数据。之后你可以通过如下代码撤销一个玩家的权限(与将permissionValue设置成false不同)：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.unsetPermission(permissionName);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The reason you may want to unset a player&#039;s permission is if you want to allow a different permissions plugin to set it. &lt;br /&gt;
,br/&amp;gt;撤销玩家权限的原因是你希望别的权限插件来设置它。&lt;br /&gt;
== Conclusion  ==&lt;br /&gt;
&lt;br /&gt;
That&#039;s about all there is to know about writing your own permissions plugin. The actual implementation of the plugin however is up to you. I can however provide a few examples: &lt;br /&gt;
&amp;lt;br/&amp;gt;一个真正的权限插件是什么样的完全取决于你。下面提供2个例子：&lt;br /&gt;
*An RPG plugin that gives player&#039;s permissions based on their XP &lt;br /&gt;
*A forum bridge that links groups/permissions from a forum such as phpBB to bukkit&#039;s permissions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:开发教程]]&lt;/div&gt;</summary>
		<author><name>SAlNO3</name></author>
	</entry>
	<entry>
		<id>https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1593</id>
		<title>Developing a permissions plugin</title>
		<link rel="alternate" type="text/html" href="https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1593"/>
		<updated>2015-10-22T19:07:18Z</updated>

		<summary type="html">&lt;p&gt;SAlNO3：​/* What is a PermissionAttachment? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Developing a permissions plugin/en|点击此处查看原文]]&lt;br /&gt;
{{待翻译}}&lt;br /&gt;
== 引言  ==&lt;br /&gt;
&lt;br /&gt;
这篇教程将会带领你了解有关怎么基于新的BukkitPermissionsAPI给你插件创建权限。&lt;br /&gt;
&lt;br /&gt;
=== 前提  ===&lt;br /&gt;
&lt;br /&gt;
这篇教程需要你掌握很好的Java知识和一些插件开发知识。这篇教程只会涵盖有关Bukkit Permissions API的各种细节。&lt;br /&gt;
&lt;br /&gt;
== Permissible  ==&lt;br /&gt;
&lt;br /&gt;
Everything that can have permissions set must inherit the &#039;&#039;Permissible&#039;&#039; class. Currently these only include the &#039;&#039;Player&#039;&#039; and &#039;&#039;CommandSender&#039;&#039; classes, however in theory anything could have permissions. For the future of this tutorial we will mention the player rather than a permissible object.&amp;lt;br /&amp;gt;&lt;br /&gt;
所有拥有权限集的类都必须继承自Permissible类。&amp;lt;br /&amp;gt;&lt;br /&gt;
目前这些只包含Player和CommandSender类，然而理论上任何事物都应该拥有“权限”。&amp;lt;br /&amp;gt;在接下来的教程里我们将更多的提到玩家而不是permissible对象。&lt;br /&gt;
&lt;br /&gt;
== PermissionAttachments  ==&lt;br /&gt;
&lt;br /&gt;
=== What is a PermissionAttachment?  ===&lt;br /&gt;
什么是PermissionAttachment？&amp;lt;br/&amp;gt;&lt;br /&gt;
A permission attachment is a way for a plugin to manage a player&#039;s permissions, and even better, allows multiple plugins to manage the player&#039;s permissions without interference, unless of course they want to set the same permission.&amp;lt;br/&amp;gt;&lt;br /&gt;
“权限附属物”[PermissionAttachment]是插件管理玩家权限的一种手段，更胜一筹的是，它允许多插件管理玩家权限而不需要接口，除非它想要设置同样的权限。&lt;br /&gt;
&lt;br /&gt;
=== How to create and remove them  ===&lt;br /&gt;
&lt;br /&gt;
Every player must first be &amp;quot;attached&amp;quot; to the plugin so that it can be managed. To create a PermissionAttachment, use the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can even create an attachment that will only last for a limited number of ticks: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin,ticks);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This attachment needs to be stored somewhere though. The best solution is to create a &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;HashMap&amp;lt;UUID,PermissionAttachment&amp;gt;&amp;lt;/source&amp;gt;&amp;amp;nbsp;and store it in there with the player&#039;s Unique ID. That will later allow you to manage a particular player&#039;s permissions via their Unique ID, and remove the attachment when it&#039;s no longer needed. The best places to remove the attachment are in the &#039;&#039;onPlayerQuit&#039;&#039; event, &#039;&#039;onPlayerKick&#039;&#039; event, and remove them all in the plugin&#039;s &#039;&#039;onDisable&#039;&#039; event. Removing the attachment is as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;player.removeAttachment(attachment);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning permissions  ==&lt;br /&gt;
&lt;br /&gt;
There are two main ways to set a player&#039;s permission: &lt;br /&gt;
&lt;br /&gt;
#Via a string. This is probably the easiest method, and the one which I will explain first. &lt;br /&gt;
#Via a permission Object. This is slightly more complicated, however it works in exactly the same way as the first internally, so I won&#039;t bother going over this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
To set a player&#039;s permission you firstly have to get the PermissionAttachment you created earlier from the HashMap. Once you have this then setting a player&#039;s permissions is easy via the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.setPermission(permissionName,permissionValue);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The permissionName is a String, and permissionValue is a boolean. You can later unset a player&#039;s permission (different to setting it to false) through the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.unsetPermission(permissionName);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The reason you may want to unset a player&#039;s permission is if you want to allow a different permissions plugin to set it. &lt;br /&gt;
&lt;br /&gt;
== Conclusion  ==&lt;br /&gt;
&lt;br /&gt;
That&#039;s about all there is to know about writing your own permissions plugin. The actual implementation of the plugin however is up to you. I can however provide a few examples: &lt;br /&gt;
&lt;br /&gt;
*An RPG plugin that gives player&#039;s permissions based on their XP &lt;br /&gt;
*A forum bridge that links groups/permissions from a forum such as phpBB to bukkit&#039;s permissions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:开发教程]]&lt;/div&gt;</summary>
		<author><name>SAlNO3</name></author>
	</entry>
	<entry>
		<id>https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1592</id>
		<title>Developing a permissions plugin</title>
		<link rel="alternate" type="text/html" href="https://mineplugin.org/index.php?title=Developing_a_permissions_plugin&amp;diff=1592"/>
		<updated>2015-10-22T19:02:34Z</updated>

		<summary type="html">&lt;p&gt;SAlNO3：​/* Permissible */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Developing a permissions plugin/en|点击此处查看原文]]&lt;br /&gt;
{{待翻译}}&lt;br /&gt;
== 引言  ==&lt;br /&gt;
&lt;br /&gt;
这篇教程将会带领你了解有关怎么基于新的BukkitPermissionsAPI给你插件创建权限。&lt;br /&gt;
&lt;br /&gt;
=== 前提  ===&lt;br /&gt;
&lt;br /&gt;
这篇教程需要你掌握很好的Java知识和一些插件开发知识。这篇教程只会涵盖有关Bukkit Permissions API的各种细节。&lt;br /&gt;
&lt;br /&gt;
== Permissible  ==&lt;br /&gt;
&lt;br /&gt;
Everything that can have permissions set must inherit the &#039;&#039;Permissible&#039;&#039; class. Currently these only include the &#039;&#039;Player&#039;&#039; and &#039;&#039;CommandSender&#039;&#039; classes, however in theory anything could have permissions. For the future of this tutorial we will mention the player rather than a permissible object.&amp;lt;br /&amp;gt;&lt;br /&gt;
所有拥有权限集的类都必须继承自Permissible类。&amp;lt;br /&amp;gt;&lt;br /&gt;
目前这些只包含Player和CommandSender类，然而理论上任何事物都应该拥有“权限”。&amp;lt;br /&amp;gt;在接下来的教程里我们将更多的提到玩家而不是permissible对象。&lt;br /&gt;
&lt;br /&gt;
== PermissionAttachments  ==&lt;br /&gt;
&lt;br /&gt;
=== What is a PermissionAttachment?  ===&lt;br /&gt;
&lt;br /&gt;
A permission attachment is a way for a plugin to manage a player&#039;s permissions, and even better, allows multiple plugins to manage the player&#039;s permissions without interference, unless of course they want to set the same permission. &lt;br /&gt;
&lt;br /&gt;
=== How to create and remove them  ===&lt;br /&gt;
&lt;br /&gt;
Every player must first be &amp;quot;attached&amp;quot; to the plugin so that it can be managed. To create a PermissionAttachment, use the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
You can even create an attachment that will only last for a limited number of ticks: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;PermissionAttachment attachment = player.addAttachment(plugin,ticks);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
This attachment needs to be stored somewhere though. The best solution is to create a &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;HashMap&amp;lt;UUID,PermissionAttachment&amp;gt;&amp;lt;/source&amp;gt;&amp;amp;nbsp;and store it in there with the player&#039;s Unique ID. That will later allow you to manage a particular player&#039;s permissions via their Unique ID, and remove the attachment when it&#039;s no longer needed. The best places to remove the attachment are in the &#039;&#039;onPlayerQuit&#039;&#039; event, &#039;&#039;onPlayerKick&#039;&#039; event, and remove them all in the plugin&#039;s &#039;&#039;onDisable&#039;&#039; event. Removing the attachment is as follows: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;player.removeAttachment(attachment);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning permissions  ==&lt;br /&gt;
&lt;br /&gt;
There are two main ways to set a player&#039;s permission: &lt;br /&gt;
&lt;br /&gt;
#Via a string. This is probably the easiest method, and the one which I will explain first. &lt;br /&gt;
#Via a permission Object. This is slightly more complicated, however it works in exactly the same way as the first internally, so I won&#039;t bother going over this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
To set a player&#039;s permission you firstly have to get the PermissionAttachment you created earlier from the HashMap. Once you have this then setting a player&#039;s permissions is easy via the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.setPermission(permissionName,permissionValue);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The permissionName is a String, and permissionValue is a boolean. You can later unset a player&#039;s permission (different to setting it to false) through the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;attachment.unsetPermission(permissionName);&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The reason you may want to unset a player&#039;s permission is if you want to allow a different permissions plugin to set it. &lt;br /&gt;
&lt;br /&gt;
== Conclusion  ==&lt;br /&gt;
&lt;br /&gt;
That&#039;s about all there is to know about writing your own permissions plugin. The actual implementation of the plugin however is up to you. I can however provide a few examples: &lt;br /&gt;
&lt;br /&gt;
*An RPG plugin that gives player&#039;s permissions based on their XP &lt;br /&gt;
*A forum bridge that links groups/permissions from a forum such as phpBB to bukkit&#039;s permissions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:开发教程]]&lt;/div&gt;</summary>
		<author><name>SAlNO3</name></author>
	</entry>
</feed>