<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://mineplugin.org/index.php?action=history&amp;feed=atom&amp;title=Developing_a_permissions_plugin%2Fen</id>
	<title>Developing a permissions plugin/en - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://mineplugin.org/index.php?action=history&amp;feed=atom&amp;title=Developing_a_permissions_plugin%2Fen"/>
	<link rel="alternate" type="text/html" href="https://mineplugin.org/index.php?title=Developing_a_permissions_plugin/en&amp;action=history"/>
	<updated>2026-05-30T20:10:14Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://mineplugin.org/index.php?title=Developing_a_permissions_plugin/en&amp;diff=1406&amp;oldid=prev</id>
		<title>Iwar：​创建条目原文</title>
		<link rel="alternate" type="text/html" href="https://mineplugin.org/index.php?title=Developing_a_permissions_plugin/en&amp;diff=1406&amp;oldid=prev"/>
		<updated>2015-09-02T23:49:58Z</updated>

		<summary type="html">&lt;p&gt;创建条目原文&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{条目原文}}&lt;br /&gt;
== Introduction  ==&lt;br /&gt;
&lt;br /&gt;
This tutorial will guide you through how to create your own permissions plugin that sets permissions using the new Bukkit permissions API. &lt;br /&gt;
&lt;br /&gt;
=== Prerequisite  ===&lt;br /&gt;
&lt;br /&gt;
This tutorial assumes you have a good understanding of the Java language, and general plugin development. This tutorial will only cover the specifics of the 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 &amp;#039;&amp;#039;Permissible&amp;#039;&amp;#039; class. Currently these only include the &amp;#039;&amp;#039;Player&amp;#039;&amp;#039; and &amp;#039;&amp;#039;CommandSender&amp;#039;&amp;#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.&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&amp;#039;s permissions, and even better, allows multiple plugins to manage the player&amp;#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&amp;#039;s Unique ID. That will later allow you to manage a particular player&amp;#039;s permissions via their Unique ID, and remove the attachment when it&amp;#039;s no longer needed. The best places to remove the attachment are in the &amp;#039;&amp;#039;onPlayerQuit&amp;#039;&amp;#039; event, &amp;#039;&amp;#039;onPlayerKick&amp;#039;&amp;#039; event, and remove them all in the plugin&amp;#039;s &amp;#039;&amp;#039;onDisable&amp;#039;&amp;#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&amp;#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&amp;#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&amp;#039;s permission you firstly have to get the PermissionAttachment you created earlier from the HashMap. Once you have this then setting a player&amp;#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&amp;#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&amp;#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&amp;#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&amp;#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&amp;#039;s permissions&lt;/div&gt;</summary>
		<author><name>Iwar</name></author>
	</entry>
</feed>