mirror of
https://github.com/plexusorg/Plex.git
synced 2025-06-29 14:56:43 +00:00
Add documentation to dev.plex.admin, dev.plex.banning, dev.plex.cache, and dev.plex.command (annotations and PlexCommand.java only)
Convert Date in punishments to LocalDateTime
This commit is contained in:
@ -6,18 +6,46 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Admin object to handle cached admins
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Admin
|
||||
{
|
||||
/**
|
||||
* Gets the unique ID of an admin (immutable)
|
||||
*/
|
||||
@Setter(AccessLevel.NONE)
|
||||
private UUID uuid;
|
||||
|
||||
/**
|
||||
* Gets the rank of the admin
|
||||
* <br>
|
||||
* Contains a #setRank and #getRank by lombok
|
||||
*/
|
||||
private Rank rank;
|
||||
|
||||
/**
|
||||
* Returns if the admin has command spy or not
|
||||
* <br>
|
||||
* Contains a #isCommandSpy and #setCommandSpy by lombok
|
||||
*/
|
||||
private boolean commandSpy = true;
|
||||
|
||||
/**
|
||||
* Returns if the admin has staff chat toggled or not
|
||||
* <br>
|
||||
* Contains a #isStaffChat and #setStaffChat by lombok
|
||||
*/
|
||||
private boolean staffChat = false;
|
||||
|
||||
/**
|
||||
* Creates an admin with the startig ADMIN rank
|
||||
* @param uuid
|
||||
* @see UUID
|
||||
* @see Rank
|
||||
*/
|
||||
public Admin(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
|
@ -15,21 +15,43 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Cached storage for Admin objects
|
||||
* @see Admin
|
||||
*/
|
||||
|
||||
public class AdminList
|
||||
{
|
||||
/**
|
||||
* Key/Value storage, where the key is the unique ID of the admin
|
||||
*/
|
||||
private final Map<UUID, Admin> admins = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* Adds the admin to cache
|
||||
* @param admin The admin object
|
||||
*/
|
||||
public void addToCache(Admin admin)
|
||||
{
|
||||
admins.put(admin.getUuid(), admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an admin from the cache
|
||||
* @param uuid The unique ID of the admin
|
||||
* @see UUID
|
||||
*/
|
||||
public void removeFromCache(UUID uuid)
|
||||
{
|
||||
admins.remove(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers every admin's username (cached and databsed)
|
||||
* @return An array list of the names of every admin
|
||||
*/
|
||||
public List<String> getAllAdmins()
|
||||
{
|
||||
List<String> admins = Lists.newArrayList();
|
||||
@ -37,13 +59,7 @@ public class AdminList
|
||||
{
|
||||
Datastore store = Plex.get().getMongoConnection().getDatastore();
|
||||
Query<PlexPlayer> query = store.find(PlexPlayer.class);
|
||||
for (PlexPlayer player : query)
|
||||
{
|
||||
if (player.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
admins.add(player.getName());
|
||||
}
|
||||
}
|
||||
admins.addAll(query.stream().filter(plexPlayer -> plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN)).map(PlexPlayer::getName).collect(Collectors.toList()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user