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
77
78
79
80
81
|
package com.earth2me.essentials.protect;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IPermission;
import java.util.Locale;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
public enum Permissions implements IPermission
{
ALERTS,
ALERTS_NOTRIGGER,
ADMIN,
BUILD(PermissionDefault.TRUE),
ENTITYTARGET(PermissionDefault.TRUE),
INTERACT(PermissionDefault.TRUE),
OWNERINFO,
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_NONE(PermissionDefault.FALSE),
RAILS(PermissionDefault.TRUE),
USEFLINTSTEEL(PermissionDefault.TRUE);
private static final String base = "essentials.protect.";
private final String permission;
private final PermissionDefault defaultPerm;
private transient Permission bukkitPerm = null;
private Permissions()
{
this(PermissionDefault.OP);
}
private Permissions(final PermissionDefault defaultPerm)
{
permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.');
this.defaultPerm = defaultPerm;
}
@Override
public String getPermission()
{
return permission;
}
@Override
public Permission getBukkitPermission()
{
if (bukkitPerm != null)
{
return bukkitPerm;
}
else
{
return Util.registerPermission(getPermission(), getPermissionDefault());
}
}
@Override
public PermissionDefault getPermissionDefault()
{
return this.defaultPerm;
}
@Override
public boolean isAuthorized(CommandSender sender)
{
return sender.hasPermission(getBukkitPermission());
}
}
|