Precautionary cancel player tasks and quest timers on disconnect.

This commit is contained in:
MobiusDevelopment
2020-03-31 11:01:32 +00:00
parent 5fe7e70c08
commit 39d35b111f
103 changed files with 2875 additions and 1022 deletions
@@ -248,6 +248,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -617,6 +618,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -780,7 +783,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -810,29 +813,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -846,6 +846,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1022,9 +1024,11 @@ public class PlayerInstance extends Playable
result |= RelationChanged.RELATION_ATTACKER;
}
}
if ((clan != null) && (targetClan != null) && (target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
if ((clan != null) && (targetClan != null))
{
final ClanWar war = clan.getWarWith(target.getClan().getId());
if ((target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
{
ClanWar war = clan.getWarWith(target.getClan().getId());
if (war != null)
{
switch (war.getState())
@@ -1044,6 +1048,7 @@ public class PlayerInstance extends Playable
}
}
}
}
if (_handysBlockCheckerEventArena != -1)
{
result |= RelationChanged.RELATION_INSIEGE;
@@ -1640,7 +1645,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1671,12 +1676,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3276,17 +3277,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4755,11 +4752,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4770,11 +4763,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4785,11 +4774,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -6768,17 +6753,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6794,9 +6773,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8134,7 +8110,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8220,11 +8200,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8843,8 +8826,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10297,7 +10278,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10746,6 +10727,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -11364,14 +11346,11 @@ public class PlayerInstance extends Playable
percent *= getStat().getValue(Stat.REDUCE_DEATH_PENALTY_BY_PVP, 1);
}
if ((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent)))
{
if (!killer.isPlayable() || (getReputation() < 0))
if (((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent))) && (!killer.isPlayable() || (getReputation() < 0)))
{
increaseShilensBreathDebuff();
}
}
}
public void increaseShilensBreathDebuff()
{
@@ -13679,9 +13658,6 @@ public class PlayerInstance extends Playable
sendPacket(new ExUserInfoInvenWeight(this));
}
/**
* @param open
*/
public void sendItemList(boolean open)
{
sendPacket(new ItemList(this, open));
@@ -13787,6 +13763,118 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -165,7 +165,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1734,21 +1734,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2164,14 +2164,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -250,6 +250,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -619,6 +620,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -782,7 +785,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -812,29 +815,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -852,6 +852,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1028,9 +1030,11 @@ public class PlayerInstance extends Playable
result |= RelationChanged.RELATION_ATTACKER;
}
}
if ((clan != null) && (targetClan != null) && (target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
if ((clan != null) && (targetClan != null))
{
final ClanWar war = clan.getWarWith(target.getClan().getId());
if ((target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
{
ClanWar war = clan.getWarWith(target.getClan().getId());
if (war != null)
{
switch (war.getState())
@@ -1050,6 +1054,7 @@ public class PlayerInstance extends Playable
}
}
}
}
if (_handysBlockCheckerEventArena != -1)
{
result |= RelationChanged.RELATION_INSIEGE;
@@ -1646,7 +1651,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1677,12 +1682,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3282,17 +3283,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4761,11 +4758,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4776,11 +4769,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4791,11 +4780,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -6775,17 +6760,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6801,9 +6780,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8141,7 +8117,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8227,11 +8207,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8850,8 +8833,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10304,7 +10285,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10753,6 +10734,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -11371,14 +11353,11 @@ public class PlayerInstance extends Playable
percent *= getStat().getValue(Stat.REDUCE_DEATH_PENALTY_BY_PVP, 1);
}
if ((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent)))
{
if (!killer.isPlayable() || (getReputation() < 0))
if (((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent))) && (!killer.isPlayable() || (getReputation() < 0)))
{
increaseShilensBreathDebuff();
}
}
}
public void increaseShilensBreathDebuff()
{
@@ -13686,9 +13665,6 @@ public class PlayerInstance extends Playable
sendPacket(new ExUserInfoInvenWeight(this));
}
/**
* @param open
*/
public void sendItemList(boolean open)
{
sendPacket(new ItemList(this, open));
@@ -13794,6 +13770,118 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1741,21 +1741,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2417,14 +2417,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -251,6 +251,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -621,6 +622,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -784,7 +787,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -814,29 +817,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -854,6 +854,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1030,9 +1032,11 @@ public class PlayerInstance extends Playable
result |= RelationChanged.RELATION_ATTACKER;
}
}
if ((clan != null) && (targetClan != null) && (target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
if ((clan != null) && (targetClan != null))
{
final ClanWar war = clan.getWarWith(target.getClan().getId());
if ((target.getPledgeType() != Clan.SUBUNIT_ACADEMY) && (getPledgeType() != Clan.SUBUNIT_ACADEMY))
{
ClanWar war = clan.getWarWith(target.getClan().getId());
if (war != null)
{
switch (war.getState())
@@ -1052,6 +1056,7 @@ public class PlayerInstance extends Playable
}
}
}
}
if (_handysBlockCheckerEventArena != -1)
{
result |= RelationChanged.RELATION_INSIEGE;
@@ -1648,7 +1653,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1679,12 +1684,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3284,17 +3285,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4763,11 +4760,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4778,11 +4771,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4793,11 +4782,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -6777,17 +6762,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6803,9 +6782,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8143,7 +8119,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8229,11 +8209,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8852,8 +8835,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10306,7 +10287,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10755,6 +10736,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -11373,14 +11355,11 @@ public class PlayerInstance extends Playable
percent *= getStat().getValue(Stat.REDUCE_DEATH_PENALTY_BY_PVP, 1);
}
if ((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent)))
{
if (!killer.isPlayable() || (getReputation() < 0))
if (((killer.isNpc() && ((Npc) killer).getTemplate().isDeathPenalty()) || (Rnd.get(1, 100) <= ((Config.DEATH_PENALTY_CHANCE) * percent))) && (!killer.isPlayable() || (getReputation() < 0)))
{
increaseShilensBreathDebuff();
}
}
}
public void increaseShilensBreathDebuff()
{
@@ -13689,9 +13668,6 @@ public class PlayerInstance extends Playable
sendPacket(new ExUserInfoInvenWeight(this));
}
/**
* @param open
*/
public void sendItemList(boolean open)
{
sendPacket(new ItemList(this, open));
@@ -13797,6 +13773,118 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1741,21 +1741,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2417,14 +2417,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -254,6 +254,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -623,6 +624,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -790,7 +793,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -820,29 +823,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Monster Book variables
@@ -864,6 +864,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -6754,17 +6756,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6780,9 +6776,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8836,8 +8829,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10286,7 +10277,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10735,6 +10726,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13752,6 +13744,118 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1741,21 +1741,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2451,14 +2451,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -619,6 +620,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -786,7 +789,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -816,29 +819,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Monster Book variables
@@ -860,6 +860,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -6733,17 +6735,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6759,9 +6755,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8819,8 +8812,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10273,7 +10264,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10722,6 +10713,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13714,6 +13706,113 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -170,7 +170,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1750,21 +1750,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2463,14 +2463,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -619,6 +620,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -786,7 +789,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -816,29 +819,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Monster Book variables
@@ -860,6 +860,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -6733,17 +6735,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6759,9 +6755,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8819,8 +8812,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10273,7 +10264,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10725,6 +10716,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13717,6 +13709,113 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -170,7 +170,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1750,21 +1750,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2463,14 +2463,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -619,6 +620,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -786,7 +789,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -816,29 +819,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Monster Book variables
@@ -860,6 +860,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -6734,17 +6736,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6760,9 +6756,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -8820,8 +8813,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10279,7 +10270,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10731,6 +10722,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13723,6 +13715,113 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -170,7 +170,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1750,21 +1750,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2463,14 +2463,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -623,6 +624,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -786,7 +789,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -816,29 +819,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Monster Book variables
@@ -869,6 +869,8 @@ public class PlayerInstance extends Playable
private ScheduledFuture<?> _timedHuntingZoneFinishTask = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -8788,8 +8790,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10690,6 +10690,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13682,6 +13683,128 @@ public class PlayerInstance extends Playable
return isInParty() ? (_party.isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_autoPlayTask != null) && !_autoPlayTask.isDone() && !_autoPlayTask.isCancelled())
{
_autoPlayTask.cancel(false);
_autoPlayTask = null;
}
if ((_autoUseTask != null) && !_autoUseTask.isDone() && !_autoUseTask.isCancelled())
{
_autoUseTask.cancel(false);
_autoUseTask = null;
}
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
{
_timedHuntingZoneFinishTask.cancel(false);
_timedHuntingZoneFinishTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public boolean isTrueHero()
{
return _trueHero;
@@ -13699,7 +13822,15 @@ public class PlayerInstance extends Playable
public int getFactionLevel(Faction faction)
{
return 5;
final int currentPoints = getFactionPoints(faction);
for (int i = 0; i < faction.getLevelCount(); i++)
{
if (currentPoints <= faction.getPointsOfLevel(i))
{
return i;
}
}
return 0;
}
public float getFactionProgress(Faction faction)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -170,7 +170,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1750,21 +1750,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2463,14 +2463,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -94,9 +94,7 @@ public class Disconnection
// Stop player tasks.
if (_player != null)
{
_player.stopTimedHuntingZoneTask();
_player.stopAutoPlayTask();
_player.stopAutoUseTask();
_player.stopAllTasks();
}
// Anti Feed
@@ -239,6 +239,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -490,7 +491,7 @@ public class PlayerInstance extends Playable
private Vehicle _vehicle = null;
private Location _inVehiclePosition;
public ScheduledFuture<?> _taskforfish;
public ScheduledFuture<?> _taskForFish;
private MountType _mountType = MountType.NONE;
private int _mountNpcId;
private int _mountLevel;
@@ -608,6 +609,8 @@ public class PlayerInstance extends Playable
// TODO: This needs to be better integrated and saved/loaded
private final Radar _radar;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Party matching
// private int _partymatching = 0;
private int _partyroom = 0;
@@ -792,7 +795,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -860,30 +863,27 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
return;
}
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Character UI
@@ -906,6 +906,8 @@ public class PlayerInstance extends Playable
private boolean _hasCharmOfCourage = false;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -7111,9 +7113,6 @@ public class PlayerInstance extends Playable
return player;
}
/**
* @return
*/
public Forum getMail()
{
if (_forumMail == null)
@@ -7129,17 +7128,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -7155,9 +7148,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -9460,8 +9450,6 @@ public class PlayerInstance extends Playable
_activeSoulShots.clear();
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -11630,17 +11618,17 @@ public class PlayerInstance extends Playable
public void stopLookingForFishTask()
{
if (_taskforfish == null)
if (_taskForFish == null)
{
return;
}
_taskforfish.cancel(false);
_taskforfish = null;
_taskForFish.cancel(false);
_taskForFish = null;
}
public void startLookingForFishTask()
{
if (!isDead() && (_taskforfish == null))
if (!isDead() && (_taskForFish == null))
{
int checkDelay = 0;
boolean isNoob = false;
@@ -11663,7 +11651,7 @@ public class PlayerInstance extends Playable
checkDelay = _fish.getGutsCheckTime() * 66;
}
}
_taskforfish = ThreadPool.scheduleAtFixedRate(new LookingForFishTask(this, _fish.getStartCombatTime(), _fish.getFishGuts(), _fish.getFishGroup(), isNoob, isUpperGrade), 10000, checkDelay);
_taskForFish = ThreadPool.scheduleAtFixedRate(new LookingForFishTask(this, _fish.getStartCombatTime(), _fish.getFishGuts(), _fish.getFishGroup(), isNoob, isUpperGrade), 10000, checkDelay);
}
}
@@ -14341,4 +14329,107 @@ public class PlayerInstance extends Playable
{
removeListenerIf(EventType.ON_PLAYABLE_EXP_CHANGED, listener -> listener.getOwner() == this);
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_vitalityTask != null) && !_vitalityTask.isDone() && !_vitalityTask.isCancelled())
{
_vitalityTask.cancel(false);
_vitalityTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_taskForFish != null) && !_taskForFish.isDone() && !_taskForFish.isCancelled())
{
_taskForFish.cancel(false);
_taskForFish = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
}
@@ -448,7 +448,7 @@ public abstract class ItemContainer
item.updateDatabase();
}
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
return item;
}
@@ -555,7 +555,7 @@ public abstract class ItemContainer
if (item != null)
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -164,7 +164,7 @@ public class Mail extends ItemContainer
_items.forEach(item ->
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
});
_items.clear();
@@ -155,7 +155,7 @@ public class ItemInstance extends WorldObject
private Elementals[] _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private final DropProtection _dropProtection = new DropProtection();
@@ -1732,21 +1732,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2191,7 +2191,7 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -244,6 +244,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -509,7 +510,7 @@ public class PlayerInstance extends Playable
private Vehicle _vehicle = null;
private Location _inVehiclePosition;
public ScheduledFuture<?> _taskforfish;
public ScheduledFuture<?> _taskForFish;
private MountType _mountType = MountType.NONE;
private int _mountNpcId;
private int _mountLevel;
@@ -629,6 +630,8 @@ public class PlayerInstance extends Playable
// TODO: This needs to be better integrated and saved/loaded
private final Radar _radar;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Party matching
// private int _partymatching = 0;
private int _partyroom = 0;
@@ -811,7 +814,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -879,30 +882,27 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
return;
}
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Character UI
@@ -925,6 +925,8 @@ public class PlayerInstance extends Playable
private boolean _hasCharmOfCourage = false;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -7003,9 +7005,6 @@ public class PlayerInstance extends Playable
return player;
}
/**
* @return
*/
public Forum getMail()
{
if (_forumMail == null)
@@ -7021,17 +7020,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -7047,9 +7040,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -9344,8 +9334,6 @@ public class PlayerInstance extends Playable
_activeSoulShots.clear();
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -11523,17 +11511,17 @@ public class PlayerInstance extends Playable
public void stopLookingForFishTask()
{
if (_taskforfish == null)
if (_taskForFish == null)
{
return;
}
_taskforfish.cancel(false);
_taskforfish = null;
_taskForFish.cancel(false);
_taskForFish = null;
}
public void startLookingForFishTask()
{
if (!isDead() && (_taskforfish == null))
if (!isDead() && (_taskForFish == null))
{
int checkDelay = 0;
boolean isNoob = false;
@@ -11556,7 +11544,7 @@ public class PlayerInstance extends Playable
checkDelay = _fish.getGutsCheckTime() * 66;
}
}
_taskforfish = ThreadPool.scheduleAtFixedRate(new LookingForFishTask(this, _fish.getStartCombatTime(), _fish.getFishGuts(), _fish.getFishGroup(), isNoob, isUpperGrade), 10000, checkDelay);
_taskForFish = ThreadPool.scheduleAtFixedRate(new LookingForFishTask(this, _fish.getStartCombatTime(), _fish.getFishGuts(), _fish.getFishGroup(), isNoob, isUpperGrade), 10000, checkDelay);
}
}
@@ -14435,4 +14423,107 @@ public class PlayerInstance extends Playable
{
removeListenerIf(EventType.ON_PLAYABLE_EXP_CHANGED, listener -> listener.getOwner() == this);
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_vitalityTask != null) && !_vitalityTask.isDone() && !_vitalityTask.isCancelled())
{
_vitalityTask.cancel(false);
_vitalityTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_taskForFish != null) && !_taskForFish.isDone() && !_taskForFish.isCancelled())
{
_taskForFish.cancel(false);
_taskForFish = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
}
@@ -448,7 +448,7 @@ public abstract class ItemContainer
item.updateDatabase();
}
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
return item;
}
@@ -555,7 +555,7 @@ public abstract class ItemContainer
if (item != null)
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -164,7 +164,7 @@ public class Mail extends ItemContainer
_items.forEach(item ->
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
});
_items.clear();
@@ -155,7 +155,7 @@ public class ItemInstance extends WorldObject
private Elementals[] _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private final DropProtection _dropProtection = new DropProtection();
@@ -1732,21 +1732,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2191,7 +2191,7 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -250,6 +250,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -494,6 +495,7 @@ public class PlayerInstance extends Playable
/** Duel */
private boolean _isInDuel = false;
private boolean _startingDuel = false;
private int _duelState = Duel.DUELSTATE_NODUEL;
private int _duelId = 0;
private SystemMessageId _noDuelReason = SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL;
@@ -615,6 +617,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -777,7 +781,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -807,29 +811,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -847,6 +848,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1621,7 +1624,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1652,12 +1655,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3251,17 +3250,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4730,11 +4725,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4745,11 +4736,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4760,11 +4747,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5151,9 +5134,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6743,17 +6724,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6769,9 +6744,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7799,9 +7771,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7891,9 +7861,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8094,7 +8062,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8180,11 +8152,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8796,8 +8771,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -9186,6 +9159,11 @@ public class PlayerInstance extends Playable
return _isInDuel;
}
public void setStartingDuel()
{
_startingDuel = true;
}
public int getDuelId()
{
return _duelId;
@@ -9224,6 +9202,7 @@ public class PlayerInstance extends Playable
_duelState = Duel.DUELSTATE_NODUEL;
_duelId = 0;
}
_startingDuel = false;
}
/**
@@ -9255,7 +9234,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_S_HP_OR_MP_IS_BELOW_50;
return false;
}
if (_isInDuel)
if (_isInDuel || _startingDuel)
{
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_ALREADY_ENGAGED_IN_A_DUEL;
return false;
@@ -10240,7 +10219,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10689,6 +10668,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -11832,7 +11812,7 @@ public class PlayerInstance extends Playable
sendPacket(SystemMessageId.YOU_CANNOT_USE_MY_TELEPORTS_WHILE_PARTICIPATING_A_LARGE_SCALE_BATTLE_SUCH_AS_A_CASTLE_SIEGE_FORTRESS_SIEGE_OR_CLAN_HALL_SIEGE);
return false;
}
else if (_isInDuel)
else if (_isInDuel || _startingDuel)
{
sendPacket(SystemMessageId.YOU_CANNOT_USE_MY_TELEPORTS_DURING_A_DUEL);
return false;
@@ -13607,6 +13587,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -83,6 +83,23 @@ public class Duel
_playerA = playerA;
_playerB = playerB;
_partyDuel = partyDuel == 1;
if (_partyDuel)
{
for (PlayerInstance member : _playerA.getParty().getMembers())
{
member.setStartingDuel();
}
for (PlayerInstance member : _playerB.getParty().getMembers())
{
member.setStartingDuel();
}
}
else
{
_playerA.setStartingDuel();
_playerB.setStartingDuel();
}
_duelEndTime = Calendar.getInstance();
_duelEndTime.add(Calendar.SECOND, _partyDuel ? PARTY_DUEL_DURATION : PLAYER_DUEL_DURATION);
setFinished(false);
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -250,6 +250,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -616,6 +617,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -778,7 +781,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -808,29 +811,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -848,6 +848,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1622,7 +1624,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1653,12 +1655,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3252,17 +3250,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4731,11 +4725,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4746,11 +4736,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4761,11 +4747,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5152,9 +5134,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6744,17 +6724,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6770,9 +6744,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7800,9 +7771,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7892,9 +7861,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8095,7 +8062,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8181,11 +8152,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8797,8 +8771,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10247,7 +10219,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10696,6 +10668,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13614,6 +13587,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -249,6 +249,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -614,6 +615,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -776,7 +779,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -806,29 +809,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -846,6 +846,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1620,7 +1622,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1651,12 +1653,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3250,17 +3248,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4716,11 +4710,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4731,11 +4721,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4746,11 +4732,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5137,9 +5119,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6730,17 +6710,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6756,9 +6730,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7786,9 +7757,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7878,9 +7847,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8081,7 +8048,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8167,11 +8138,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8783,8 +8757,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10233,7 +10205,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10682,6 +10654,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13599,6 +13572,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -621,6 +622,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -783,7 +786,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -813,29 +816,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -856,6 +856,8 @@ public class PlayerInstance extends Playable
private ElementalSpirit[] _spirits;
private ElementalType _activeElementalSpiritType;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1630,7 +1632,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1661,12 +1663,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3261,17 +3259,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4727,11 +4721,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4742,11 +4732,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4757,11 +4743,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5148,9 +5130,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6746,17 +6726,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6772,9 +6746,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7813,9 +7784,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7905,9 +7874,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8108,7 +8075,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8194,11 +8165,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8810,8 +8784,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10260,7 +10232,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10712,6 +10684,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13641,6 +13614,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -253,6 +253,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -621,6 +622,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -783,7 +786,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -813,29 +816,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -856,6 +856,8 @@ public class PlayerInstance extends Playable
private ElementalSpirit[] _spirits;
private ElementalType _activeElementalSpiritType;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1630,7 +1632,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1661,12 +1663,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3261,17 +3259,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4727,11 +4721,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4742,11 +4732,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4757,11 +4743,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5148,9 +5130,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6746,17 +6726,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6772,9 +6746,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7813,9 +7784,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7905,9 +7874,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8108,7 +8075,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8194,11 +8165,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8810,8 +8784,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10260,7 +10232,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10712,6 +10684,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13641,6 +13614,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -91,6 +91,12 @@ public class Disconnection
_client = getClient(client, player);
_player = getActiveChar(client, player);
// Stop player tasks.
if (_player != null)
{
_player.stopAllTasks();
}
// Anti Feed
AntiFeedManager.getInstance().onDisconnect(_client);
@@ -254,6 +254,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -624,6 +625,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -784,7 +787,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -814,29 +817,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -866,6 +866,8 @@ public class PlayerInstance extends Playable
private ScheduledFuture<?> _timedHuntingZoneFinishTask = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1640,7 +1642,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1671,12 +1673,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3176,17 +3174,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4642,11 +4636,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4657,11 +4647,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4672,11 +4658,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5063,9 +5045,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6657,17 +6637,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6683,9 +6657,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7724,9 +7695,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7816,9 +7785,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8020,7 +7987,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8106,11 +8077,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8722,8 +8696,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10610,6 +10582,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13561,6 +13534,133 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_autoPlayTask != null) && !_autoPlayTask.isDone() && !_autoPlayTask.isCancelled())
{
_autoPlayTask.cancel(false);
_autoPlayTask = null;
}
if ((_autoUseTask != null) && !_autoUseTask.isDone() && !_autoUseTask.isCancelled())
{
_autoUseTask.cancel(false);
_autoUseTask = null;
}
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isDone() && !_timedHuntingZoneFinishTask.isCancelled())
{
_timedHuntingZoneFinishTask.cancel(false);
_timedHuntingZoneFinishTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
@@ -167,7 +167,7 @@ public class ItemInstance extends WorldObject
private Map<AttributeType, AttributeHolder> _elementals = null;
private ScheduledFuture<?> itemLootShedule = null;
private ScheduledFuture<?> _itemLootShedule = null;
private ScheduledFuture<?> _lifeTimeTask;
private ScheduledFuture<?> _appearanceLifeTimeTask;
@@ -1739,21 +1739,21 @@ public class ItemInstance extends WorldObject
public void resetOwnerTimer()
{
if (itemLootShedule != null)
if (_itemLootShedule != null)
{
itemLootShedule.cancel(true);
itemLootShedule = null;
_itemLootShedule.cancel(true);
_itemLootShedule = null;
}
}
public void setItemLootShedule(ScheduledFuture<?> sf)
{
itemLootShedule = sf;
_itemLootShedule = sf;
}
public ScheduledFuture<?> getItemLootShedule()
{
return itemLootShedule;
return _itemLootShedule;
}
public void setProtected(boolean isProtected)
@@ -2449,14 +2449,13 @@ public class ItemInstance extends WorldObject
{
}
public void deleteMe()
public void stopAllTasks()
{
if ((_lifeTimeTask != null) && !_lifeTimeTask.isDone())
{
_lifeTimeTask.cancel(false);
_lifeTimeTask = null;
}
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
{
_appearanceLifeTimeTask.cancel(false);
@@ -47,6 +47,11 @@ public class QuestTimer
{
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
}
if (player != null)
{
player.addQuestTimer(this);
}
}
public void cancel()
@@ -57,6 +62,11 @@ public class QuestTimer
_scheduler = null;
}
if (_player != null)
{
_player.removeQuestTimer(this);
}
_quest.removeQuestTimer(this);
}
@@ -94,9 +94,7 @@ public class Disconnection
// Stop player tasks.
if (_player != null)
{
_player.stopTimedHuntingZoneTask();
_player.stopAutoPlayTask();
_player.stopAutoUseTask();
_player.stopAllTasks();
}
// Anti Feed
@@ -250,6 +250,7 @@ import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.AbnormalType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
@@ -616,6 +617,8 @@ public class PlayerInstance extends Playable
private MatchingRoom _matchingRoom;
private ScheduledFuture<?> _taskWarnUserTakeBreak;
// Clan related attributes
/** The Clan Identifier of the PlayerInstance */
private int _clanId;
@@ -780,7 +783,7 @@ public class PlayerInstance extends Playable
private volatile long _lastItemAuctionInfoRequest = 0;
private Future<?> _PvPRegTask;
private Future<?> _pvpRegTask;
private long _pvpFlagLasts;
@@ -810,29 +813,26 @@ public class PlayerInstance extends Playable
public void startPvPFlag()
{
updatePvPFlag(1);
if (_PvPRegTask == null)
if (_pvpRegTask == null)
{
_PvPRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
_pvpRegTask = ThreadPool.scheduleAtFixedRate(new PvPFlagTask(this), 1000, 1000);
}
}
public void stopPvpRegTask()
{
if (_PvPRegTask != null)
if (_pvpRegTask != null)
{
_PvPRegTask.cancel(true);
_PvPRegTask = null;
_pvpRegTask.cancel(true);
_pvpRegTask = null;
}
}
public void stopPvPFlag()
{
stopPvpRegTask();
updatePvPFlag(0);
_PvPRegTask = null;
_pvpRegTask = null;
}
// Training Camp
@@ -850,6 +850,8 @@ public class PlayerInstance extends Playable
private final Set<Integer> _whisperers = ConcurrentHashMap.newKeySet();
private final List<QuestTimer> _questTimers = new ArrayList<>();
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@@ -1624,7 +1626,7 @@ public class PlayerInstance extends Playable
public boolean isRegisteredOnThisSiegeField(int value)
{
return (_siegeSide != value) && ((_siegeSide < 81) || (_siegeSide > 89));
return (_siegeSide == value) || ((_siegeSide >= 81) && (_siegeSide <= 89));
}
public int getSiegeSide()
@@ -1655,12 +1657,8 @@ public class PlayerInstance extends Playable
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
return castle.getOwner() == null;
}
// Both are defenders, friends.
@@ -3254,17 +3252,13 @@ public class PlayerInstance extends Playable
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
// Combat Flag
else if (FortSiegeManager.getInstance().isCombat(item.getId()))
{
if (FortSiegeManager.getInstance().activateCombatFlag(this, item))
else if (FortSiegeManager.getInstance().isCombat(item.getId()) && FortSiegeManager.getInstance().activateCombatFlag(this, item))
{
final Fort fort = FortManager.getInstance().getFort(this);
fort.getSiege().announceToPlayer(new SystemMessage(SystemMessageId.C1_HAS_ACQUIRED_THE_FLAG), getName());
}
}
}
}
/**
* Adds item to Inventory and send a Server->Client InventoryUpdate packet to the PlayerInstance.
@@ -4733,11 +4727,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.HEAVY));
}
public boolean isWearingLightArmor()
@@ -4748,11 +4738,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.LIGHT));
}
public boolean isWearingMagicArmor()
@@ -4763,11 +4749,7 @@ public class PlayerInstance extends Playable
{
return true;
}
if ((armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC)))
{
return true;
}
return false;
return (armor != null) && ((_inventory.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == Item.SLOT_FULL_ARMOR) && (armor.getItemType() == ArmorType.MAGIC));
}
/**
@@ -5154,9 +5136,7 @@ public class PlayerInstance extends Playable
}
}
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.SOCIAL);
sendPacket(ui);
broadcastUserInfo(UserInfoType.SOCIAL);
checkItemRestriction();
}
@@ -6746,17 +6726,11 @@ public class PlayerInstance extends Playable
return _forumMail;
}
/**
* @param forum
*/
public void setMail(Forum forum)
{
_forumMail = forum;
}
/**
* @return
*/
public Forum getMemo()
{
if (_forumMemo == null)
@@ -6772,9 +6746,6 @@ public class PlayerInstance extends Playable
return _forumMemo;
}
/**
* @param forum
*/
public void setMemo(Forum forum)
{
_forumMemo = forum;
@@ -7802,9 +7773,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
final long remainingTime = getVariables().getLong("HennaDuration" + slot, 0) - System.currentTimeMillis();
if ((henna.getDuration() < 0) || (remainingTime > 0))
@@ -7894,9 +7863,7 @@ public class PlayerInstance extends Playable
sendPacket(new HennaInfo(this));
// Send Server->Client UserInfo packet to this PlayerInstance
final UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui);
broadcastUserInfo(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
@@ -8097,7 +8064,11 @@ public class PlayerInstance extends Playable
// Check if the attacker is in olympia and olympia start
if (attacker.isPlayer() && attacker.getActingPlayer().isInOlympiadMode())
{
return _inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId());
if (_inOlympiadMode && _OlympiadStart && (((PlayerInstance) attacker).getOlympiadGameId() == getOlympiadGameId()))
{
return true;
}
return false;
}
if (_isOnCustomEvent && (getTeam() == attacker.getTeam()))
@@ -8183,11 +8154,14 @@ public class PlayerInstance extends Playable
}
}
if ((attacker instanceof DefenderInstance) && (_clan != null))
if (attacker instanceof DefenderInstance)
{
if (_clan != null)
{
final Siege siege = SiegeManager.getInstance().getSiege(this);
return ((siege != null) && siege.checkIsAttacker(_clan));
}
}
if (attacker instanceof GuardInstance)
{
@@ -8799,8 +8773,6 @@ public class PlayerInstance extends Playable
}
}
private ScheduledFuture<?> _taskWarnUserTakeBreak;
public EnumIntBitmask<ClanPrivilege> getClanPrivileges()
{
return _clanPrivileges;
@@ -10259,7 +10231,7 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
@@ -10717,6 +10689,7 @@ public class PlayerInstance extends Playable
{
LOGGER.log(Level.SEVERE, "deleteMe()", e);
}
// Stop the HP/MP/CP Regeneration task (scheduled tasks)
try
{
@@ -13635,6 +13608,118 @@ public class PlayerInstance extends Playable
return super.getMoveType();
}
/**
* Precautionary method to end all tasks upon disconnection.
* @TODO: Rework stopAllTimers() method.
*/
public void stopAllTasks()
{
if ((_mountFeedTask != null) && !_mountFeedTask.isDone() && !_mountFeedTask.isCancelled())
{
_mountFeedTask.cancel(false);
_mountFeedTask = null;
}
if ((_dismountTask != null) && !_dismountTask.isDone() && !_dismountTask.isCancelled())
{
_dismountTask.cancel(false);
_dismountTask = null;
}
if ((_fameTask != null) && !_fameTask.isDone() && !_fameTask.isCancelled())
{
_fameTask.cancel(false);
_fameTask = null;
}
if ((_teleportWatchdog != null) && !_teleportWatchdog.isDone() && !_teleportWatchdog.isCancelled())
{
_teleportWatchdog.cancel(false);
_teleportWatchdog = null;
}
if ((_recoGiveTask != null) && !_recoGiveTask.isDone() && !_recoGiveTask.isCancelled())
{
_recoGiveTask.cancel(false);
_recoGiveTask = null;
}
if ((_chargeTask != null) && !_chargeTask.isDone() && !_chargeTask.isCancelled())
{
_chargeTask.cancel(false);
_chargeTask = null;
}
if ((_soulTask != null) && !_soulTask.isDone() && !_soulTask.isCancelled())
{
_soulTask.cancel(false);
_soulTask = null;
}
if ((_taskRentPet != null) && !_taskRentPet.isDone() && !_taskRentPet.isCancelled())
{
_taskRentPet.cancel(false);
_taskRentPet = null;
}
if ((_taskWater != null) && !_taskWater.isDone() && !_taskWater.isCancelled())
{
_taskWater.cancel(false);
_taskWater = null;
}
if ((_fallingDamageTask != null) && !_fallingDamageTask.isDone() && !_fallingDamageTask.isCancelled())
{
_fallingDamageTask.cancel(false);
_fallingDamageTask = null;
}
if ((_pvpRegTask != null) && !_pvpRegTask.isDone() && !_pvpRegTask.isCancelled())
{
_pvpRegTask.cancel(false);
_pvpRegTask = null;
}
if ((_autoSaveTask != null) && !_autoSaveTask.isDone() && !_autoSaveTask.isCancelled())
{
_autoSaveTask.cancel(false);
_autoSaveTask = null;
}
if ((_taskWarnUserTakeBreak != null) && !_taskWarnUserTakeBreak.isDone() && !_taskWarnUserTakeBreak.isCancelled())
{
_taskWarnUserTakeBreak.cancel(false);
_taskWarnUserTakeBreak = null;
}
if ((_onlineTimeUpdateTask != null) && !_onlineTimeUpdateTask.isDone() && !_onlineTimeUpdateTask.isCancelled())
{
_onlineTimeUpdateTask.cancel(false);
_onlineTimeUpdateTask = null;
}
for (Entry<Integer, ScheduledFuture<?>> entry : _hennaRemoveSchedules.entrySet())
{
final ScheduledFuture<?> task = entry.getValue();
if ((task != null) && !task.isCancelled() && !task.isDone())
{
task.cancel(false);
}
_hennaRemoveSchedules.remove(entry.getKey());
}
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
private void startOnlineTimeUpdateTask()
{
if (_onlineTimeUpdateTask != null)
@@ -477,7 +477,7 @@ public abstract class ItemContainer
item.updateDatabase();
refreshWeight();
item.deleteMe();
item.stopAllTasks();
}
}
return item;
@@ -590,7 +590,7 @@ public abstract class ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}
}
@@ -149,7 +149,7 @@ public class Mail extends ItemContainer
for (ItemInstance item : _items.values())
{
item.updateDatabase(true);
item.deleteMe();
item.stopAllTasks();
World.getInstance().removeObject(item);
}

Some files were not shown because too many files have changed in this diff Show More