Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_datapack
- Index: sql/character_timed_items.sql
- ===================================================================
- --- sql/character_timed_items.sql (revision 0)
- +++ sql/character_timed_items.sql (working copy)
- @@ -0,0 +1,5 @@
- +CREATE TABLE `character_timed_items` (
- + `charId` int(11) NOT NULL,
- + `itemId` int(11) NOT NULL,
- + `time` decimal(20,0) NOT NULL DEFAULT '0'
- +) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- \ No newline at end of file
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java (revision 1)
- +++ java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java (working copy)
- @@ -4,6 +4,8 @@
- import java.util.List;
- import java.util.stream.Collectors;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.sql.TimedItemTable;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- @@ -393,6 +395,9 @@
- else if (item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena))
- _ancientAdena = item;
- + if (Config.LIST_TIMED_ITEMS.contains(item.getItemId()))
- + TimedItemTable.getInstance().setTimed(item);
- +
- return item;
- }
- @@ -416,6 +421,9 @@
- _adena = item;
- else if (item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena))
- _ancientAdena = item;
- +
- + if (Config.LIST_TIMED_ITEMS.contains(item.getItemId()))
- + TimedItemTable.getInstance().setTimed(item);
- if (actor != null)
- {
- @@ -452,6 +460,9 @@
- if (_ancientAdena != null && (_ancientAdena.getCount() <= 0 || _ancientAdena.getOwnerId() != getOwnerId()))
- _ancientAdena = null;
- +
- + if (item != null && Config.LIST_TIMED_ITEMS.contains(item.getItemId()))
- + TimedItemTable.getInstance().setTimed(item);
- return item;
- }
- @@ -488,6 +499,9 @@
- if (_ancientAdena != null && _ancientAdena.getCount() <= 0)
- _ancientAdena = null;
- +
- + if (item != null && Config.LIST_TIMED_ITEMS.contains(item.getItemId()))
- + TimedItemTable.getInstance().destroy(item);
- return item;
- }
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 1)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -360,7 +385,41 @@
- public static boolean DEEPBLUE_DROP_RULES;
- public static boolean ALT_GAME_DELEVEL;
- public static int DEATH_PENALTY_CHANCE;
- + public static String TIMED_ITEMS;
- + public static ArrayList<Object> LIST_TIMED_ITEMS = new ArrayList<>();
- + public static int TIMED_ITEM_TIME;
- @@ -1037,7 +1197,66 @@
- DEEPBLUE_DROP_RULES = players.getProperty("UseDeepBlueDropRules", true);
- ALT_GAME_DELEVEL = players.getProperty("Delevel", true);
- DEATH_PENALTY_CHANCE = players.getProperty("DeathPenaltyChance", 20);
- + TIMED_ITEMS = players.getProperty("ListOfTimedItems");
- + TIMED_ITEM_TIME = Integer.parseInt(players.getProperty("TimedItemTime", "2"));
- + LIST_TIMED_ITEMS = new ArrayList<>();
- + for (String id : TIMED_ITEMS.trim().split(","))
- + LIST_TIMED_ITEMS.add(Integer.parseInt(id.trim()));
- Index: java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java (working copy)
- @@ -0,0 +1,105 @@
- +package net.sf.l2j.gameserver.taskmanager;
- +
- +import java.util.concurrent.Future;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +/**
- + * @author Williams
- + *
- + */
- +public abstract class ItemsTaskManager
- +{
- + private final boolean _returnIfAlreadyRunning;
- +
- + private Future<?> _future;
- + private boolean _isRunning;
- + private Thread _currentThread;
- +
- + protected ItemsTaskManager(boolean returnIfAlreadyRunning)
- + {
- + _returnIfAlreadyRunning = returnIfAlreadyRunning;
- + }
- +
- + protected ItemsTaskManager()
- + {
- + this(false);
- + }
- +
- + public synchronized boolean isScheduled()
- + {
- + return _future != null;
- + }
- +
- + public synchronized final void cancel()
- + {
- + if (_future != null)
- + {
- + _future.cancel(false);
- + _future = null;
- + }
- + }
- +
- + public synchronized final void schedule(long delay)
- + {
- + cancel();
- + _future = ThreadPool.schedule(_runnable, delay);
- + }
- +
- + public synchronized final void scheduleAtFixedRate(long delay, long period)
- + {
- + cancel();
- + _future = ThreadPool.scheduleAtFixedRate(_runnable, delay, period);
- + }
- +
- + private final Runnable _runnable = new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + if (tryLock())
- + {
- + try
- + {
- + onElapsed();
- + }
- + finally
- + {
- + unlock();
- + }
- + }
- + }
- + };
- +
- + protected abstract void onElapsed();
- +
- + public synchronized boolean tryLock()
- + {
- + if (_returnIfAlreadyRunning)
- + return !_isRunning;
- +
- + _currentThread = Thread.currentThread();
- +
- + try
- + {
- + notifyAll();
- +
- + if (_currentThread != Thread.currentThread())
- + return false;
- +
- + if (!_isRunning)
- + return true;
- +
- + wait();
- + }
- + catch (InterruptedException e)
- + {
- + }
- + return false;
- + }
- +
- + public synchronized void unlock()
- + {
- + _isRunning = false;
- + }
- +}
- \ No newline at end of file
- Index: config/players.properties
- ===================================================================
- --- config/players.properties (revision 1)
- +++ config/players.properties (working copy)
- @@ -42,7 +42,128 @@
- # Death Penalty chance if killed by mob (in %), 20 by default
- DeathPenaltyChance = 20
- +# Timed Item ID use , for separate (57,3441,5588...)
- +ListOfTimedItems = 6369
- +# Time for item disappear in Hour's
- +TimedItemTime = 1
- \ No newline at end of file
Add Comment
Please, Sign In to add comment