diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index adc4617a..558a71df 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -20,7 +20,7 @@ public class PermissionManager { private final SkyBlock plugin; - private final List registeredPermissions = new ArrayList<>(); + private final Map registeredPermissions = new HashMap<>(); private List registeredHandlers = new LinkedList<>(); public PermissionManager(SkyBlock plugin) { @@ -109,7 +109,7 @@ public class PermissionManager { } public boolean registerPermission(BasicPermission permission) { - registeredPermissions.add(permission); + registeredPermissions.put(permission.getName().toUpperCase(), permission); Set methods; try { Method[] publicMethods = permission.getClass().getMethods(); @@ -198,17 +198,15 @@ public class PermissionManager { } public BasicPermission getPermission(String permissionName) { - return registeredPermissions.stream() - .filter(p -> p.getName().equalsIgnoreCase(permissionName)) - .findFirst().orElse(null); + return registeredPermissions.get(permissionName.toUpperCase()); } public List getPermissions() { - return new ArrayList<>(registeredPermissions); + return new ArrayList<>(registeredPermissions.values()); } public List getListeningPermissions() { - return registeredPermissions.stream() + return registeredPermissions.values().stream() .filter(p -> p instanceof ListeningPermission) .map(p -> (ListeningPermission) p) .collect(Collectors.toList());