Prevent flood from container items.
This commit is contained in:
		@@ -569,10 +569,9 @@ public class Player extends Playable
 | 
			
		||||
	private final PlayerFreight _freight = new PlayerFreight(this);
 | 
			
		||||
	private PlayerWarehouse _warehouse;
 | 
			
		||||
	private PlayerRefund _refund;
 | 
			
		||||
	
 | 
			
		||||
	private PrivateStoreType _privateStoreType = PrivateStoreType.NONE;
 | 
			
		||||
	
 | 
			
		||||
	private TradeList _activeTradeList;
 | 
			
		||||
	private boolean _isUsingContainerItem;
 | 
			
		||||
	private ItemContainer _activeWarehouse;
 | 
			
		||||
	private Map<Integer, ManufactureItem> _manufactureItems;
 | 
			
		||||
	private String _storeName = "";
 | 
			
		||||
@@ -5571,6 +5570,16 @@ public class Player extends Playable
 | 
			
		||||
		return _activeWarehouse;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean isUsingContainerItem()
 | 
			
		||||
	{
 | 
			
		||||
		return _isUsingContainerItem;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setUsingContainerItem(boolean value)
 | 
			
		||||
	{
 | 
			
		||||
		_isUsingContainerItem = value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Select the TradeList to be used in next activity.
 | 
			
		||||
	 * @param tradeList
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,6 @@ import org.l2jmobius.gameserver.util.Util;
 | 
			
		||||
public class PlayerStat extends PlayableStat
 | 
			
		||||
{
 | 
			
		||||
	private long _startingXp;
 | 
			
		||||
	/** Player's maximum talisman count. */
 | 
			
		||||
	private final AtomicInteger _talismanSlots = new AtomicInteger();
 | 
			
		||||
	private boolean _cloakSlot = false;
 | 
			
		||||
	private int _vitalityPoints = 0;
 | 
			
		||||
@@ -708,7 +707,7 @@ public class PlayerStat extends PlayableStat
 | 
			
		||||
	@Override
 | 
			
		||||
	public void recalculateStats(boolean broadcast)
 | 
			
		||||
	{
 | 
			
		||||
		if (!getActiveChar().isChangingClass())
 | 
			
		||||
		if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
 | 
			
		||||
		{
 | 
			
		||||
			super.recalculateStats(broadcast);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ import java.util.LinkedList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
import java.util.concurrent.ScheduledFuture;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
import java.util.function.Predicate;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
@@ -33,6 +34,7 @@ import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
import org.l2jmobius.commons.database.DatabaseFactory;
 | 
			
		||||
import org.l2jmobius.commons.threads.ThreadPool;
 | 
			
		||||
import org.l2jmobius.commons.util.CommonUtil;
 | 
			
		||||
import org.l2jmobius.gameserver.cache.PaperdollCache;
 | 
			
		||||
import org.l2jmobius.gameserver.data.ItemTable;
 | 
			
		||||
@@ -75,6 +77,8 @@ public abstract class Inventory extends ItemContainer
 | 
			
		||||
{
 | 
			
		||||
	protected static final Logger LOGGER = Logger.getLogger(Inventory.class.getName());
 | 
			
		||||
	
 | 
			
		||||
	private ScheduledFuture<?> _containerItemTask;
 | 
			
		||||
	
 | 
			
		||||
	public interface PaperdollListener
 | 
			
		||||
	{
 | 
			
		||||
		void notifyEquiped(int slot, Item inst, Inventory inventory);
 | 
			
		||||
@@ -1901,10 +1905,12 @@ public abstract class Inventory extends ItemContainer
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_L_BRACELET)
 | 
			
		||||
		{
 | 
			
		||||
			pdollSlot = PAPERDOLL_LBRACELET;
 | 
			
		||||
			containerItemCheck();
 | 
			
		||||
		}
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_R_BRACELET)
 | 
			
		||||
		{
 | 
			
		||||
			pdollSlot = PAPERDOLL_RBRACELET;
 | 
			
		||||
			containerItemCheck();
 | 
			
		||||
		}
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_DECO)
 | 
			
		||||
		{
 | 
			
		||||
@@ -1917,6 +1923,7 @@ public abstract class Inventory extends ItemContainer
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_BROOCH)
 | 
			
		||||
		{
 | 
			
		||||
			pdollSlot = PAPERDOLL_BROOCH;
 | 
			
		||||
			containerItemCheck();
 | 
			
		||||
		}
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_BROOCH_JEWEL)
 | 
			
		||||
		{
 | 
			
		||||
@@ -1929,6 +1936,7 @@ public abstract class Inventory extends ItemContainer
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_ARTIFACT_BOOK)
 | 
			
		||||
		{
 | 
			
		||||
			pdollSlot = PAPERDOLL_ARTIFACT_BOOK;
 | 
			
		||||
			containerItemCheck();
 | 
			
		||||
		}
 | 
			
		||||
		else if (slot == ItemTemplate.SLOT_ARTIFACT)
 | 
			
		||||
		{
 | 
			
		||||
@@ -1951,6 +1959,26 @@ public abstract class Inventory extends ItemContainer
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Avoid flood from container items.
 | 
			
		||||
	 */
 | 
			
		||||
	private void containerItemCheck()
 | 
			
		||||
	{
 | 
			
		||||
		final Creature owner = getOwner();
 | 
			
		||||
		if ((owner != null) && owner.isPlayer() && (_containerItemTask == null))
 | 
			
		||||
		{
 | 
			
		||||
			owner.getActingPlayer().setUsingContainerItem(true);
 | 
			
		||||
			_containerItemTask = ThreadPool.schedule(() ->
 | 
			
		||||
			{
 | 
			
		||||
				owner.getActingPlayer().setUsingContainerItem(false);
 | 
			
		||||
				owner.getStat().recalculateStats(true);
 | 
			
		||||
				owner.updateAbnormalVisualEffects();
 | 
			
		||||
				owner.getActingPlayer().sendSkillList();
 | 
			
		||||
				_containerItemTask = null;
 | 
			
		||||
			}, 100);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Equips item and returns list of alterations<br>
 | 
			
		||||
	 * <b>If you don't need return value use {@link Inventory#equipItem(Item)} instead</b>
 | 
			
		||||
 
 | 
			
		||||
@@ -229,8 +229,8 @@ public class GameClient extends ChannelInboundHandler<GameClient>
 | 
			
		||||
		
 | 
			
		||||
		if (_player != null)
 | 
			
		||||
		{
 | 
			
		||||
			// Avoid flood from class change.
 | 
			
		||||
			if (_player.isChangingClass() && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
 | 
			
		||||
			// Avoid flood from class change or container items.
 | 
			
		||||
			if ((_player.isChangingClass() || _player.isUsingContainerItem()) && ((packet instanceof SkillList) || (packet instanceof AcquireSkillList) || (packet instanceof ExUserInfoAbnormalVisualEffect) || (packet instanceof AbnormalStatusUpdate) || (packet instanceof ExAbnormalStatusUpdateFromTarget)))
 | 
			
		||||
			{
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user