use of me.lucko.luckperms.common.actionlog.ExtendedLogEntry in project LuckPerms by lucko.
the class MongoDao method getLog.
@Override
public Log getLog() {
Log.Builder log = Log.builder();
MongoCollection<Document> c = this.database.getCollection(this.prefix + "action");
try (MongoCursor<Document> cursor = c.find().iterator()) {
while (cursor.hasNext()) {
Document d = cursor.next();
UUID actedUuid = null;
if (d.containsKey("acted")) {
actedUuid = d.get("acted", UUID.class);
}
ExtendedLogEntry e = ExtendedLogEntry.build().timestamp(d.getLong("timestamp")).actor(d.get("actor", UUID.class)).actorName(d.getString("actorName")).type(LogEntry.Type.valueOf(d.getString("type").toCharArray()[0])).acted(actedUuid).actedName(d.getString("actedName")).action(d.getString("action")).build();
log.add(e);
}
}
return log.build();
}
use of me.lucko.luckperms.common.actionlog.ExtendedLogEntry in project LuckPerms by lucko.
the class SqlDao method getLog.
@Override
public Log getLog() throws SQLException {
final Log.Builder log = Log.builder();
try (Connection c = this.provider.getConnection()) {
try (PreparedStatement ps = c.prepareStatement(this.prefix.apply(ACTION_SELECT_ALL))) {
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
final String actedUuid = rs.getString("acted_uuid");
ExtendedLogEntry e = ExtendedLogEntry.build().timestamp(rs.getLong("time")).actor(UUID.fromString(rs.getString("actor_uuid"))).actorName(rs.getString("actor_name")).type(LogEntry.Type.valueOf(rs.getString("type").toCharArray()[0])).acted(actedUuid.equals("null") ? null : UUID.fromString(actedUuid)).actedName(rs.getString("acted_name")).action(rs.getString("action")).build();
log.add(e);
}
}
}
}
return log.build();
}
Aggregations