Removal of Warehouse Cache.
This commit is contained in:
parent
224d1b3757
commit
9df3988d2e
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> _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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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<Integer> _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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> _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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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<Integer> _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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<Player, Long> 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<Player, Long> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user