Search in sources :

Example 1 with ExtendedLogEntry

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();
}
Also used : Log(me.lucko.luckperms.common.actionlog.Log) Document(org.bson.Document) UUID(java.util.UUID) ExtendedLogEntry(me.lucko.luckperms.common.actionlog.ExtendedLogEntry)

Example 2 with ExtendedLogEntry

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();
}
Also used : Log(me.lucko.luckperms.common.actionlog.Log) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ExtendedLogEntry(me.lucko.luckperms.common.actionlog.ExtendedLogEntry)

Aggregations

ExtendedLogEntry (me.lucko.luckperms.common.actionlog.ExtendedLogEntry)2 Log (me.lucko.luckperms.common.actionlog.Log)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 UUID (java.util.UUID)1 Document (org.bson.Document)1