Precautionary cancel NPC quest timers on decay.

This commit is contained in:
MobiusDevelopment
2020-03-31 11:13:30 +00:00
parent 39d35b111f
commit 4ed01c5fba
34 changed files with 765 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -80,6 +81,7 @@ import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
import org.l2jmobius.gameserver.model.variables.NpcVariables; import org.l2jmobius.gameserver.model.variables.NpcVariables;
@@ -157,6 +159,8 @@ public class Npc extends Creature
/** Map of summoned NPCs by this NPC. */ /** Map of summoned NPCs by this NPC. */
private Map<Integer, Npc> _summonedNpcs = null; private Map<Integer, Npc> _summonedNpcs = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Creates a NPC. * Creates a NPC.
* @param template the NPC template * @param template the NPC template
@@ -1323,6 +1327,9 @@ public class Npc extends Creature
((Npc) summoner).removeSummonedNpc(getObjectId()); ((Npc) summoner).removeSummonedNpc(getObjectId());
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -2052,4 +2059,32 @@ public class Npc extends Creature
{ {
return Config.SHOP_MIN_RANGE_FROM_NPC; return Config.SHOP_MIN_RANGE_FROM_NPC;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -80,6 +81,7 @@ import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
import org.l2jmobius.gameserver.model.variables.NpcVariables; import org.l2jmobius.gameserver.model.variables.NpcVariables;
@@ -157,6 +159,8 @@ public class Npc extends Creature
/** Map of summoned NPCs by this NPC. */ /** Map of summoned NPCs by this NPC. */
private Map<Integer, Npc> _summonedNpcs = null; private Map<Integer, Npc> _summonedNpcs = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Creates a NPC. * Creates a NPC.
* @param template the NPC template * @param template the NPC template
@@ -1323,6 +1327,9 @@ public class Npc extends Creature
((Npc) summoner).removeSummonedNpc(getObjectId()); ((Npc) summoner).removeSummonedNpc(getObjectId());
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -2052,4 +2059,32 @@ public class Npc extends Creature
{ {
return Config.SHOP_MIN_RANGE_FROM_NPC; return Config.SHOP_MIN_RANGE_FROM_NPC;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -78,6 +79,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -157,6 +159,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1148,6 +1152,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1866,4 +1873,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -78,6 +79,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -157,6 +159,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1148,6 +1152,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1866,4 +1873,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -78,6 +79,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -157,6 +159,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1148,6 +1152,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1866,4 +1873,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);

View File

@@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.model.actor; package org.l2jmobius.gameserver.model.actor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -77,6 +78,7 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.Weapon; import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad; import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.quest.QuestTimer;
import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
import org.l2jmobius.gameserver.model.stats.Formulas; import org.l2jmobius.gameserver.model.stats.Formulas;
@@ -156,6 +158,8 @@ public class Npc extends Creature
/** Contains information about local tax payments. */ /** Contains information about local tax payments. */
private TaxZone _taxZone = null; private TaxZone _taxZone = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
/** /**
* Constructor of NpcInstance (use Creature constructor).<br> * Constructor of NpcInstance (use Creature constructor).<br>
* <br> * <br>
@@ -1136,6 +1140,9 @@ public class Npc extends Creature
instance.removeNpc(this); instance.removeNpc(this);
} }
// Stop quest timers
stopQuestTimers();
// Clear script value // Clear script value
_scriptValue = 0; _scriptValue = 0;
} }
@@ -1854,4 +1861,32 @@ public class Npc extends Creature
{ {
return _raidStatus; return _raidStatus;
} }
public void addQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.add(questTimer);
}
}
public void removeQuestTimer(QuestTimer questTimer)
{
synchronized (_questTimers)
{
_questTimers.remove(questTimer);
}
}
public void stopQuestTimers()
{
synchronized (_questTimers)
{
for (QuestTimer timer : _questTimers)
{
timer.cancel();
}
_questTimers.clear();
}
}
} }

View File

@@ -48,6 +48,11 @@ public class QuestTimer
_scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task
} }
if (npc != null)
{
npc.addQuestTimer(this);
}
if (player != null) if (player != null)
{ {
player.addQuestTimer(this); player.addQuestTimer(this);
@@ -62,6 +67,11 @@ public class QuestTimer
_scheduler = null; _scheduler = null;
} }
if (_npc != null)
{
_npc.removeQuestTimer(this);
}
if (_player != null) if (_player != null)
{ {
_player.removeQuestTimer(this); _player.removeQuestTimer(this);