L2JMobius

C6 Custom Time Item

Pirsys · 6 · 6296

Offline Pirsys

  • Knight
  • ***
    • Posts: 67
Good morning to all the members of the forum, I am wanting to develop a mod to place x duration of time on some items, what would be a shadow weapon does not work for me... I was seeing that what would be the PK weapons is better adapted, but no I know where to adjust the time variable in the core. Would someone be so kind as to guide me where I should look. Thanks.



Online Mobius

  • Distinguished King
  • *****
    • Posts: 16050
I do not think time items are implemented on Interlude.
You could adapt from Gracia Epilogue.


Offline Pirsys

  • Knight
  • ***
    • Posts: 67
layers I expressed myself wrong, the idea would be an item that can set the time as the time is set to the aiobuffer, I will be looking at the code of the aiobuffer and I will see if I can put together something like that.


Offline Pirsys

  • Knight
  • ***
    • Posts: 67
Code: [Select]
if (days > 0)
{
player.setAio(true);
player.setEndTime("aio", days);
player.getStat().addExp(player.getStat().getExpForLevel(81));

try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET aio=1, aio_end=? WHERE charId=?");
statement.setLong(1, player.getAioEndTime());
statement.setInt(2, player.getObjectId());
statement.execute();
statement.close();

something like this would be Mr. Mobius, the issue is that instead of being able to choose the amount of time, it is the number of hours.


Offline Pirsys

  • Knight
  • ***
    • Posts: 67
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;


Code: [Select]
* 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;

Code: [Select]
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;

Code: [Select]
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);