-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed [Velocity crash](https://gist.github.com/Netherwhal/5e37bd8a1656dbb9ac8cc88530144a65) happening when users in list are null * Added forced stack trace to individuate error on Velocity restart * Removed internal static list and reworked constructor * Created UsersManager to keep track of loaded users * Added usersManager field * Added addUser method * Updated some methods to use users manager * Updated to use users manager to retrieve users * Updated SimplePermProvider
- Loading branch information
1 parent
4d8e6ec
commit 16dfea6
Showing
4 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/net/simplyvanilla/simplyperms/users/UsersManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.simplyvanilla.simplyperms.users; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class UsersManager { | ||
private final List<User> users; | ||
|
||
public UsersManager() { | ||
this.users = new LinkedList<>(); | ||
} | ||
|
||
public void addUser(User user) { | ||
this.users.add(user); | ||
} | ||
|
||
public User getUser(final UUID uniqueId) { | ||
return uniqueId == null ? null : getUsers().stream() | ||
.filter(g -> g.getUniqueId().equals(uniqueId)) | ||
.findFirst().orElseGet(() -> new User(uniqueId.toString())); | ||
} | ||
|
||
public List<User> getUsers() { | ||
this.users.removeIf(Objects::isNull); | ||
return new LinkedList<>(this.users); | ||
} | ||
|
||
public void clearUsers() { | ||
this.users.clear(); | ||
} | ||
} |