summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/Permissions2Handler.java
blob: 71d7da58b2393164d62ab184e70c225f2a6b2cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.earth2me.essentials;

import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;


public class Permissions2Handler implements IPermissionsHandler
{
	private final transient PermissionHandler permissionHandler;

	Permissions2Handler(final Plugin permissionsPlugin)
	{
		permissionHandler = ((Permissions)permissionsPlugin).getHandler();
	}

	public String getGroup(final Player base)
	{
		final String group = permissionHandler.getGroup(base.getWorld().getName(), base.getName());
		return group == null ? "default" : group;
	}

	public boolean canBuild(final Player base, final String group)
	{
		return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base));
	}

	public boolean inGroup(final Player base, final String group)
	{
		return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
	}

	public boolean hasPermission(final Player base, final String node)
	{
		return permissionHandler.permission(base, node);
	}

	public String getPrefix(final Player base)
	{
		final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
		return prefix == null ? "" : prefix;
	}

	public String getSuffix(final Player base)
	{
		final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
		return suffix == null ? "" : suffix;
	}
}