Removal of Warehouse Cache.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user