From 46fc8921c08bffdbc6e9f4c598e50130f86d201c Mon Sep 17 00:00:00 2001 From: Dom Eori <4j6dq2zi8@relay.firefox.com> Date: Tue, 19 Oct 2021 21:12:31 +0900 Subject: [PATCH] [chuni] Use dynamic reboot time instead of fixed one --- .../handler/impl/GetGameSettingHandler.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/icu/samnyan/aqua/sega/chunithm/handler/impl/GetGameSettingHandler.java b/src/main/java/icu/samnyan/aqua/sega/chunithm/handler/impl/GetGameSettingHandler.java index 0f59ee27..d838fd86 100644 --- a/src/main/java/icu/samnyan/aqua/sega/chunithm/handler/impl/GetGameSettingHandler.java +++ b/src/main/java/icu/samnyan/aqua/sega/chunithm/handler/impl/GetGameSettingHandler.java @@ -4,14 +4,14 @@ import com.fasterxml.jackson.core.JsonProcessingException; import icu.samnyan.aqua.sega.chunithm.handler.BaseHandler; import icu.samnyan.aqua.sega.chunithm.model.response.GetGameSettingResp; import icu.samnyan.aqua.sega.chunithm.model.response.data.GameSetting; -import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository; -import icu.samnyan.aqua.sega.general.model.PropertyEntry; import icu.samnyan.aqua.sega.util.jackson.StringMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Map; /** @@ -24,29 +24,29 @@ public class GetGameSettingHandler implements BaseHandler { private final StringMapper mapper; - private final PropertyEntryRepository propertyEntryRepository; - @Autowired - public GetGameSettingHandler(StringMapper mapper, PropertyEntryRepository propertyEntryRepository) { + public GetGameSettingHandler(StringMapper mapper) { this.mapper = mapper; - this.propertyEntryRepository = propertyEntryRepository; } @Override public String handle(Map request) throws JsonProcessingException { - PropertyEntry start = propertyEntryRepository.findByPropertyKey("reboot_start_time") - .orElseGet(() -> new PropertyEntry("reboot_start_time", "2020-01-01 23:59:00.0")); - PropertyEntry end = propertyEntryRepository.findByPropertyKey("reboot_end_time") - .orElseGet(() -> new PropertyEntry("reboot_end_time", "2020-01-01 23:59:00.0")); + // Fixed reboot time triggers chunithm maintenance lockout, so let's try minime method which sets it dynamically + // Special thanks to skogaby + + // Hardcode so that the reboot time always started 3 hours ago and ended 2 hours ago + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss"); + LocalDateTime rebootStartTime = LocalDateTime.now().minusHours(3); + LocalDateTime rebootEndTime = LocalDateTime.now().minusHours(2); GameSetting gameSetting = new GameSetting( 1, false, 10, - start.getPropertyValue(), - end.getPropertyValue(), + rebootStartTime.format(formatter), + rebootEndTime.format(formatter), false, 300, 300,