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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -73,16 +89,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -53,9 +56,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -64,7 +66,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -73,6 +89,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -80,11 +100,12 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -75,6 +91,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -83,11 +103,12 @@ public class DailyTaskManager
|
|||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
resetThroneOfHeroes();
|
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
resetTrainingCamp();
|
resetTrainingCamp();
|
||||||
|
resetThroneOfHeroes();
|
||||||
resetTimedHuntingZones();
|
resetTimedHuntingZones();
|
||||||
resetHomunculusResetPoints();
|
resetHomunculusResetPoints();
|
||||||
resetAttendanceRewards();
|
resetAttendanceRewards();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
resetThroneOfHeroes();
|
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
resetTrainingCamp();
|
resetTrainingCamp();
|
||||||
|
resetThroneOfHeroes();
|
||||||
resetTimedHuntingZones();
|
resetTimedHuntingZones();
|
||||||
resetHomunculusResetPoints();
|
resetHomunculusResetPoints();
|
||||||
resetAttendanceRewards();
|
resetAttendanceRewards();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,6 +93,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -84,17 +104,18 @@ public class DailyTaskManager
|
|||||||
resetClanContribution();
|
resetClanContribution();
|
||||||
resetDailyMissionRewards();
|
resetDailyMissionRewards();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
resetThroneOfHeroes();
|
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
resetRecommends();
|
resetRecommends();
|
||||||
resetTrainingCamp();
|
resetTrainingCamp();
|
||||||
|
resetThroneOfHeroes();
|
||||||
resetTimedHuntingZones();
|
resetTimedHuntingZones();
|
||||||
resetHomunculusResetPoints();
|
resetHomunculusResetPoints();
|
||||||
resetAttendanceRewards();
|
resetAttendanceRewards();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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_MARKS = "COC_TOP_MARKS";
|
||||||
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
|
||||||
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -57,9 +60,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -68,7 +70,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -77,16 +93,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -79,17 +95,22 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -55,9 +58,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -66,7 +68,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -75,16 +91,21 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -79,17 +95,22 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
resetVitalityWeekly();
|
resetVitalityWeekly();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetDailySkills();
|
resetDailySkills();
|
||||||
resetWorldChatPoints();
|
resetWorldChatPoints();
|
||||||
|
@ -41,6 +41,9 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
private static final String DELETE_QUERY = "DELETE FROM global_variables";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
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()
|
protected GlobalVariablesManager()
|
||||||
{
|
{
|
||||||
restoreMe();
|
restoreMe();
|
||||||
|
@ -18,7 +18,9 @@ package org.l2jmobius.gameserver.instancemanager;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -79,6 +95,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -86,11 +106,12 @@ public class DailyTaskManager
|
|||||||
resetMonsterArenaWeekly();
|
resetMonsterArenaWeekly();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetClanContributionList();
|
resetClanContributionList();
|
||||||
resetClanDonationPoints();
|
resetClanDonationPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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 MONSTER_ARENA_VARIABLE = "MA_C";
|
||||||
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
|
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.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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 Logger LOGGER = Logger.getLogger(DailyTaskManager.class.getName());
|
||||||
|
|
||||||
|
private static final SimpleDateFormat SDF = new SimpleDateFormat("dd/MM HH:mm");
|
||||||
private static final int[] RESET_SKILLS =
|
private static final int[] RESET_SKILLS =
|
||||||
{
|
{
|
||||||
2510, // Wondrous Cubic
|
2510, // Wondrous Cubic
|
||||||
@ -59,9 +62,8 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
protected DailyTaskManager()
|
protected DailyTaskManager()
|
||||||
{
|
{
|
||||||
final long currentTime = Chronos.currentTimeMillis();
|
|
||||||
|
|
||||||
// Schedule reset everyday at 6:30.
|
// Schedule reset everyday at 6:30.
|
||||||
|
final long currentTime = Chronos.currentTimeMillis();
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
calendar.set(Calendar.HOUR_OF_DAY, 6);
|
||||||
calendar.set(Calendar.MINUTE, 30);
|
calendar.set(Calendar.MINUTE, 30);
|
||||||
@ -70,7 +72,21 @@ public class DailyTaskManager
|
|||||||
{
|
{
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
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
|
ThreadPool.scheduleAtFixedRate(this::onReset, startDelay, 86400000); // 86400000 = 1 day
|
||||||
|
|
||||||
// Global save task.
|
// Global save task.
|
||||||
@ -79,6 +95,10 @@ public class DailyTaskManager
|
|||||||
|
|
||||||
private void onReset()
|
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)
|
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY)
|
||||||
{
|
{
|
||||||
clanLeaderApply();
|
clanLeaderApply();
|
||||||
@ -86,11 +106,12 @@ public class DailyTaskManager
|
|||||||
resetMonsterArenaWeekly();
|
resetMonsterArenaWeekly();
|
||||||
resetTimedHuntingZonesWeekly();
|
resetTimedHuntingZonesWeekly();
|
||||||
}
|
}
|
||||||
else
|
else // All days, except Wednesday.
|
||||||
{
|
{
|
||||||
resetVitalityDaily();
|
resetVitalityDaily();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Daily tasks.
|
||||||
resetClanBonus();
|
resetClanBonus();
|
||||||
resetClanContributionList();
|
resetClanContributionList();
|
||||||
resetClanDonationPoints();
|
resetClanDonationPoints();
|
||||||
|
@ -42,6 +42,7 @@ public class GlobalVariablesManager extends AbstractVariables
|
|||||||
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO global_variables (var, value) VALUES (?, ?)";
|
||||||
|
|
||||||
// Public variable names
|
// 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 MONSTER_ARENA_VARIABLE = "MA_C";
|
||||||
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
|
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user