mirror of https://github.com/hykilpikonna/AquaDX
[chuni] Use dynamic reboot time instead of fixed one
parent
5d32d269d1
commit
46fc8921c0
|
@ -4,14 +4,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import icu.samnyan.aqua.sega.chunithm.handler.BaseHandler;
|
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.GetGameSettingResp;
|
||||||
import icu.samnyan.aqua.sega.chunithm.model.response.data.GameSetting;
|
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 icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,29 +24,29 @@ public class GetGameSettingHandler implements BaseHandler {
|
||||||
|
|
||||||
private final StringMapper mapper;
|
private final StringMapper mapper;
|
||||||
|
|
||||||
private final PropertyEntryRepository propertyEntryRepository;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GetGameSettingHandler(StringMapper mapper, PropertyEntryRepository propertyEntryRepository) {
|
public GetGameSettingHandler(StringMapper mapper) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
this.propertyEntryRepository = propertyEntryRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
|
|
||||||
PropertyEntry start = propertyEntryRepository.findByPropertyKey("reboot_start_time")
|
// Fixed reboot time triggers chunithm maintenance lockout, so let's try minime method which sets it dynamically
|
||||||
.orElseGet(() -> new PropertyEntry("reboot_start_time", "2020-01-01 23:59:00.0"));
|
// Special thanks to skogaby
|
||||||
PropertyEntry end = propertyEntryRepository.findByPropertyKey("reboot_end_time")
|
|
||||||
.orElseGet(() -> new PropertyEntry("reboot_end_time", "2020-01-01 23:59:00.0"));
|
// 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(
|
GameSetting gameSetting = new GameSetting(
|
||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
10,
|
10,
|
||||||
start.getPropertyValue(),
|
rebootStartTime.format(formatter),
|
||||||
end.getPropertyValue(),
|
rebootEndTime.format(formatter),
|
||||||
false,
|
false,
|
||||||
300,
|
300,
|
||||||
300,
|
300,
|
||||||
|
|
Loading…
Reference in New Issue