Custom olympiad period config.

This commit is contained in:
MobiusDev
2018-03-24 02:49:13 +00:00
parent 84bd9378fa
commit 653c7e8276
22 changed files with 730 additions and 84 deletions

View File

@@ -546,20 +546,80 @@ public class Olympiad extends ListenersContainer
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.ROUND_S1_OF_THE_OLYMPIAD_GAMES_HAS_STARTED);
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
final Calendar currentTime = Calendar.getInstance();
currentTime.add(Calendar.MONTH, 1);
currentTime.set(Calendar.DAY_OF_MONTH, 1);
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
currentTime.set(Calendar.SECOND, 0);
_olympiadEnd = currentTime.getTimeInMillis();
if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
{
final Calendar currentTime = Calendar.getInstance();
currentTime.add(Calendar.MONTH, 1);
currentTime.set(Calendar.DAY_OF_MONTH, 1);
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
currentTime.set(Calendar.SECOND, 0);
_olympiadEnd = currentTime.getTimeInMillis();
final Calendar nextChange = Calendar.getInstance();
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
}
else
{
Calendar currentTime = Calendar.getInstance();
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
currentTime.set(Calendar.SECOND, 0);
Calendar nextChange = Calendar.getInstance();
switch (Config.ALT_OLY_PERIOD)
{
case "DAY":
{
currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
}
else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
{
_nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
}
else
{
LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
}
break;
}
case "WEEK":
{
currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
{
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
}
else
{
_nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
}
break;
}
case "MONTH":
{
currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
break;
}
}
_olympiadEnd = currentTime.getTimeInMillis();
}
final Calendar nextChange = Calendar.getInstance();
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
scheduleWeeklyChange();
}