blob: d47c3c8a4cc013e2e75d99338f786d99ae48f033 (
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
77
|
package com.earth2me.essentials.perm;
import com.platymuus.bukkit.permissions.Group;
import com.platymuus.bukkit.permissions.PermissionInfo;
import com.platymuus.bukkit.permissions.PermissionsPlugin;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class PermissionsBukkitHandler extends SuperpermsHandler
{
private final transient PermissionsPlugin plugin;
public PermissionsBukkitHandler(final Plugin plugin)
{
this.plugin = (PermissionsPlugin)plugin;
}
@Override
public String getGroup(final Player base)
{
final List<Group> groups = getPBGroups(base);
if (groups == null || groups.isEmpty())
{
return null;
}
return groups.get(0).getName();
}
@Override
public List<String> getGroups(final Player base)
{
final List<Group> groups = getPBGroups(base);
if (groups.size() == 1)
{
return Collections.singletonList(groups.get(0).getName());
}
final List<String> groupNames = new ArrayList<String>(groups.size());
for (Group group : groups)
{
groupNames.add(group.getName());
}
return groupNames;
}
private List<Group> getPBGroups(final Player base)
{
final PermissionInfo info = plugin.getPlayerInfo(base.getName());
if (info == null)
{
return Collections.emptyList();
}
final List<Group> groups = info.getGroups();
if (groups == null || groups.isEmpty())
{
return Collections.emptyList();
}
return groups;
}
@Override
public boolean inGroup(final Player base, final String group)
{
final List<Group> groups = getPBGroups(base);
for (Group group1 : groups)
{
if (group1.getName().equalsIgnoreCase(group))
{
return true;
}
}
return false;
}
}
|