summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src/net/ess3/protect/Permissions.java
blob: 9574ca886d1f6c3f40630b8fd567c242aa4316e0 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package net.ess3.protect;

import java.util.Locale;
import net.ess3.api.IPermission;
import net.ess3.bukkit.PermissionFactory;
import net.ess3.permissions.DotStarPermission;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;


public enum Permissions implements IPermission
{	
	PVP(PermissionDefault.TRUE),
	PREVENTDAMAGE_FALL(PermissionDefault.FALSE),
	PREVENTDAMAGE_CREEPER(PermissionDefault.FALSE),
	PREVENTDAMAGE_CONTACT(PermissionDefault.FALSE),
	PREVENTDAMAGE_FIREBALL(PermissionDefault.FALSE),
	PREVENTDAMAGE_PROJECTILES(PermissionDefault.FALSE),
	PREVENTDAMAGE_LAVADAMAGE(PermissionDefault.FALSE),
	PREVENTDAMAGE_TNT(PermissionDefault.FALSE),
	PREVENTDAMAGE_SUFFOCATION(PermissionDefault.FALSE),
	PREVENTDAMAGE_FIRE(PermissionDefault.FALSE),
	PREVENTDAMAGE_DROWNING(PermissionDefault.FALSE),
	PREVENTDAMAGE_LIGHTNING(PermissionDefault.FALSE),
	PREVENTDAMAGE_WITHER(PermissionDefault.FALSE),
	PREVENTDAMAGE_NONE(PermissionDefault.FALSE),
	USEFLINTSTEEL(PermissionDefault.TRUE);
	private static final String base = "essentials.protect.";
	private final String permission;
	private final PermissionDefault defaultPerm;
	private transient String parent = null;

	private Permissions()
	{
		this(PermissionDefault.OP);
	}

	private Permissions(final PermissionDefault defaultPerm)
	{
		permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.');
		this.defaultPerm = defaultPerm;
	}

	@Override
	public String getPermissionName()
	{
		return permission;
	}

	@Override
	public String getParentPermission()
	{
		if (parent != null)
		{
			return parent;
		}
		else
		{
			return PermissionFactory.registerParentPermission(getPermissionName());
		}
	}

	@Override
	public PermissionDefault getPermissionDefault()
	{
		return this.defaultPerm;
	}

	@Override
	public boolean isAuthorized(final CommandSender sender)
	{
		return PermissionFactory.checkPermission(sender, this);
	}

		public static DotStarPermission ENTITY_TARGET_BYPASS = new DotStarPermission("essentials.protect.entitytarget.bypass");
}