Added keys. I'm not sure why I did this to begin with.

This commit is contained in:
Brianna 2020-06-07 09:53:04 -05:00
parent b54b063c9c
commit b0cd0c5388

View File

@ -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());