DailyTaskManager reset when passed schedule.
Thanks to nasseka.
This commit is contained in:
parent
e4ec9cb6a5
commit
3a32239660
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -45,6 +47,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -73,16 +89,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -47,6 +49,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -47,6 +49,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -47,6 +49,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -45,6 +47,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -45,6 +47,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -45,6 +47,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -47,6 +49,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -75,6 +91,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -83,11 +103,12 @@ public class DailyTaskManager
|
||||
resetDailyMissionRewards();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
resetThroneOfHeroes();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
resetTrainingCamp();
|
||||
resetThroneOfHeroes();
|
||||
resetTimedHuntingZones();
|
||||
resetHomunculusResetPoints();
|
||||
resetAttendanceRewards();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
resetThroneOfHeroes();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
resetTrainingCamp();
|
||||
resetThroneOfHeroes();
|
||||
resetTimedHuntingZones();
|
||||
resetHomunculusResetPoints();
|
||||
resetAttendanceRewards();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
||||
resetClanContribution();
|
||||
resetDailyMissionRewards();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
resetThroneOfHeroes();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
resetRecommends();
|
||||
resetTrainingCamp();
|
||||
resetThroneOfHeroes();
|
||||
resetTimedHuntingZones();
|
||||
resetHomunculusResetPoints();
|
||||
resetAttendanceRewards();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String COC_TOP_MARKS = "COC_TOP_MARKS";
|
||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -49,6 +51,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -51,6 +53,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -79,17 +95,22 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -47,6 +49,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -51,6 +53,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -79,17 +95,22 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
resetVitalityWeekly();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetDailySkills();
|
||||
resetWorldChatPoints();
|
||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
|
||||
protected GlobalVariablesManager()
|
||||
{
|
||||
restoreMe();
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -51,6 +53,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -79,6 +95,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -86,11 +106,12 @@ public class DailyTaskManager
|
||||
resetMonsterArenaWeekly();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetClanContributionList();
|
||||
resetClanDonationPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String MONSTER_ARENA_VARIABLE = "MA_C";
|
||||
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
|
||||
|
||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -51,6 +53,7 @@ public class DailyTaskManager
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||
private static final int[] RESET_SKILLS =
|
||||
{
|
||||
2510, // Wondrous Cubic
|
||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
||||
|
||||
protected DailyTaskManager()
|
||||
{
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
|
||||
// Schedule reset everyday at 6:30.
|
||||
final long currentTime = Chronos.currentTimeMillis();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||
calendar.set(Calendar.MINUTE, 30);
|
||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
||||
{
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
final long startDelay = Math.max(0, calendar.getTimeInMillis() - currentTime);
|
||||
|
||||
// Check if 24 hours have passed since the last daily reset.
|
||||
final long calendarTime = calendar.getTimeInMillis();
|
||||
if (GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.DAILY_TASK_RESET, 0) < calendarTime)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Next schedule at " + SDF.format(new Date(calendarTime)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Daily task will run now.");
|
||||
onReset();
|
||||
}
|
||||
|
||||
// Daily reset task.
|
||||
final long startDelay = Math.max(0, calendarTime - currentTime);
|
||||
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||
|
||||
// Global save task.
|
||||
@ -79,6 +95,10 @@ public class DailyTaskManager
|
||||
|
||||
private void onReset()
|
||||
{
|
||||
// Store last reset time.
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.DAILY_TASK_RESET, Chronos.currentTimeMillis());
|
||||
|
||||
// Wednesday weekly tasks.
|
||||
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||
{
|
||||
clanLeaderApply();
|
||||
@ -86,11 +106,12 @@ public class DailyTaskManager
|
||||
resetMonsterArenaWeekly();
|
||||
resetTimedHuntingZonesWeekly();
|
||||
}
|
||||
else
|
||||
else // All days, except Wednesday.
|
||||
{
|
||||
resetVitalityDaily();
|
||||
}
|
||||
|
||||
// Daily tasks.
|
||||
resetClanBonus();
|
||||
resetClanContributionList();
|
||||
resetClanDonationPoints();
|
||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||
|
||||
// Public variable names
|
||||
public static final String DAILY_TASK_RESET = "DAILY_TASK_RESET";
|
||||
public static final String MONSTER_ARENA_VARIABLE = "MA_C";
|
||||
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user