SHOW:
|
|
- or go back to the newest paste.
| 1 | ### Eclipse Workspace Patch 1.0 | |
| 2 | #P aCis_datapack | |
| 3 | Index: sql/character_timed_items.sql | |
| 4 | =================================================================== | |
| 5 | --- sql/character_timed_items.sql (revision 0) | |
| 6 | +++ sql/character_timed_items.sql (working copy) | |
| 7 | @@ -0,0 +1,5 @@ | |
| 8 | +CREATE TABLE `character_timed_items` ( | |
| 9 | + `charId` int(11) NOT NULL, | |
| 10 | + `itemId` int(11) NOT NULL, | |
| 11 | + `time` decimal(20,0) NOT NULL DEFAULT '0' | |
| 12 | +) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
| 13 | \ No newline at end of file | |
| 14 | #P aCis_gameserver | |
| 15 | Index: java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java | |
| 16 | =================================================================== | |
| 17 | --- java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java (revision 1) | |
| 18 | +++ java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java (working copy) | |
| 19 | @@ -4,6 +4,8 @@ | |
| 20 | import java.util.List; | |
| 21 | import java.util.stream.Collectors; | |
| 22 | ||
| 23 | +import net.sf.l2j.Config; | |
| 24 | +import net.sf.l2j.gameserver.data.sql.TimedItemTable; | |
| 25 | import net.sf.l2j.gameserver.model.WorldObject; | |
| 26 | import net.sf.l2j.gameserver.model.actor.instance.Player; | |
| 27 | import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
| 28 | @@ -393,6 +395,9 @@ | |
| 29 | else if (item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena)) | |
| 30 | _ancientAdena = item; | |
| 31 | ||
| 32 | + if (Config.LIST_TIMED_ITEMS.contains(item.getItemId())) | |
| 33 | + TimedItemTable.getInstance().setTimed(item); | |
| 34 | + | |
| 35 | return item; | |
| 36 | } | |
| 37 | ||
| 38 | @@ -416,6 +421,9 @@ | |
| 39 | _adena = item; | |
| 40 | else if (item.getItemId() == ANCIENT_ADENA_ID && !item.equals(_ancientAdena)) | |
| 41 | _ancientAdena = item; | |
| 42 | + | |
| 43 | + if (Config.LIST_TIMED_ITEMS.contains(item.getItemId())) | |
| 44 | + TimedItemTable.getInstance().setTimed(item); | |
| 45 | ||
| 46 | if (actor != null) | |
| 47 | {
| |
| 48 | @@ -452,6 +460,9 @@ | |
| 49 | ||
| 50 | if (_ancientAdena != null && (_ancientAdena.getCount() <= 0 || _ancientAdena.getOwnerId() != getOwnerId())) | |
| 51 | _ancientAdena = null; | |
| 52 | + | |
| 53 | + if (item != null && Config.LIST_TIMED_ITEMS.contains(item.getItemId())) | |
| 54 | + TimedItemTable.getInstance().setTimed(item); | |
| 55 | ||
| 56 | return item; | |
| 57 | } | |
| 58 | @@ -488,6 +499,9 @@ | |
| 59 | ||
| 60 | if (_ancientAdena != null && _ancientAdena.getCount() <= 0) | |
| 61 | _ancientAdena = null; | |
| 62 | + | |
| 63 | + if (item != null && Config.LIST_TIMED_ITEMS.contains(item.getItemId())) | |
| 64 | + TimedItemTable.getInstance().destroy(item); | |
| 65 | ||
| 66 | return item; | |
| 67 | } | |
| 68 | Index: java/net/sf/l2j/Config.java | |
| 69 | =================================================================== | |
| 70 | --- java/net/sf/l2j/Config.java (revision 1) | |
| 71 | +++ java/net/sf/l2j/Config.java (working copy) | |
| 72 | @@ -360,7 +385,41 @@ | |
| 73 | public static boolean DEEPBLUE_DROP_RULES; | |
| 74 | public static boolean ALT_GAME_DELEVEL; | |
| 75 | public static int DEATH_PENALTY_CHANCE; | |
| 76 | + public static String TIMED_ITEMS; | |
| 77 | + public static ArrayList<Object> LIST_TIMED_ITEMS = new ArrayList<>(); | |
| 78 | + public static int TIMED_ITEM_TIME; | |
| 79 | ||
| 80 | @@ -1037,7 +1197,66 @@ | |
| 81 | DEEPBLUE_DROP_RULES = players.getProperty("UseDeepBlueDropRules", true);
| |
| 82 | ALT_GAME_DELEVEL = players.getProperty("Delevel", true);
| |
| 83 | DEATH_PENALTY_CHANCE = players.getProperty("DeathPenaltyChance", 20);
| |
| 84 | + TIMED_ITEMS = players.getProperty("ListOfTimedItems");
| |
| 85 | + TIMED_ITEM_TIME = Integer.parseInt(players.getProperty("TimedItemTime", "2"));
| |
| 86 | + LIST_TIMED_ITEMS = new ArrayList<>(); | |
| 87 | + for (String id : TIMED_ITEMS.trim().split(","))
| |
| 88 | + LIST_TIMED_ITEMS.add(Integer.parseInt(id.trim())); | |
| 89 | ||
| 90 | Index: java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java | |
| 91 | =================================================================== | |
| 92 | --- java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java (revision 0) | |
| 93 | +++ java/net/sf/l2j/gameserver/taskmanager/ItemsTaskManager.java (working copy) | |
| 94 | @@ -0,0 +1,105 @@ | |
| 95 | +package net.sf.l2j.gameserver.taskmanager; | |
| 96 | + | |
| 97 | +import java.util.concurrent.Future; | |
| 98 | + | |
| 99 | +import net.sf.l2j.commons.concurrent.ThreadPool; | |
| 100 | + | |
| 101 | +/** | |
| 102 | + * @author Williams | |
| 103 | + * | |
| 104 | + */ | |
| 105 | +public abstract class ItemsTaskManager | |
| 106 | +{
| |
| 107 | + private final boolean _returnIfAlreadyRunning; | |
| 108 | + | |
| 109 | + private Future<?> _future; | |
| 110 | + private boolean _isRunning; | |
| 111 | + private Thread _currentThread; | |
| 112 | + | |
| 113 | + protected ItemsTaskManager(boolean returnIfAlreadyRunning) | |
| 114 | + {
| |
| 115 | + _returnIfAlreadyRunning = returnIfAlreadyRunning; | |
| 116 | + } | |
| 117 | + | |
| 118 | + protected ItemsTaskManager() | |
| 119 | + {
| |
| 120 | + this(false); | |
| 121 | + } | |
| 122 | + | |
| 123 | + public synchronized boolean isScheduled() | |
| 124 | + {
| |
| 125 | + return _future != null; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public synchronized final void cancel() | |
| 129 | + {
| |
| 130 | + if (_future != null) | |
| 131 | + {
| |
| 132 | + _future.cancel(false); | |
| 133 | + _future = null; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + public synchronized final void schedule(long delay) | |
| 138 | + {
| |
| 139 | + cancel(); | |
| 140 | + _future = ThreadPool.schedule(_runnable, delay); | |
| 141 | + } | |
| 142 | + | |
| 143 | + public synchronized final void scheduleAtFixedRate(long delay, long period) | |
| 144 | + {
| |
| 145 | + cancel(); | |
| 146 | + _future = ThreadPool.scheduleAtFixedRate(_runnable, delay, period); | |
| 147 | + } | |
| 148 | + | |
| 149 | + private final Runnable _runnable = new Runnable() | |
| 150 | + {
| |
| 151 | + @Override | |
| 152 | + public void run() | |
| 153 | + {
| |
| 154 | + if (tryLock()) | |
| 155 | + {
| |
| 156 | + try | |
| 157 | + {
| |
| 158 | + onElapsed(); | |
| 159 | + } | |
| 160 | + finally | |
| 161 | + {
| |
| 162 | + unlock(); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + } | |
| 166 | + }; | |
| 167 | + | |
| 168 | + protected abstract void onElapsed(); | |
| 169 | + | |
| 170 | + public synchronized boolean tryLock() | |
| 171 | + {
| |
| 172 | + if (_returnIfAlreadyRunning) | |
| 173 | + return !_isRunning; | |
| 174 | + | |
| 175 | + _currentThread = Thread.currentThread(); | |
| 176 | + | |
| 177 | + try | |
| 178 | + {
| |
| 179 | + notifyAll(); | |
| 180 | + | |
| 181 | + if (_currentThread != Thread.currentThread()) | |
| 182 | + return false; | |
| 183 | + | |
| 184 | + if (!_isRunning) | |
| 185 | + return true; | |
| 186 | + | |
| 187 | + wait(); | |
| 188 | + } | |
| 189 | + catch (InterruptedException e) | |
| 190 | + {
| |
| 191 | + } | |
| 192 | + return false; | |
| 193 | + } | |
| 194 | + | |
| 195 | + public synchronized void unlock() | |
| 196 | + {
| |
| 197 | + _isRunning = false; | |
| 198 | + } | |
| 199 | +} | |
| 200 | \ No newline at end of file | |
| 201 | Index: config/players.properties | |
| 202 | =================================================================== | |
| 203 | --- config/players.properties (revision 1) | |
| 204 | +++ config/players.properties (working copy) | |
| 205 | @@ -42,7 +42,128 @@ | |
| 206 | # Death Penalty chance if killed by mob (in %), 20 by default | |
| 207 | DeathPenaltyChance = 20 | |
| 208 | ||
| 209 | +# Timed Item ID use , for separate (57,3441,5588...) | |
| 210 | +ListOfTimedItems = 6369 | |
| 211 | +# Time for item disappear in Hour's | |
| 212 | +TimedItemTime = 1 | |
| 213 | \ No newline at end of file |