This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.datatables.CharNameTable;
|
||||
import com.l2jserver.gameserver.instancemanager.MailManager;
|
||||
import com.l2jserver.gameserver.model.entity.Message;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Mail;
|
||||
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;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Nyaran
|
||||
*/
|
||||
public class TaskBirthday extends Task
|
||||
{
|
||||
private static final String NAME = "birthday";
|
||||
private static final String QUERY = "SELECT charId, createDate FROM characters WHERE createDate LIKE ?";
|
||||
private static final Calendar _today = Calendar.getInstance();
|
||||
private int _count = 0;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Calendar lastExecDate = Calendar.getInstance();
|
||||
long lastActivation = task.getLastActivation();
|
||||
|
||||
if (lastActivation > 0)
|
||||
{
|
||||
lastExecDate.setTimeInMillis(lastActivation);
|
||||
}
|
||||
|
||||
String rangeDate = "[" + Util.getDateString(lastExecDate.getTime()) + "] - [" + Util.getDateString(_today.getTime()) + "]";
|
||||
|
||||
for (; !_today.before(lastExecDate); lastExecDate.add(Calendar.DATE, 1))
|
||||
{
|
||||
checkBirthday(lastExecDate.get(Calendar.YEAR), lastExecDate.get(Calendar.MONTH), lastExecDate.get(Calendar.DATE));
|
||||
}
|
||||
|
||||
_log.info("BirthdayManager: " + _count + " gifts sent. " + rangeDate);
|
||||
}
|
||||
|
||||
private void checkBirthday(int year, int month, int day)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY))
|
||||
{
|
||||
statement.setString(1, "%-" + getNum(month + 1) + "-" + getNum(day));
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
while (rset.next())
|
||||
{
|
||||
int playerId = rset.getInt("charId");
|
||||
Calendar createDate = Calendar.getInstance();
|
||||
createDate.setTime(rset.getDate("createDate"));
|
||||
|
||||
int age = year - createDate.get(Calendar.YEAR);
|
||||
if (age <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String text = Config.ALT_BIRTHDAY_MAIL_TEXT;
|
||||
|
||||
if (text.contains("$c1"))
|
||||
{
|
||||
text = text.replace("$c1", CharNameTable.getInstance().getNameById(playerId));
|
||||
}
|
||||
if (text.contains("$s1"))
|
||||
{
|
||||
text = text.replace("$s1", String.valueOf(age));
|
||||
}
|
||||
|
||||
Message msg = new Message(playerId, Config.ALT_BIRTHDAY_MAIL_SUBJECT, text, Message.SendBySystem.ALEGRIA);
|
||||
|
||||
Mail attachments = msg.createAttachments();
|
||||
attachments.addItem("Birthday", Config.ALT_BIRTHDAY_GIFT, 1, null, null);
|
||||
|
||||
MailManager.getInstance().sendMessage(msg);
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error checking birthdays. ", e);
|
||||
}
|
||||
|
||||
// If character birthday is 29-Feb and year isn't leap, send gift on 28-feb
|
||||
GregorianCalendar calendar = new GregorianCalendar();
|
||||
if ((month == Calendar.FEBRUARY) && (day == 28) && !calendar.isLeapYear(_today.get(Calendar.YEAR)))
|
||||
{
|
||||
checkBirthday(year, Calendar.FEBRUARY, 29);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param num the number to format.
|
||||
* @return the formatted number starting with a 0 if it is lower or equal than 10.
|
||||
*/
|
||||
private String getNum(int num)
|
||||
{
|
||||
return (num <= 9) ? "0" + num : String.valueOf(num);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2ClanMember;
|
||||
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 UnAfraid
|
||||
*/
|
||||
public class TaskClanLeaderApply extends Task
|
||||
{
|
||||
private static final String NAME = "clanleaderapply";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if (cal.get(Calendar.DAY_OF_WEEK) == Config.ALT_CLAN_LEADER_DATE_CHANGE)
|
||||
{
|
||||
for (L2Clan clan : ClanTable.getInstance().getClans())
|
||||
{
|
||||
if (clan.getNewLeaderId() != 0)
|
||||
{
|
||||
final L2ClanMember member = clan.getClanMember(clan.getNewLeaderId());
|
||||
if (member == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
clan.setNewLeader(member);
|
||||
}
|
||||
}
|
||||
_log.info(getClass().getSimpleName() + ": launched.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", Config.ALT_CLAN_LEADER_HOUR_CHANGE, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
System.runFinalization();
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 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;
|
||||
|
||||
public class TaskDailySkillReuseClean extends Task
|
||||
{
|
||||
private static final String NAME = "daily_skill_clean";
|
||||
|
||||
private static final int[] _daily_skills =
|
||||
{
|
||||
2510,
|
||||
22180
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
for (int skill_id : _daily_skills)
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_skills_save WHERE skill_id=?;"))
|
||||
{
|
||||
ps.setInt(1, skill_id);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.severe(getClass().getSimpleName() + ": Could not reset daily skill reuse: " + e);
|
||||
}
|
||||
_log.info("Daily skill reuse cleaned.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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.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
|
||||
{
|
||||
public static final String NAME = "global_varibales_save";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
GlobalVariablesManager.getInstance().storeMe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_FIXED_SHEDULED, "500000", "1800000", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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();
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
_python.cleanup();
|
||||
_python.exec("import sys");
|
||||
_python.execfile("data/scripts/cron/" + task.getParams()[2]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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.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
|
||||
{
|
||||
public static final String NAME = "olympiad_save";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
if (Olympiad.getInstance().inCompPeriod())
|
||||
{
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
_log.info("Olympiad System: Data updated.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_FIXED_SHEDULED, "900000", "1800000", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 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
|
||||
{
|
||||
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,75 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 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 String NAME = "recommendations";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE character_reco_bonus SET rec_left=?, time_left=?, rec_have=0 WHERE rec_have <= 20"))
|
||||
{
|
||||
ps.setInt(1, 0); // Rec left = 0
|
||||
ps.setInt(2, 3600000); // Timer = 1 hour
|
||||
ps.execute();
|
||||
}
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE character_reco_bonus SET rec_left=?, time_left=?, rec_have=GREATEST(rec_have-20,0) WHERE rec_have > 20"))
|
||||
{
|
||||
ps.setInt(1, 0); // Rec left = 0
|
||||
ps.setInt(2, 3600000); // Timer = 1 hour
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.severe(getClass().getSimpleName() + ": Could not reset Recommendations System: " + e);
|
||||
}
|
||||
_log.info("Recommendations System reseted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializate()
|
||||
{
|
||||
super.initializate();
|
||||
TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
Shutdown handler = new Shutdown(Integer.parseInt(task.getParams()[2]), true);
|
||||
handler.start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 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
|
||||
{
|
||||
public static final String NAME = "script";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeElapsed(ExecutedTask task)
|
||||
{
|
||||
final 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,44 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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";
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@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