Prevent flood from container items.

This commit is contained in:
MobiusDevelopment
2022-02-03 06:24:01 +00:00
parent 6d1d12f8ec
commit 9ba9ae38af
84 changed files with 866 additions and 126 deletions

View File

@ -561,10 +561,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 = "";
@ -5597,6 +5596,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

View File

@ -51,7 +51,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;
@ -663,7 +662,7 @@ public class PlayerStat extends PlayableStat
@Override
public void recalculateStats(boolean broadcast)
{
if (!getActiveChar().isChangingClass())
if (!getActiveChar().isChangingClass() && !getActiveChar().isUsingContainerItem())
{
super.recalculateStats(broadcast);
}

View File

@ -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);
@ -1698,6 +1702,7 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_R_BRACELET:
{
pdollSlot = PAPERDOLL_RBRACELET;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_DECO:
@ -1713,6 +1718,7 @@ public abstract class Inventory extends ItemContainer
case ItemTemplate.SLOT_BROOCH:
{
pdollSlot = PAPERDOLL_BROOCH;
containerItemCheck();
break;
}
case ItemTemplate.SLOT_BROOCH_JEWEL:
@ -1738,6 +1744,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>

View File

@ -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;
}