Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java =================================================================== --- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (revision 1850) +++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (working copy) @@ -1965,39 +1965,7 @@ { _spawn = spawn; } - - - /** - * Remove the L2NpcInstance from the world and update its spawn object (for a complete removal use the deleteMe method).

- * - * Actions :

- *
  • Remove the L2NpcInstance from the world when the decay task is launched
  • - *
  • Decrease its spawn counter
  • - *
  • Manage Siege task (killFlag, killCT)


  • - * - * Caution : This method DOESN'T REMOVE the object from _allObjects of L2World
    - * Caution : This method DOESN'T SEND Server->Client packets to players

    - * - */ - public void onDecay() - { - // Manage Life Control Tower - if (this instanceof L2ControlTowerInstance) - ((L2ControlTowerInstance)this).onDeath(); - // Remove the L2NpcInstance from the world when the decay task is launched - super.onDecay(); - - // Decrease its spawn counter - if (_spawn != null) - _spawn.decreaseCount(this); - - // Reset the _decayTask for this L2NpcInstance - if (_decayTask != null) - _decayTask.cancel(false); - _decayTask = null; - } - /** * Remove PROPERLY the L2NpcInstance from the world.

    * @@ -2035,13 +2003,45 @@ return this.getTemplate().name; } + /** + * Remove the L2NpcInstance from the world and update its spawn object (for a complete removal use the deleteMe method).

    + * + * Actions :

    + *
  • Remove the L2NpcInstance from the world when the decay task is launched
  • + *
  • Decrease its spawn counter
  • + *
  • Manage Siege task (killFlag, killCT)


  • + * + * Caution : This method DOESN'T REMOVE the object from _allObjects of L2World
    + * Caution : This method DOESN'T SEND Server->Client packets to players

    + * + */ public void endDecayTask() { - if (_decayTask == null) - return; - - _decayTask.cancel(true); - _decayTask = null; - this.onDecay(); + // Manage Life Control Tower + if (this instanceof L2ControlTowerInstance) + ((L2ControlTowerInstance)this).onDeath(); + + // Remove the L2NpcInstance from the world when the decay task is launched + super.onDecay(); + + // Decrease its spawn counter + if (_spawn != null) + _spawn.decreaseCount(this); + + synchronized(_decayTask) + { + // Reset the _decayTask for this L2NpcInstance + while (!_decayTask.isDone()) + { + try + { + wait(); + } + catch (InterruptedException e) {} + } + _decayTask.cancel(false); + _decayTask = null; + DecayTaskManager.getInstance().cancelDecayTask(this); + } } }