Added "_raw" placeholder variants for further processing (#1851)

These placeholders can be more easily used to be processed in plugins that process placeholders (like scoreboards)
This commit is contained in:
Yannick Schinko 2021-04-20 07:26:15 +02:00 committed by GitHub
parent b1ebf55ce1
commit 330dc17035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 0 deletions

View File

@ -164,52 +164,94 @@ public class PlayerPlaceHolders implements Placeholders {
player -> time.apply(SessionsMutator.forContainer(player)
.toActivePlaytime())
);
placeholders.register("player_time_active_raw",
player -> SessionsMutator.forContainer(player)
.toActivePlaytime()
);
placeholders.register("player_time_afk",
player -> time.apply(SessionsMutator.forContainer(player)
.toAfkTime())
);
placeholders.register("player_time_afk_raw",
player -> SessionsMutator.forContainer(player)
.toAfkTime()
);
placeholders.register("player_time_total",
player -> time.apply(SessionsMutator.forContainer(player)
.toPlaytime())
);
placeholders.register("player_time_total_raw",
player -> SessionsMutator.forContainer(player)
.toPlaytime()
);
placeholders.register("player_time_day",
player -> time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(dayAgo(), now())
.toPlaytime())
);
placeholders.register("player_time_day_raw",
player -> SessionsMutator.forContainer(player)
.filterSessionsBetween(dayAgo(), now())
.toPlaytime()
);
placeholders.register("player_time_week",
player -> time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(weekAgo(), now())
.toPlaytime())
);
placeholders.register("player_time_week_raw",
player -> SessionsMutator.forContainer(player)
.filterSessionsBetween(weekAgo(), now())
.toPlaytime()
);
placeholders.register("player_time_month",
player -> time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(monthAgo(), now())
.toPlaytime())
);
placeholders.register("player_time_month_raw",
player -> time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(monthAgo(), now())
.toPlaytime())
);
placeholders.register("player_server_time_active",
player -> time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toActivePlaytime())
);
placeholders.register("player_server_time_active_raw",
player -> time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toActivePlaytime())
);
placeholders.register("player_server_time_afk",
player -> time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toAfkTime())
);
placeholders.register("player_server_time_afk_raw",
player -> SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toAfkTime()
);
placeholders.register("player_server_time_total",
player -> time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime())
);
placeholders.register("player_server_time_total_raw",
player -> SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime()
);
placeholders.register("player_server_time_day",
player -> time.apply(SessionsMutator.forContainer(player)
@ -217,6 +259,12 @@ public class PlayerPlaceHolders implements Placeholders {
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime())
);
placeholders.register("player_server_time_day_raw",
player -> SessionsMutator.forContainer(player)
.filterSessionsBetween(dayAgo(), now())
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime()
);
placeholders.register("player_server_time_week",
player -> time.apply(SessionsMutator.forContainer(player)
@ -224,6 +272,12 @@ public class PlayerPlaceHolders implements Placeholders {
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime())
);
placeholders.register("player_server_time_week_raw",
player -> SessionsMutator.forContainer(player)
.filterSessionsBetween(weekAgo(), now())
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime()
);
placeholders.register("player_server_time_month",
player -> time.apply(SessionsMutator.forContainer(player)
@ -231,5 +285,11 @@ public class PlayerPlaceHolders implements Placeholders {
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime())
);
placeholders.register("player_server_time_month_raw",
player -> SessionsMutator.forContainer(player)
.filterSessionsBetween(monthAgo(), now())
.filterPlayedOnServer(serverInfo.getServerUUID())
.toPlaytime()
);
}
}

View File

@ -84,30 +84,54 @@ public class SessionPlaceHolders implements Placeholders {
placeholders.registerStatic("sessions_play_time_total",
() -> timeAmount.apply(database.query(SessionQueries.playtime(0L, now(), serverUUID))));
placeholders.registerStatic("sessions_play_time_total_raw",
() -> database.query(SessionQueries.playtime(0L, now(), serverUUID)));
placeholders.registerStatic("sessions_play_time_day",
() -> timeAmount.apply(database.query(SessionQueries.playtime(dayAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_play_time_day_raw",
() -> database.query(SessionQueries.playtime(dayAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_play_time_week",
() -> timeAmount.apply(database.query(SessionQueries.playtime(weekAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_play_time_week_raw",
() -> database.query(SessionQueries.playtime(weekAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_play_time_month",
() -> timeAmount.apply(database.query(SessionQueries.playtime(monthAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_play_time_month_raw",
() -> database.query(SessionQueries.playtime(monthAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_active_time_total",
() -> timeAmount.apply(database.query(SessionQueries.activePlaytime(0L, now(), serverUUID))));
placeholders.registerStatic("sessions_active_time_total_raw",
() -> database.query(SessionQueries.activePlaytime(0L, now(), serverUUID)));
placeholders.registerStatic("sessions_active_time_day",
() -> timeAmount.apply(database.query(SessionQueries.activePlaytime(dayAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_active_time_day_raw",
() -> database.query(SessionQueries.activePlaytime(dayAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_active_time_week",
() -> timeAmount.apply(database.query(SessionQueries.activePlaytime(weekAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_active_time_week_raw",
() -> database.query(SessionQueries.activePlaytime(weekAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_active_time_month",
() -> timeAmount.apply(database.query(SessionQueries.activePlaytime(monthAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_active_time_month_raw",
() -> database.query(SessionQueries.activePlaytime(monthAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_afk_time_total",
() -> timeAmount.apply(database.query(SessionQueries.afkTime(0L, now(), serverUUID))));
placeholders.registerStatic("sessions_afk_time_total_raw",
() -> database.query(SessionQueries.afkTime(0L, now(), serverUUID)));
placeholders.registerStatic("sessions_afk_time_day",
() -> timeAmount.apply(database.query(SessionQueries.afkTime(dayAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_afk_time_day_raw",
() -> database.query(SessionQueries.afkTime(dayAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_afk_time_week",
() -> timeAmount.apply(database.query(SessionQueries.afkTime(weekAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_afk_time_week_raw",
() -> database.query(SessionQueries.afkTime(weekAgo(), now(), serverUUID)));
placeholders.registerStatic("sessions_afk_time_month",
() -> timeAmount.apply(database.query(SessionQueries.afkTime(monthAgo(), now(), serverUUID))));
placeholders.registerStatic("sessions_afk_time_month_raw",
() -> database.query(SessionQueries.afkTime(monthAgo(), now(), serverUUID)));
Supplier<Serializable> uniquePlayers = () -> database.query(PlayerCountQueries.newPlayerCount(0L, now(), serverUUID));
placeholders.registerStatic("sessions_unique_players_total", uniquePlayers);