mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
Added keys. I'm not sure why I did this to begin with.
This commit is contained in:
parent
b54b063c9c
commit
b0cd0c5388
@ -20,7 +20,7 @@ public class PermissionManager {
|
|||||||
|
|
||||||
private final SkyBlock plugin;
|
private final SkyBlock plugin;
|
||||||
|
|
||||||
private final List<BasicPermission> registeredPermissions = new ArrayList<>();
|
private final Map<String, BasicPermission> registeredPermissions = new HashMap<>();
|
||||||
private List<HandlerWrapper> registeredHandlers = new LinkedList<>();
|
private List<HandlerWrapper> registeredHandlers = new LinkedList<>();
|
||||||
|
|
||||||
public PermissionManager(SkyBlock plugin) {
|
public PermissionManager(SkyBlock plugin) {
|
||||||
@ -109,7 +109,7 @@ public class PermissionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean registerPermission(BasicPermission permission) {
|
public boolean registerPermission(BasicPermission permission) {
|
||||||
registeredPermissions.add(permission);
|
registeredPermissions.put(permission.getName().toUpperCase(), permission);
|
||||||
Set<Method> methods;
|
Set<Method> methods;
|
||||||
try {
|
try {
|
||||||
Method[] publicMethods = permission.getClass().getMethods();
|
Method[] publicMethods = permission.getClass().getMethods();
|
||||||
@ -198,17 +198,15 @@ public class PermissionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BasicPermission getPermission(String permissionName) {
|
public BasicPermission getPermission(String permissionName) {
|
||||||
return registeredPermissions.stream()
|
return registeredPermissions.get(permissionName.toUpperCase());
|
||||||
.filter(p -> p.getName().equalsIgnoreCase(permissionName))
|
|
||||||
.findFirst().orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BasicPermission> getPermissions() {
|
public List<BasicPermission> getPermissions() {
|
||||||
return new ArrayList<>(registeredPermissions);
|
return new ArrayList<>(registeredPermissions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ListeningPermission> getListeningPermissions() {
|
public List<ListeningPermission> getListeningPermissions() {
|
||||||
return registeredPermissions.stream()
|
return registeredPermissions.values().stream()
|
||||||
.filter(p -> p instanceof ListeningPermission)
|
.filter(p -> p instanceof ListeningPermission)
|
||||||
.map(p -> (ListeningPermission) p)
|
.map(p -> (ListeningPermission) p)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
Loading…
Reference in New Issue
Block a user