Player time placeholder changes

- Fixed time amount formatting
- Added player_server_ placeholders for all _time placeholders
This commit is contained in:
Rsl1122 2019-10-25 13:25:27 +03:00
parent bf9043ab20
commit 0a2bb0d203

View File

@ -42,6 +42,7 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
private final DBSystem dbSystem; private final DBSystem dbSystem;
private Formatter<Long> year; private Formatter<Long> year;
private Formatter<Long> time;
public PlayerPlaceHolder( public PlayerPlaceHolder(
DBSystem dbSystem, DBSystem dbSystem,
@ -50,6 +51,7 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
) { ) {
super(serverInfo); super(serverInfo);
this.dbSystem = dbSystem; this.dbSystem = dbSystem;
time = formatters.timeAmount();
year = formatters.yearLong(); year = formatters.yearLong();
} }
@ -100,31 +102,61 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
return year.apply(player.getValue(PlayerKeys.REGISTERED).orElse((long) 0)); return year.apply(player.getValue(PlayerKeys.REGISTERED).orElse((long) 0));
case "player_time_active": case "player_time_active":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.toActivePlaytime()); .toActivePlaytime());
case "player_time_afk": case "player_time_afk":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.toAfkTime()); .toAfkTime());
case "player_time_total": case "player_time_total":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.toPlaytime()); .toPlaytime());
case "player_time_day": case "player_time_day":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(dayAgo(), now()) .filterSessionsBetween(dayAgo(), now())
.toPlaytime()); .toPlaytime());
case "player_time_week": case "player_time_week":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(weekAgo(), now()) .filterSessionsBetween(weekAgo(), now())
.toPlaytime()); .toPlaytime());
case "player_time_month": case "player_time_month":
return year.apply(SessionsMutator.forContainer(player) return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(monthAgo(), now()) .filterSessionsBetween(monthAgo(), now())
.toPlaytime()); .toPlaytime());
} case "player_server_time_active":
return time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverUUID())
.toActivePlaytime());
case "player_server_time_afk":
return time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverUUID())
.toAfkTime());
case "player_server_time_total":
return time.apply(SessionsMutator.forContainer(player)
.filterPlayedOnServer(serverUUID())
.toPlaytime());
case "player_server_time_day":
return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(dayAgo(), now())
.filterPlayedOnServer(serverUUID())
.toPlaytime());
case "player_server_time_week":
return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(weekAgo(), now())
.filterPlayedOnServer(serverUUID())
.toPlaytime());
case "player_server_time_month":
return time.apply(SessionsMutator.forContainer(player)
.filterSessionsBetween(monthAgo(), now())
.filterPlayedOnServer(serverUUID())
.toPlaytime());
default:
return null; return null;
} }
}
// Checkstyle.ON: CyclomaticComplexity // Checkstyle.ON: CyclomaticComplexity