mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-04 07:28:26 +01:00
Implemented session playtime to Query API.
CommonQueries#fetchCurrentSessionPlaytime, requires Capability#QUERY_API_ACTIVE_SESSION_PLAYTIME API version increased to v5.1-R0.3 Affects issues: - #1384
This commit is contained in:
parent
4cca2251a8
commit
dff96b1728
@ -7,7 +7,7 @@ dependencies {
|
|||||||
compileOnly "com.google.code.gson:gson:$gsonVersion"
|
compileOnly "com.google.code.gson:gson:$gsonVersion"
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.apiVersion = '5.1-R0.2'
|
ext.apiVersion = '5.1-R0.3'
|
||||||
|
|
||||||
bintray {
|
bintray {
|
||||||
user = System.getenv('BINTRAY_USER')
|
user = System.getenv('BINTRAY_USER')
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.djrapitops.plan.capability;
|
package com.djrapitops.plan.capability;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of different capabilities current version provides.
|
* List of different capabilities current version provides.
|
||||||
@ -59,6 +60,10 @@ enum Capability {
|
|||||||
* {@link com.djrapitops.plan.query.QueryService} and {@link com.djrapitops.plan.query.CommonQueries}
|
* {@link com.djrapitops.plan.query.QueryService} and {@link com.djrapitops.plan.query.CommonQueries}
|
||||||
*/
|
*/
|
||||||
QUERY_API,
|
QUERY_API,
|
||||||
|
/**
|
||||||
|
* {@link com.djrapitops.plan.query.CommonQueries#fetchCurrentSessionPlaytime(UUID)}
|
||||||
|
*/
|
||||||
|
QUERY_API_ACTIVE_SESSION_PLAYTIME,
|
||||||
/**
|
/**
|
||||||
* {@link com.djrapitops.plan.settings.SettingsService}
|
* {@link com.djrapitops.plan.settings.SettingsService}
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +43,16 @@ public interface CommonQueries {
|
|||||||
*/
|
*/
|
||||||
long fetchPlaytime(UUID playerUUID, UUID serverUUID, long after, long before);
|
long fetchPlaytime(UUID playerUUID, UUID serverUUID, long after, long before);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get playtime of current online session.
|
||||||
|
* <p>
|
||||||
|
* Requires Capability QUERY_API_ACTIVE_SESSION_PLAYTIME
|
||||||
|
*
|
||||||
|
* @param playerUUID UUID of the player.
|
||||||
|
* @return Milliseconds the player has played during current online session. 0 if player is offline.
|
||||||
|
*/
|
||||||
|
long fetchCurrentSessionPlaytime(UUID playerUUID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch last seen Epoch ms for a player on a server.
|
* Fetch last seen Epoch ms for a player on a server.
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.query;
|
package com.djrapitops.plan.query;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||||
|
import com.djrapitops.plan.gathering.domain.Session;
|
||||||
import com.djrapitops.plan.storage.database.DBType;
|
import com.djrapitops.plan.storage.database.DBType;
|
||||||
import com.djrapitops.plan.storage.database.Database;
|
import com.djrapitops.plan.storage.database.Database;
|
||||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||||
@ -42,6 +44,11 @@ public class CommonQueriesImplementation implements CommonQueries {
|
|||||||
return db.query(SessionQueries.playtimeOfPlayer(after, before, playerUUID)).getOrDefault(serverUUID, 0L);
|
return db.query(SessionQueries.playtimeOfPlayer(after, before, playerUUID)).getOrDefault(serverUUID, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long fetchCurrentSessionPlaytime(UUID playerUUID) {
|
||||||
|
return SessionCache.getCachedSession(playerUUID).map(Session::getLength).orElse(0L);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long fetchLastSeen(UUID playerUUID, UUID serverUUID) {
|
public long fetchLastSeen(UUID playerUUID, UUID serverUUID) {
|
||||||
return db.query(SessionQueries.lastSeen(playerUUID, serverUUID));
|
return db.query(SessionQueries.lastSeen(playerUUID, serverUUID));
|
||||||
|
Loading…
Reference in New Issue
Block a user