actual freya branch
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
|
||||
/**
|
||||
* @author Tempy
|
||||
*/
|
||||
public final class TaskCleanUp extends Task
|
||||
{
|
||||
public static final String NAME = "clean_up";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
System.runFinalization();
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
/**
|
||||
** @author Gnacik
|
||||
*/
|
||||
public class TaskDailyQuestClean extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskDailyQuestClean.class.getName());
|
||||
|
||||
private static final String NAME = "daily_quest_clean";
|
||||
|
||||
private static final String[] _daily_names =
|
||||
{
|
||||
"463_IMustBeaGenius",
|
||||
"464_Oath",
|
||||
"458_PerfectForm",
|
||||
"461_RumbleInTheBase"
|
||||
};
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
for (String name : _daily_names)
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE name=? AND var='<state>' AND value='Completed';");
|
||||
statement.setString(1, name);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Could not reset daily quests: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
_log.config("Daily quests cleared");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#initializate()
|
||||
*/
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.instancemanager.GlobalVariablesManager;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
/**
|
||||
* @author Gigiikun
|
||||
*/
|
||||
public class TaskGlobalVariablesSave extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskGlobalVariablesSave.class.getName());
|
||||
public static final String NAME = "global_varibales_save";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
GlobalVariablesManager.getInstance().saveVars();
|
||||
_log.info("GlobalVariablesManager: Data updated successfully.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#initializate()
|
||||
*/
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_FIXED_SHEDULED, "500000", "1800000", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import org.python.util.PythonInterpreter;
|
||||
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
|
||||
/**
|
||||
* @author Layane
|
||||
*/
|
||||
public class TaskJython extends Task
|
||||
{
|
||||
public static final String NAME = "jython";
|
||||
private final PythonInterpreter _python = new PythonInterpreter();
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
_python.cleanup();
|
||||
_python.exec("import sys");
|
||||
_python.execfile("data/scripts/cron/" + task.getParams()[2]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
/**
|
||||
* Updates all data of Olympiad nobles in db
|
||||
* @author godson
|
||||
*/
|
||||
public class TaskOlympiadSave extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskOlympiadSave.class.getName());
|
||||
public static final String NAME = "olympiad_save";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
if (Olympiad.getInstance().inCompPeriod())
|
||||
{
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
_log.info("Olympiad System: Data updated.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#initializate()
|
||||
*/
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_FIXED_SHEDULED, "900000", "1800000", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossPointsManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
public class TaskRaidPointsReset extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskRaidPointsReset.class.getName());
|
||||
public static final String NAME = "raid_points_reset";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY)
|
||||
{
|
||||
// reward clan reputation points
|
||||
Map<Integer, Integer> rankList = RaidBossPointsManager.getInstance().getRankList();
|
||||
for (L2Clan c : ClanTable.getInstance().getClans())
|
||||
{
|
||||
for (Map.Entry<Integer, Integer> entry : rankList.entrySet())
|
||||
{
|
||||
if ((entry.getValue() <= 100) && c.isMember(entry.getKey()))
|
||||
{
|
||||
int reputation = 0;
|
||||
switch (entry.getValue())
|
||||
{
|
||||
case 1:
|
||||
reputation = Config.RAID_RANKING_1ST;
|
||||
break;
|
||||
case 2:
|
||||
reputation = Config.RAID_RANKING_2ND;
|
||||
break;
|
||||
case 3:
|
||||
reputation = Config.RAID_RANKING_3RD;
|
||||
break;
|
||||
case 4:
|
||||
reputation = Config.RAID_RANKING_4TH;
|
||||
break;
|
||||
case 5:
|
||||
reputation = Config.RAID_RANKING_5TH;
|
||||
break;
|
||||
case 6:
|
||||
reputation = Config.RAID_RANKING_6TH;
|
||||
break;
|
||||
case 7:
|
||||
reputation = Config.RAID_RANKING_7TH;
|
||||
break;
|
||||
case 8:
|
||||
reputation = Config.RAID_RANKING_8TH;
|
||||
break;
|
||||
case 9:
|
||||
reputation = Config.RAID_RANKING_9TH;
|
||||
break;
|
||||
case 10:
|
||||
reputation = Config.RAID_RANKING_10TH;
|
||||
break;
|
||||
default:
|
||||
if (entry.getValue() <= 50)
|
||||
{
|
||||
reputation = Config.RAID_RANKING_UP_TO_50TH;
|
||||
}
|
||||
else
|
||||
{
|
||||
reputation = Config.RAID_RANKING_UP_TO_100TH;
|
||||
}
|
||||
break;
|
||||
}
|
||||
c.addReputationScore(reputation, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RaidBossPointsManager.getInstance().cleanUp();
|
||||
_log.info("Raid Points Reset Global Task: launched.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "00:10:00", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
/**
|
||||
* @author Layane
|
||||
*/
|
||||
public class TaskRecom extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskRecom.class.getName());
|
||||
private static final String NAME = "recommendations";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE character_reco_bonus SET rec_left=?, time_left=?, rec_have=0 WHERE rec_have <= 20");
|
||||
statement.setInt(1, 0); // Rec left = 0
|
||||
statement.setInt(2, 3600000); // Timer = 1 hour
|
||||
statement.execute();
|
||||
|
||||
statement = con.prepareStatement("UPDATE character_reco_bonus SET rec_left=?, time_left=?, rec_have=GREATEST(rec_have-20,0) WHERE rec_have > 20");
|
||||
statement.setInt(1, 0); // Rec left = 0
|
||||
statement.setInt(2, 3600000); // Timer = 1 hour
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Could not reset Recommendations System: " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
_log.config("Recommendations System reseted");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#initializate()
|
||||
*/
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import com.l2jserver.gameserver.Shutdown;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
|
||||
/**
|
||||
* @author Layane
|
||||
*/
|
||||
public final class TaskRestart extends Task
|
||||
{
|
||||
public static final String NAME = "restart";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Shutdown handler = new Shutdown(Integer.parseInt(task.getParams()[2]), true);
|
||||
handler.start();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
|
||||
/**
|
||||
* @author janiii
|
||||
*/
|
||||
public class TaskScript extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskScript.class.getName());
|
||||
public static final String NAME = "script";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "cron/" + task.getParams()[2]);
|
||||
if (file.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
_log.warning("Failed loading: " + task.getParams()[2]);
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("Failed loading: " + task.getParams()[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("File Not Found: " + task.getParams()[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.SevenSigns;
|
||||
import com.l2jserver.gameserver.SevenSignsFestival;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskTypes;
|
||||
|
||||
/**
|
||||
* Updates all data for the Seven Signs and Festival of Darkness engines, when time is elapsed.
|
||||
* @author Tempy
|
||||
*/
|
||||
public class TaskSevenSignsUpdate extends Task
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(TaskSevenSignsUpdate.class.getName());
|
||||
public static final String NAME = "seven_signs_update";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
try
|
||||
{
|
||||
SevenSigns.getInstance().saveSevenSignsStatus();
|
||||
|
||||
if (!SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
SevenSignsFestival.getInstance().saveFestivalData(false);
|
||||
}
|
||||
|
||||
_log.info("SevenSigns: Data updated successfully.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "SevenSigns: Failed to save Seven Signs configuration: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#initializate()
|
||||
*/
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_FIXED_SHEDULED, "1800000", "1800000", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.taskmanager.tasks;
|
||||
|
||||
import com.l2jserver.gameserver.Shutdown;
|
||||
import com.l2jserver.gameserver.taskmanager.Task;
|
||||
import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
|
||||
|
||||
/**
|
||||
* @author Layane
|
||||
*/
|
||||
public class TaskShutdown extends Task
|
||||
{
|
||||
public static final String NAME = "shutdown";
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
|
||||
*/
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Shutdown handler = new Shutdown(Integer.parseInt(task.getParams()[2]), false);
|
||||
handler.start();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user