diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java index 8671417696..02ee1824ce 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java index 935b46f424..648559e153 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java index 1652490f97..97a04ddd2e 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; 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.instance.ItemInstance; 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.stats.Formulas; import org.l2jmobius.gameserver.model.variables.NpcVariables; @@ -157,6 +159,8 @@ public class Npc extends Creature /** Map of summoned NPCs by this NPC. */ private Map _summonedNpcs = null; + private final List _questTimers = new ArrayList<>(); + /** * Creates a NPC. * @param template the NPC template @@ -1323,6 +1327,9 @@ public class Npc extends Creature ((Npc) summoner).removeSummonedNpc(getObjectId()); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -2052,4 +2059,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java index 1652490f97..97a04ddd2e 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; 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.instance.ItemInstance; 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.stats.Formulas; import org.l2jmobius.gameserver.model.variables.NpcVariables; @@ -157,6 +159,8 @@ public class Npc extends Creature /** Map of summoned NPCs by this NPC. */ private Map _summonedNpcs = null; + private final List _questTimers = new ArrayList<>(); + /** * Creates a NPC. * @param template the NPC template @@ -1323,6 +1327,9 @@ public class Npc extends Creature ((Npc) summoner).removeSummonedNpc(getObjectId()); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -2052,4 +2059,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java index 6e287c4990..9d590a93d9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java index 6e287c4990..9d590a93d9 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java index 6e287c4990..9d590a93d9 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java index 94169ca3ae..4264ce8eb4 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -157,6 +159,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1148,6 +1152,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1866,4 +1873,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java index 94169ca3ae..4264ce8eb4 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -157,6 +159,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1148,6 +1152,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1866,4 +1873,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java index 94169ca3ae..4264ce8eb4 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -157,6 +159,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1148,6 +1152,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1866,4 +1873,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java index 6e287c4990..9d590a93d9 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/Npc.java @@ -16,6 +16,7 @@ */ package org.l2jmobius.gameserver.model.actor; +import java.util.ArrayList; import java.util.List; 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.instance.ItemInstance; 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.spawns.NpcSpawnTemplate; import org.l2jmobius.gameserver.model.stats.Formulas; @@ -156,6 +158,8 @@ public class Npc extends Creature /** Contains information about local tax payments. */ private TaxZone _taxZone = null; + private final List _questTimers = new ArrayList<>(); + /** * Constructor of NpcInstance (use Creature constructor).
*
@@ -1136,6 +1140,9 @@ public class Npc extends Creature instance.removeNpc(this); } + // Stop quest timers + stopQuestTimers(); + // Clear script value _scriptValue = 0; } @@ -1854,4 +1861,32 @@ public class Npc extends Creature { 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(); + } + } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java index 265e01de0b..f064c9a657 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/QuestTimer.java @@ -48,6 +48,11 @@ public class QuestTimer _scheduler = ThreadPool.schedule(new ScheduleTimerTask(), time); // Prepare auto end task } + if (npc != null) + { + npc.addQuestTimer(this); + } + if (player != null) { player.addQuestTimer(this); @@ -62,6 +67,11 @@ public class QuestTimer _scheduler = null; } + if (_npc != null) + { + _npc.removeQuestTimer(this); + } + if (_player != null) { _player.removeQuestTimer(this);