Prevent flood from container items.
This commit is contained in:
		| @@ -565,10 +565,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 = ""; | ||||
| @@ -5601,6 +5600,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 | ||||
|   | ||||
| @@ -52,7 +52,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; | ||||
| @@ -665,7 +664,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; | ||||
| @@ -73,6 +75,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); | ||||
| @@ -1704,6 +1708,7 @@ public abstract class Inventory extends ItemContainer | ||||
| 			case ItemTemplate.SLOT_R_BRACELET: | ||||
| 			{ | ||||
| 				pdollSlot = PAPERDOLL_RBRACELET; | ||||
| 				containerItemCheck(); | ||||
| 				break; | ||||
| 			} | ||||
| 			case ItemTemplate.SLOT_DECO: | ||||
| @@ -1719,6 +1724,7 @@ public abstract class Inventory extends ItemContainer | ||||
| 			case ItemTemplate.SLOT_BROOCH: | ||||
| 			{ | ||||
| 				pdollSlot = PAPERDOLL_BROOCH; | ||||
| 				containerItemCheck(); | ||||
| 				break; | ||||
| 			} | ||||
| 			case ItemTemplate.SLOT_BROOCH_JEWEL: | ||||
| @@ -1744,6 +1750,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
	 MobiusDevelopment
					MobiusDevelopment