Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We'll use the VaultAPI if it's there for group checks. This will also allow us to default to Player#hasPermission from Bukkit instead of going through each permission plugin.
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Essentials/src/com/earth2me/essentials/perm/VaultHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.earth2me.essentials.perm; | ||
|
||
import com.earth2me.essentials.Essentials; | ||
import net.milkbowl.vault.permission.Permission; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class VaultHandler extends SuperpermsHandler { | ||
|
||
private Essentials plugin; | ||
private static Permission perms = null; | ||
|
||
public VaultHandler(Essentials plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public boolean setupPermissions() { | ||
try { | ||
Class.forName("net.milkbowl.vault.permission.Permission"); | ||
} catch (ClassNotFoundException e) { | ||
return false; | ||
} | ||
|
||
RegisteredServiceProvider<Permission> rsp = plugin.getServer().getServicesManager().getRegistration(Permission.class); | ||
perms = rsp.getProvider(); | ||
return perms != null; | ||
} | ||
|
||
@Override | ||
public String getGroup(final Player base) { | ||
return perms.getPrimaryGroup(base); | ||
} | ||
|
||
@Override | ||
public List<String> getGroups(final Player base) { | ||
return Arrays.asList(perms.getPlayerGroups(base)); | ||
} | ||
|
||
@Override | ||
public boolean inGroup(final Player base, final String group) { | ||
return perms.playerInGroup(base, group); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(final Player base, String node) { | ||
return base.hasPermission(node); | ||
} | ||
} |