mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
parent
be0fab2f6b
commit
9d26591dfc
@ -45,6 +45,7 @@ import java.util.UUID;
|
||||
public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private final Formatter<Double> decimals;
|
||||
private Formatter<Long> year;
|
||||
private Formatter<Long> time;
|
||||
|
||||
@ -57,10 +58,11 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
this.dbSystem = dbSystem;
|
||||
time = formatters.timeAmount();
|
||||
year = formatters.yearLong();
|
||||
decimals = formatters.decimals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
public String onPlaceholderRequest(Player p, String params) {
|
||||
Serializable got = get(params, p.getUniqueId());
|
||||
return got != null ? got.toString() : null;
|
||||
}
|
||||
@ -93,12 +95,17 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
return PlayerVersusMutator.forContainer(player).toKillDeathRatio();
|
||||
|
||||
case "player_ping_average_day":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(dayAgo(), now())).average();
|
||||
return decimals.apply(PingMutator.forContainer(player)
|
||||
.filterBy(Predicates.within(dayAgo(), now()))
|
||||
.average()) + " ms";
|
||||
case "player_ping_average_week":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(weekAgo(), now())).average();
|
||||
|
||||
return decimals.apply(PingMutator.forContainer(player)
|
||||
.filterBy(Predicates.within(weekAgo(), now()))
|
||||
.average()) + " ms";
|
||||
case "player_ping_average_month":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(monthAgo(), now())).average();
|
||||
return decimals.apply(PingMutator.forContainer(player)
|
||||
.filterBy(Predicates.within(monthAgo(), now()))
|
||||
.average()) + " ms";
|
||||
|
||||
case "player_lastseen":
|
||||
return year.apply(player.getValue(PlayerKeys.LAST_SEEN).orElse((long) 0));
|
||||
|
@ -50,7 +50,7 @@ public class ServerPlaceHolders extends AbstractPlanPlaceHolder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
public String onPlaceholderRequest(Player p, String params) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
UUID serverUUID = serverUUID();
|
||||
Serializable got = get(params, database, serverUUID);
|
||||
|
@ -42,6 +42,7 @@ import java.util.UUID;
|
||||
public class SessionPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private final Formatter<Double> decimals;
|
||||
private Formatter<Long> timeAmount;
|
||||
private int tzOffsetMs;
|
||||
private Formatter<DateHolder> year;
|
||||
@ -58,10 +59,11 @@ public class SessionPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
tzOffsetMs = config.getTimeZone().getOffset(System.currentTimeMillis());
|
||||
timeAmount = formatters.timeAmount();
|
||||
year = formatters.year();
|
||||
decimals = formatters.decimals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p, String params) throws Exception {
|
||||
public String onPlaceholderRequest(Player p, String params) {
|
||||
Serializable got = get(params);
|
||||
return got != null ? got.toString() : null;
|
||||
}
|
||||
@ -163,13 +165,13 @@ public class SessionPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
return database.query(PlayerCountQueries.newPlayerCount(monthAgo(), now(), serverUUID));
|
||||
|
||||
case "ping_total":
|
||||
return database.query(PingQueries.averagePing(0L, now(), serverUUID));
|
||||
return decimals.apply(database.query(PingQueries.averagePing(0L, now(), serverUUID))) + " ms";
|
||||
case "ping_day":
|
||||
return database.query(PingQueries.averagePing(dayAgo(), now(), serverUUID));
|
||||
return decimals.apply(database.query(PingQueries.averagePing(dayAgo(), now(), serverUUID))) + " ms";
|
||||
case "ping_week":
|
||||
return database.query(PingQueries.averagePing(weekAgo(), now(), serverUUID));
|
||||
return decimals.apply(database.query(PingQueries.averagePing(weekAgo(), now(), serverUUID))) + " ms";
|
||||
case "ping_month":
|
||||
return database.query(PingQueries.averagePing(monthAgo(), now(), serverUUID));
|
||||
return decimals.apply(database.query(PingQueries.averagePing(monthAgo(), now(), serverUUID))) + " ms";
|
||||
|
||||
case "sessions_peak_count":
|
||||
return database.query(TPSQueries.fetchAllTimePeakPlayerCount(serverUUID)).map(DateObj::getValue).orElse(0);
|
||||
|
Loading…
Reference in New Issue
Block a user