Well, I don't know if it will be good, I think it would be a matter of trying, but I know that in the forum there are many people who, just by reading, can know if it will work or if I am going to break the pack... would you be so kind to tell me if it is necessary modify some line... I share what I did so far.
org.l2jmobius.gameserver.handler.itemhandlers.CustomDuration;
* This file is part of the L2J Mobius project.
*
* 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 org.l2jmobius.gameserver.handler.itemhandlers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
public class CustomDuration implements IItemHandler
{
protected static final Logger LOGGER = Logger.getLogger(CustomDuration.class.getName());
private static final int ITEM_IDS[] =
{
Config.RUNAEXP_ITEM_ID
};
public void useItem(Playable playable, ItemInstance item , String time)
{
if (Config.RUNAEXP_ITEMS)
{
final PlayerInstance player = (PlayerInstance) playable;
if (player.isInOlympiadMode())
{
player.sendMessage("This item cannot be used in olympiad mode.");
}
else
{
try (Connection con = DatabaseFactory.getConnection())
{
final int ReTime = Config.RUNAEXP_DAY * 24 * 60 * 60 * 1000;
player.setEndTime("RECustomDay", ReTime);
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET RECustomDay=1, RE_end=? WHERE charId=?");
statement.setLong(1, player.getReEndTime());
statement.setInt(2, player.getObjectId());
statement.execute();
statement.close();
}
catch (Exception e)
{
LOGGER.warning("Could not set Aio stats to char: " + e);
}
}
}
}
@Override
public int[] getItemIds()
{
return ITEM_IDS;
}
/* (non-Javadoc)
* @see org.l2jmobius.gameserver.handler.IItemHandler#useItem(org.l2jmobius.gameserver.model.actor.Playable, org.l2jmobius.gameserver.model.items.instance.ItemInstance)
*/
@Override
public void useItem(Playable playable, ItemInstance item)
{
// TODO Auto-generated method stub
}
}
org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
private long _aioEndTime = 0;
+private long _ReEndTime = 0;
_aioEndTime = value;
}
+public void setReEndTime(long value)
+{
+ _ReEndTime = value;
+}
_aioEndTime = endDay;
}
+if (process.equals("RECustomDay"))
+{
+ _ReEndTime = endDay;
+}
_aioEndTime = 0;
}
+else if (process.equals("RECustomDay"))
+{
+ _ReEndTime = 0;
+}
org.l2jmobius.Config.java;
public static boolean RUNAEXP_ITEMS;
public static int RUNAEXP_ITEM_ID;
public static long RUNAEXP_DAY;
RUNAEXP_ITEMS = customServerConfig.getBoolean("EnableRECustomItem", true);
RUNAEXP_ITEM_ID = customServerConfig.getInt("ReCustomItemId", 3481);
RUNAEXP_DAY = customServerConfig.getLong("RECustomDay", 0);