Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Integrating with PEX

zml edited this page Aug 26, 2015 · 6 revisions

Want to get information from PEX? There are some things you should consider before directly hooking into PEX.

Contents

Integration Methods (top)

Using the native API adds complexity to your plugin and reduces compatibility. Instead of directly using the native API, the majority of permissions operations can be done through the Superperms player.hasPermission(String) method. This method is the most widely compatible and stable, and is preferred when possible. Additionally, with PEX this method supports more than just permissions thanks to the added metapermissions

For any operations that cannot be done through Superperms, Vault should be used. See the Vault BukkitDev page for more information on how to integrate with Vault. Vault, while still requiring a dependency, provides one API for whatever permissions plugin a server admin is using, making plugins that need more permissions access than superperms provides more widely accessible.

If the API provided by Vault is still not enough, the native PEX API is your last resort. PermissionsEx is available through Maven, as specified in the Maven descriptors below. The native API is the least stable of the options, sometimes changing to reflect changes in PEX's operations. No API changes should exist between n.n.x minor versions. API changes may exist between n.x versions. Major version increases almost certainly contain major API changes.

Dependency:

<dependency>
    <groupId>ru.tehkode</groupId>
    <artifactId>PermissionsEx</artifactId>
    <version>1.22</version>
</dependency>

Repository:

<repository>
    <id>pex-repo</id>
    <url>http://pex-repo.aoeu.xyz</url>
</repository>

Metapermissions added to Superperms (top)

PermissionsEx adds several permissions to each user's superperms cache to allow access to certain information without any additional dependencies. These permissions are:

Permission Usage
group.<group> Added for each group a user is in
groups.<group> same as above
options.<option>.<value> Each option the user has
prefix.<prefix> User's prefix
suffix.<suffix> User's suffix

These permissions are visible through every superperms method, but not through Vault or the native API.

Javadocs (top)

Javadocs for the latest development version are automatically generated from the latest sources. Note that these documents represent the API as of development builds, which may be different from the release API. Javadocs can also be generated from PEX sources locally with the command mvn javadoc:javadoc.

Code Example (top)

	PermissionUser user = PermissionsEx.getUser(player);
		
	// Check permission in specific world
	user.has(permission, world); // we recommend to use player.has(permission) in common cases
		
	// Get player permissions
	String[] permissions = user.getPermissions(world);
		
	// Returns player's groups in particular world
	String[] groups = user.getParentIdentifiers(world);
		
	// Set player groups for specific world, use world = null for all worlds
	user.setParentsIdentifier(groups, world);
		
	// Add player group in all worlds
	user.addGroup(groupName);
		
	// returns player prefix in specific world
	String prefix = user.getPrefix(world);
			
	// Returns player option (setting) in specific world
	String playerOption = user.getOption("player-option", world);
Previous: Commands, Next: Troubleshooting and FAQ