Custom olympiad period config.
This commit is contained in:
@ -536,6 +536,9 @@ public final class Config
|
||||
public static List<Integer> LIST_OLY_RESTRICTED_ITEMS;
|
||||
public static int ALT_OLY_ENCHANT_LIMIT;
|
||||
public static int ALT_OLY_WAIT_TIME;
|
||||
public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
|
||||
public static String ALT_OLY_PERIOD;
|
||||
public static int ALT_OLY_PERIOD_MULTIPLIER;
|
||||
public static int ALT_MANOR_REFRESH_TIME;
|
||||
public static int ALT_MANOR_REFRESH_MIN;
|
||||
public static int ALT_MANOR_APPROVE_TIME;
|
||||
@ -2274,6 +2277,9 @@ public final class Config
|
||||
}
|
||||
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
|
||||
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
|
||||
ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
|
||||
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
|
||||
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
|
||||
|
||||
final File hexIdFile = new File(HEXID_FILE);
|
||||
if (hexIdFile.exists())
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user