mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-03 15:08:12 +01:00
Refactor PlayerPlaceHolders to reduce method length
This commit is contained in:
parent
1ec6fc913a
commit
fac196ed0d
@ -247,99 +247,13 @@ public class PlayerPlaceHolders implements Placeholders {
|
||||
}
|
||||
|
||||
private void registerPlaytimePlaceholders(PlanPlaceholders placeholders, Formatter<Long> time) {
|
||||
placeholders.register("player_time_active",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_day",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(dayAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_day_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(dayAgo(), now())
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_week",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(weekAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_week_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(weekAgo(), now())
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_month",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_month_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.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 -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toPlaytime()
|
||||
);
|
||||
registerActivePlaytimePlaceholders(placeholders, time);
|
||||
registerAfkTimePlaceholders(placeholders, time);
|
||||
registerPlayerPlaytimePlaceholders(placeholders, time);
|
||||
registerServerSpecificPlaytimePlaceholders(placeholders, time);
|
||||
}
|
||||
|
||||
private void registerServerSpecificPlaytimePlaceholders(PlanPlaceholders placeholders, Formatter<Long> time) {
|
||||
placeholders.register("player_server_time_active",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterPlayedOnServer(serverInfo.getServerUUID())
|
||||
@ -413,6 +327,105 @@ public class PlayerPlaceHolders implements Placeholders {
|
||||
);
|
||||
}
|
||||
|
||||
private void registerPlayerPlaytimePlaceholders(PlanPlaceholders placeholders, Formatter<Long> time) {
|
||||
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 -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toPlaytime()
|
||||
);
|
||||
}
|
||||
|
||||
private void registerAfkTimePlaceholders(PlanPlaceholders placeholders, Formatter<Long> time) {
|
||||
placeholders.register("player_time_afk",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.toAfkTime())
|
||||
);
|
||||
placeholders.register("player_time_afk_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.toAfkTime()
|
||||
);
|
||||
}
|
||||
|
||||
private void registerActivePlaytimePlaceholders(PlanPlaceholders placeholders, Formatter<Long> time) {
|
||||
placeholders.register("player_time_active",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_day",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(dayAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_day_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(dayAgo(), now())
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_week",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(weekAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_week_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(weekAgo(), now())
|
||||
.toActivePlaytime()
|
||||
);
|
||||
|
||||
placeholders.register("player_time_active_month",
|
||||
player -> time.apply(SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toActivePlaytime())
|
||||
);
|
||||
placeholders.register("player_time_active_month_raw",
|
||||
player -> SessionsMutator.forContainer(player)
|
||||
.filterSessionsBetween(monthAgo(), now())
|
||||
.toActivePlaytime()
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Optional<Long> getActiveSessionLength(PlayerContainer player) {
|
||||
SessionCache.refreshActiveSessionsState();
|
||||
|
Loading…
Reference in New Issue
Block a user