mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-09 20:41:23 +01:00
Added SimplyPerms Handler
This commit is contained in:
parent
52b104aca5
commit
62832ad43a
@ -134,6 +134,17 @@ public class PermissionsHandler implements IPermissionsHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin simplyPermsPlugin = pluginManager.getPlugin("SimplyPerms");
|
||||
if (simplyPermsPlugin != null && simplyPermsPlugin.isEnabled())
|
||||
{
|
||||
if (!(handler instanceof SimplyPermsHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using SimplyPerms based permissions.");
|
||||
handler = new SimplyPermsHandler(simplyPermsPlugin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin privPlugin = pluginManager.getPlugin("Privileges");
|
||||
if (privPlugin != null && privPlugin.isEnabled())
|
||||
{
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SimplyPermsHandler extends SuperpermsHandler {
|
||||
|
||||
private final transient SimplyAPI api;
|
||||
|
||||
public SimplyPermsHandler(final Plugin plugin) {
|
||||
this.api = ((SimplyPlugin) plugin).getAPI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
final List<String> groups = api.getPlayerGroups(base.getName());
|
||||
if (groups == null || groups.isEmpty()) return null;
|
||||
return groups.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return api.getPlayerGroups(base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
final List<String> groups = api.getPlayerGroups(base.getName());
|
||||
for (String group1 : groups)
|
||||
{
|
||||
if (group1.equalsIgnoreCase(group))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player base, String group)
|
||||
{
|
||||
return hasPermission(base, "essentials.build") || hasPermission(base, "permissions.allow.build");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user