diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/config/General.ini b/L2J_Mobius_01.0_Ertheia/dist/game/config/General.ini index 731e388916..7280d58bbe 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/config/General.ini +++ b/L2J_Mobius_01.0_Ertheia/dist/game/config/General.ini @@ -324,14 +324,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java index 15eeee8e34..4590664af3 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/Config.java @@ -506,8 +506,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2047,8 +2045,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java index a8dd9d6583..f0a7097cb6 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -56,7 +56,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -565,7 +564,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2986,36 +2985,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6718,11 +6696,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11188,16 +11163,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_02.5_Underground/dist/game/config/General.ini b/L2J_Mobius_02.5_Underground/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/config/General.ini +++ b/L2J_Mobius_02.5_Underground/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java index 2d525b8fd9..50c17b9ab4 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/Config.java @@ -516,8 +516,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2071,8 +2069,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java index a2323d1fcb..07e0b30ba2 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -56,7 +56,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -567,7 +566,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2988,36 +2987,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6721,11 +6699,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11191,16 +11166,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_03.0_Helios/dist/game/config/General.ini b/L2J_Mobius_03.0_Helios/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/config/General.ini +++ b/L2J_Mobius_03.0_Helios/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java index 72e6ed66d5..a8d448bc3a 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/Config.java @@ -516,8 +516,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2084,8 +2082,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java index e5b33266d3..f1c4c94d30 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -56,7 +56,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -569,7 +568,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2990,36 +2989,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6723,11 +6701,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11193,16 +11168,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/config/General.ini b/L2J_Mobius_04.0_GrandCrusade/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/config/General.ini +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java index 71a28c723e..65b96200a9 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -510,8 +510,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2064,8 +2062,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java index 796f5fc316..da88019e2c 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -573,7 +572,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2986,36 +2985,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6718,11 +6696,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11197,16 +11172,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_05.0_Salvation/dist/game/config/General.ini b/L2J_Mobius_05.0_Salvation/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/config/General.ini +++ b/L2J_Mobius_05.0_Salvation/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java index a73e3b75fb..d22cfed2b7 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/Config.java @@ -509,8 +509,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2073,8 +2071,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java index d026392424..759377d5cc 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -569,7 +568,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3016,36 +3015,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6736,11 +6714,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11224,16 +11199,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/config/General.ini b/L2J_Mobius_05.5_EtinasFate/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/config/General.ini +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java index d2e9103703..928fdfbb9e 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/Config.java @@ -509,8 +509,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2080,8 +2078,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java index dd7e9bf3a4..ff27c26de0 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -570,7 +569,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3029,36 +3028,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6749,11 +6727,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11240,16 +11215,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/config/General.ini b/L2J_Mobius_06.0_Fafurion/dist/game/config/General.ini index e5b30cc09e..d8b4a0c980 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/config/General.ini +++ b/L2J_Mobius_06.0_Fafurion/dist/game/config/General.ini @@ -332,14 +332,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java index f92efe809b..47aa98b371 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/Config.java @@ -510,8 +510,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2119,8 +2117,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java index 006a233eed..35fda668ca 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -570,7 +569,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3030,36 +3029,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6750,11 +6728,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11246,16 +11221,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/General.ini b/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/General.ini index fe0170243c..bd397fd309 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/General.ini +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/config/General.ini @@ -333,14 +333,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java index 5b0a21fc8c..524fd34667 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -511,8 +511,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2131,8 +2129,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java index 46d8bd48a4..c522c0a4af 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -583,7 +582,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2966,36 +2965,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6719,11 +6697,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11288,16 +11263,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/config/General.ini b/L2J_Mobius_08.2_Homunculus/dist/game/config/General.ini index 9315ec4f2e..4569538851 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/config/General.ini +++ b/L2J_Mobius_08.2_Homunculus/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java index f239d72455..ec7ecfddb5 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/Config.java @@ -501,8 +501,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2107,8 +2105,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java index 620053e2f6..5374823001 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -591,7 +590,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3004,36 +3003,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6825,11 +6803,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11439,16 +11414,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/General.ini b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/General.ini index 7c6216262d..fb08e9aa2a 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/General.ini +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java index 7ccecf9b5d..964517839e 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java @@ -501,8 +501,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2143,8 +2141,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java index 08d4bcbd09..3062a168ea 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -604,7 +603,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3021,36 +3020,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6842,11 +6820,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11466,16 +11441,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_10.2_MasterClass/dist/game/config/General.ini b/L2J_Mobius_10.2_MasterClass/dist/game/config/General.ini index b2060481af..fed3eba9fe 100644 --- a/L2J_Mobius_10.2_MasterClass/dist/game/config/General.ini +++ b/L2J_Mobius_10.2_MasterClass/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/Config.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/Config.java index aa1ab161d0..30915ac85c 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/Config.java @@ -501,8 +501,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2144,8 +2142,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index 550c4e4596..f15ee1c373 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -607,7 +606,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3024,36 +3023,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6901,11 +6879,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11538,16 +11513,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_10.3_MasterClass/dist/game/config/General.ini b/L2J_Mobius_10.3_MasterClass/dist/game/config/General.ini index 550e2fa123..779aa4b156 100644 --- a/L2J_Mobius_10.3_MasterClass/dist/game/config/General.ini +++ b/L2J_Mobius_10.3_MasterClass/dist/game/config/General.ini @@ -334,14 +334,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/Config.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/Config.java index 448d3bfbf8..a9e4ba1feb 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/Config.java @@ -503,8 +503,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2181,8 +2179,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index 4aaedd9079..305b24a164 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -613,7 +612,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3046,36 +3045,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6931,11 +6909,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11581,16 +11556,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/General.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/General.ini index bd006afc74..3a878b9605 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/General.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/General.ini @@ -441,12 +441,6 @@ DefaultPunishParam = 0 # On / Off Warehouse AllowWarehouse = True -# On / Off hashing Warehouse -WarehouseCache = False - -# How much memory should occupy hash Warehouse -WarehouseCacheTime = 15 - # On / Off use Freight Warehouse AllowFreight = True diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index b9e1f73ade..241be25976 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -155,8 +155,6 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static boolean ALLOW_FREIGHT; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_WEAR; public static int WEAR_DELAY; public static int WEAR_PRICE; @@ -1453,8 +1451,6 @@ public class Config PRECISE_DROP_CALCULATION = generalConfig.getBoolean("PreciseDropCalculation", true); MULTIPLE_ITEM_DROP = generalConfig.getBoolean("MultipleItemDrop", true); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_FREIGHT = generalConfig.getBoolean("AllowFreight", true); ALLOW_WEAR = generalConfig.getBoolean("AllowWear", false); WEAR_DELAY = generalConfig.getInt("WearDelay", 5); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 9626585aae..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected final Map _cachedWh; - protected final long _cacheTime; - - protected WarehouseCacheManager() - { - _cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000; // 60*1000 = 60000 - _cachedWh = new ConcurrentHashMap<>(); - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - _cachedWh.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - _cachedWh.remove(pc); - } - - public class CacheScheduler implements Runnable - { - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : _cachedWh.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > _cacheTime) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - _cachedWh.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Player.java index d5d8d7d5e7..e9e2cd5d6d 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -42,7 +42,6 @@ import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.cache.HtmCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.HeroSkillTable; @@ -338,7 +337,7 @@ public class Player extends Playable private long _lastRecomUpdate; private final List _recomChars = new ArrayList<>(); private final PlayerInventory _inventory = new PlayerInventory(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private final PlayerFreight _freight = new PlayerFreight(this); private int _privatestore; private TradeList _activeTradeList; @@ -910,10 +909,7 @@ public class Player extends Playable // Retrieve from the database all skills of this Player and add them to _skills // Retrieve from the database all items of this Player and add them to _inventory getInventory().restore(); - if (!Config.WAREHOUSE_CACHE) - { - getWarehouse(); - } + getWarehouse().restore(); getFreight().restore(); _instanceLoginTime = System.currentTimeMillis(); @@ -3123,37 +3119,16 @@ public class Player extends Playable } /** - * Return the PcWarehouse object of the Player. + * Return the PlayerWarehouse object of the Player. * @return the warehouse */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse. - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * Return the PcFreight object of the Player. + * Return the PlayerFreight object of the Player. * @return the freight */ public PlayerFreight getFreight() @@ -13003,18 +12978,13 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Throwable t) { LOGGER.warning("deleteMe()" + t); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } - // Update database with items in its freight and remove them from the world try { diff --git a/L2J_Mobius_C6_Interlude/dist/game/config/General.ini b/L2J_Mobius_C6_Interlude/dist/game/config/General.ini index 130c854b4b..9fdabb254f 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/config/General.ini +++ b/L2J_Mobius_C6_Interlude/dist/game/config/General.ini @@ -465,12 +465,6 @@ DefaultPunishParam = 0 # On / Off Warehouse AllowWarehouse = True -# On / Off hashing Warehouse -WarehouseCache = False - -# How much memory should occupy hash Warehouse -WarehouseCacheTime = 15 - # On / Off use Freight Warehouse AllowFreight = True diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index 8efdd2b798..1616983fe7 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -171,8 +171,6 @@ public class Config public static boolean ALLOW_DISCARDITEM; public static boolean ALLOW_FREIGHT; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_WEAR; public static int WEAR_DELAY; public static int WEAR_PRICE; @@ -1506,8 +1504,6 @@ public class Config PRECISE_DROP_CALCULATION = generalConfig.getBoolean("PreciseDropCalculation", true); MULTIPLE_ITEM_DROP = generalConfig.getBoolean("MultipleItemDrop", true); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_FREIGHT = generalConfig.getBoolean("AllowFreight", true); ALLOW_WEAR = generalConfig.getBoolean("AllowWear", false); WEAR_DELAY = generalConfig.getInt("WearDelay", 5); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 9626585aae..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected final Map _cachedWh; - protected final long _cacheTime; - - protected WarehouseCacheManager() - { - _cacheTime = Config.WAREHOUSE_CACHE_TIME * 60000; // 60*1000 = 60000 - _cachedWh = new ConcurrentHashMap<>(); - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - _cachedWh.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - _cachedWh.remove(pc); - } - - public class CacheScheduler implements Runnable - { - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : _cachedWh.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > _cacheTime) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - _cachedWh.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java index 5c314b9bb9..160a0b50b1 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -42,7 +42,6 @@ import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.cache.HtmCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.HeroSkillTable; @@ -351,7 +350,7 @@ public class Player extends Playable private long _lastRecomUpdate; private final List _recomChars = new ArrayList<>(); private final PlayerInventory _inventory = new PlayerInventory(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private final PlayerFreight _freight = new PlayerFreight(this); private int _privatestore; private TradeList _activeTradeList; @@ -924,10 +923,7 @@ public class Player extends Playable // Retrieve from the database all skills of this Player and add them to _skills // Retrieve from the database all items of this Player and add them to _inventory getInventory().restore(); - if (!Config.WAREHOUSE_CACHE) - { - getWarehouse(); - } + getWarehouse().restore(); getFreight().restore(); _instanceLoginTime = System.currentTimeMillis(); @@ -3191,37 +3187,16 @@ public class Player extends Playable } /** - * Return the PcWarehouse object of the Player. + * Return the PlayerWarehouse object of the Player. * @return the warehouse */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse. - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * Return the PcFreight object of the Player. + * Return the PlayerFreight object of the Player. * @return the freight */ public PlayerFreight getFreight() @@ -13327,18 +13302,13 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Throwable t) { LOGGER.warning("deleteMe()" + t); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } - // Update database with items in its freight and remove them from the world try { diff --git a/L2J_Mobius_CT_0_Interlude/dist/game/config/General.ini b/L2J_Mobius_CT_0_Interlude/dist/game/config/General.ini index 1431edbf42..17e2c85f5c 100644 --- a/L2J_Mobius_CT_0_Interlude/dist/game/config/General.ini +++ b/L2J_Mobius_CT_0_Interlude/dist/game/config/General.ini @@ -316,14 +316,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/Config.java index f267229663..e2e70ca933 100644 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/Config.java @@ -554,8 +554,6 @@ public class Config public static String DEFAULT_TRADE_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_WEAR; public static int WEAR_DELAY; @@ -2032,8 +2030,6 @@ public class Config DEFAULT_TRADE_CHAT = generalConfig.getString("TradeChat", "ON"); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_WEAR = generalConfig.getBoolean("AllowWear", true); WEAR_DELAY = generalConfig.getInt("WearDelay", 5); diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java index 90997c4849..7c612585f2 100644 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -52,7 +52,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -506,7 +505,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; @@ -2832,36 +2831,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6665,11 +6643,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } // Retrieve from the database all secondary data of this Player // Note that Clan, Noblesse and Hero skills are given separately and not here. @@ -10930,16 +10905,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/General.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/General.ini index c05a5e857e..7f2af883fb 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/General.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/General.ini @@ -316,14 +316,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index a6b45c3812..6eb20a8134 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -562,8 +562,6 @@ public class Config public static String DEFAULT_TRADE_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2097,8 +2095,6 @@ public class Config DEFAULT_TRADE_CHAT = generalConfig.getString("TradeChat", "ON"); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Player.java index 394d7f313e..cb09c1f0f4 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -53,7 +53,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -552,7 +551,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; @@ -3020,36 +3019,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -7058,11 +7036,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } // Retrieve from the database all secondary data of this Player // Note that Clan, Noblesse and Hero skills are given separately and not here. @@ -11545,16 +11520,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/General.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/General.ini index c05a5e857e..7f2af883fb 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/General.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/General.ini @@ -316,14 +316,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index ad857954f0..a4c1212b8b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -567,8 +567,6 @@ public class Config public static String DEFAULT_TRADE_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2102,8 +2100,6 @@ public class Config DEFAULT_TRADE_CHAT = generalConfig.getString("TradeChat", "ON"); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java index 2899821971..111cf518e9 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -53,7 +53,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -573,7 +572,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; @@ -2931,36 +2930,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6950,11 +6928,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } // Retrieve from the database all secondary data of this Player // Note that Clan, Noblesse and Hero skills are given separately and not here. @@ -11438,16 +11413,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_1.0/dist/game/config/General.ini b/L2J_Mobius_Classic_1.0/dist/game/config/General.ini index c691a39771..797b32ad08 100644 --- a/L2J_Mobius_Classic_1.0/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_1.0/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/Config.java index 92566efc2c..a298eb10e7 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/Config.java @@ -519,8 +519,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -1981,8 +1979,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/actor/Player.java index 6191e3d02c..a067df8c19 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -559,7 +558,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2940,36 +2939,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6690,11 +6668,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11083,16 +11058,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/dist/game/config/General.ini b/L2J_Mobius_Classic_1.5_AgeOfSplendor/dist/game/config/General.ini index 3eb91fb38b..f17bd4455f 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/Config.java index 23720cdbb0..5d993138d8 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2010,8 +2008,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/actor/Player.java index 89b3af818b..e5b207702a 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -567,7 +566,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2949,36 +2948,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6700,11 +6678,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11094,16 +11069,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/General.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/General.ini index 72d03e2494..6f838fd1b3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index 7f79b5e401..b34b075689 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2013,8 +2011,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java index 89b3af818b..e5b207702a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -567,7 +566,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2949,36 +2948,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6700,11 +6678,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11094,16 +11069,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.5_Zaken/dist/game/config/General.ini b/L2J_Mobius_Classic_2.5_Zaken/dist/game/config/General.ini index 72d03e2494..6f838fd1b3 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.5_Zaken/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/Config.java index eb0970f06a..e4fdcfa8e0 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2017,8 +2015,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java index 06afe7c75e..f9dddaa85d 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -567,7 +566,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2949,36 +2948,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6700,11 +6678,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11094,16 +11069,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.7_Antharas/dist/game/config/General.ini b/L2J_Mobius_Classic_2.7_Antharas/dist/game/config/General.ini index 72d03e2494..6f838fd1b3 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.7_Antharas/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/Config.java index eb0970f06a..e4fdcfa8e0 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2017,8 +2015,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java index c5c32b37c9..5213ae3a69 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -565,7 +564,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2947,36 +2946,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6686,11 +6664,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11080,16 +11055,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/dist/game/config/General.ini b/L2J_Mobius_Classic_2.8_SevenSigns/dist/game/config/General.ini index 72d03e2494..6f838fd1b3 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.8_SevenSigns/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/Config.java index eb0970f06a..e4fdcfa8e0 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2017,8 +2015,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java index 08c1a364a3..a98a7caa36 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -575,7 +574,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2975,36 +2974,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6719,11 +6697,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11126,16 +11101,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/dist/game/config/General.ini b/L2J_Mobius_Classic_2.9.5_Saviors/dist/game/config/General.ini index eb4b86a639..5ea87c0335 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.9.5_Saviors/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/Config.java index acdcce4ced..ca61ad27d3 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/Config.java @@ -530,8 +530,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2069,8 +2067,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java index e3f6c4f708..c00c9917ef 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -585,7 +584,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2988,36 +2987,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6766,11 +6744,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11189,16 +11164,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/dist/game/config/General.ini b/L2J_Mobius_Classic_2.9_SecretOfEmpire/dist/game/config/General.ini index 72d03e2494..6f838fd1b3 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/Config.java index 0b41af0ef9..fb689d0572 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2026,8 +2024,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java index d2fa07546e..a52f50c883 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -575,7 +574,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2975,36 +2974,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6719,11 +6697,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11126,16 +11101,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/General.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/General.ini index c65a143c4e..6aca958ad8 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index 842ca37747..0ddb4ad681 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2068,8 +2066,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java index 92e2ad8bad..c24e80ab35 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -589,7 +588,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2901,36 +2900,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6678,11 +6656,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11092,16 +11067,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/General.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/General.ini index ec11020445..2f14cf2f93 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/General.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index a318a120f6..2c7d1862e5 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -529,8 +529,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2021,8 +2019,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java index 14c4687cfe..53c0d3dfe2 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -55,7 +55,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -562,7 +561,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2946,36 +2945,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6676,11 +6654,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11088,16 +11063,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini index 4b7b1eb46a..5ea510fff3 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java index 2e7af646a0..1b75fc893c 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -530,8 +530,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2107,8 +2105,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java index 3545e7097a..1173eadec5 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -609,7 +608,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -2979,36 +2978,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6810,11 +6788,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11284,16 +11259,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini index fb8c3f2ca8..eae6e84de6 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/config/General.ini @@ -328,14 +328,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java index 2477c594ce..d5ec4eb943 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/Config.java @@ -533,8 +533,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2213,8 +2211,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java index 39134b0c51..2b2e32a49b 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -633,7 +632,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3088,36 +3087,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -6929,11 +6907,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11426,16 +11401,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini index fb14e4d777..80fd67205b 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/General.ini @@ -334,14 +334,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java index 05d8b995aa..dc2c6a7993 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java @@ -535,8 +535,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2251,8 +2249,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java index 874bb96b67..328164be69 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -644,7 +643,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3139,36 +3138,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -7029,11 +7007,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11694,16 +11669,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try { diff --git a/L2J_Mobius_Essence_6.3_Crusader/dist/game/config/General.ini b/L2J_Mobius_Essence_6.3_Crusader/dist/game/config/General.ini index fb14e4d777..80fd67205b 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/dist/game/config/General.ini +++ b/L2J_Mobius_Essence_6.3_Crusader/dist/game/config/General.ini @@ -334,14 +334,6 @@ MinimumChatLevel = 0 # Default: True AllowWarehouse = True -# Enable Warehouse Cache. If warehouse is not used will server clear memory used by this warehouse. -# Default: False -WarehouseCache = False - -# How long warehouse should be stored in memory. -# Default: 15 -WarehouseCacheTime = 15 - # Default: True AllowRefund = True diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/Config.java index 05d8b995aa..dc2c6a7993 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/Config.java @@ -535,8 +535,6 @@ public class Config public static boolean ENABLE_WORLD_CHAT; public static int MINIMUM_CHAT_LEVEL; public static boolean ALLOW_WAREHOUSE; - public static boolean WAREHOUSE_CACHE; - public static int WAREHOUSE_CACHE_TIME; public static boolean ALLOW_REFUND; public static boolean ALLOW_MAIL; public static boolean ALLOW_ATTACHMENTS; @@ -2251,8 +2249,6 @@ public class Config ENABLE_WORLD_CHAT = generalConfig.getBoolean("WorldChatEnabled", true); MINIMUM_CHAT_LEVEL = generalConfig.getInt("MinimumChatLevel", 20); ALLOW_WAREHOUSE = generalConfig.getBoolean("AllowWarehouse", true); - WAREHOUSE_CACHE = generalConfig.getBoolean("WarehouseCache", false); - WAREHOUSE_CACHE_TIME = generalConfig.getInt("WarehouseCacheTime", 15); ALLOW_REFUND = generalConfig.getBoolean("AllowRefund", true); ALLOW_MAIL = generalConfig.getBoolean("AllowMail", true); ALLOW_ATTACHMENTS = generalConfig.getBoolean("AllowAttachments", true); diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java deleted file mode 100644 index 0d17397987..0000000000 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/cache/WarehouseCacheManager.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 . - */ -package org.l2jmobius.gameserver.cache; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.l2jmobius.Config; -import org.l2jmobius.commons.threads.ThreadPool; -import org.l2jmobius.gameserver.model.actor.Player; - -/** - * @author -Nemesiss- - */ -public class WarehouseCacheManager -{ - protected static final Map CACHED_WH = new ConcurrentHashMap<>(); - protected static final long CACHE_TIME = Config.WAREHOUSE_CACHE_TIME * 60000; - - protected WarehouseCacheManager() - { - ThreadPool.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000); - } - - public void addCacheTask(Player pc) - { - CACHED_WH.put(pc, System.currentTimeMillis()); - } - - public void remCacheTask(Player pc) - { - CACHED_WH.remove(pc); - } - - private class CacheScheduler implements Runnable - { - public CacheScheduler() - { - } - - @Override - public void run() - { - final long cTime = System.currentTimeMillis(); - for (Entry entry : CACHED_WH.entrySet()) - { - if ((cTime - entry.getValue().longValue()) > CACHE_TIME) - { - final Player player = entry.getKey(); - player.clearWarehouse(); - CACHED_WH.remove(player); - } - } - } - } - - public static WarehouseCacheManager getInstance() - { - return SingletonHolder.INSTANCE; - } - - private static class SingletonHolder - { - protected static final WarehouseCacheManager INSTANCE = new WarehouseCacheManager(); - } -} diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Player.java index c4b49f16ee..6fdc4bbe0f 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -58,7 +58,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.PlayerAI; import org.l2jmobius.gameserver.ai.SummonAI; import org.l2jmobius.gameserver.cache.RelationCache; -import org.l2jmobius.gameserver.cache.WarehouseCacheManager; import org.l2jmobius.gameserver.communitybbs.BB.Forum; import org.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager; import org.l2jmobius.gameserver.data.ItemTable; @@ -644,7 +643,7 @@ public class Player extends Playable private final PlayerInventory _inventory = new PlayerInventory(this); private final PlayerFreight _freight = new PlayerFreight(this); - private PlayerWarehouse _warehouse; + private final PlayerWarehouse _warehouse = new PlayerWarehouse(this); private PlayerRefund _refund; private PrivateStoreType _privateStoreType = PrivateStoreType.NONE; private TradeList _activeTradeList; @@ -3139,36 +3138,15 @@ public class Player extends Playable } /** - * @return the PcWarehouse object of the Player. + * @return the PlayerWarehouse object of the Player. */ public PlayerWarehouse getWarehouse() { - if (_warehouse == null) - { - _warehouse = new PlayerWarehouse(this); - _warehouse.restore(); - } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().addCacheTask(this); - } return _warehouse; } /** - * Free memory used by Warehouse - */ - public void clearWarehouse() - { - if (_warehouse != null) - { - _warehouse.deleteMe(); - } - _warehouse = null; - } - - /** - * @return the PcFreight object of the Player. + * @return the PlayerFreight object of the Player. */ public PlayerFreight getFreight() { @@ -7029,11 +7007,8 @@ public class Player extends Playable // Retrieve from the database all items of this Player and add them to _inventory player.getInventory().restore(); + player.getWarehouse().restore(); player.getFreight().restore(); - if (!Config.WAREHOUSE_CACHE) - { - player.getWarehouse(); - } player.restoreItemReuse(); @@ -11694,16 +11669,12 @@ public class Player extends Playable // Update database with items in its warehouse and remove them from the world try { - clearWarehouse(); + getWarehouse().deleteMe(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "deleteMe()", e); } - if (Config.WAREHOUSE_CACHE) - { - WarehouseCacheManager.getInstance().remCacheTask(this); - } try {