From 374eab6fdd480b9eb26b968dae40e047f176e25f Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 24 Mar 2020 11:15:43 +0000 Subject: [PATCH] Removed some unnecessary synchronizations from quest timers. --- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 77 ++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- .../gameserver/model/quest/Quest.java | 81 +++++++++---------- 18 files changed, 647 insertions(+), 807 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/Quest.java index bd9c1d4e5e..95d3a1c267 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -315,6 +315,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -329,23 +330,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -361,23 +360,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -393,13 +388,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2813,22 +2805,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/Quest.java index 599a2912a1..bd0576f4e6 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -317,6 +317,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -331,23 +332,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -363,23 +362,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -395,13 +390,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2815,22 +2807,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/Quest.java index 72be7beb68..a5d15042ee 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -332,23 +333,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -364,23 +363,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -396,13 +391,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2816,22 +2808,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/Quest.java index 086b0ad979..98716d22ff 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -332,23 +333,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -364,23 +363,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -396,13 +391,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2816,22 +2808,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/Quest.java index 9a55ec4256..b751861e20 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -332,23 +333,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -364,23 +363,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -396,13 +391,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2816,22 +2808,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/Quest.java index 086b0ad979..98716d22ff 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -332,23 +333,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -364,23 +363,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -396,13 +391,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2816,22 +2808,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/Quest.java index 086b0ad979..98716d22ff 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -332,23 +333,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -364,23 +363,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -396,13 +391,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2816,22 +2808,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/Quest.java index 2d1266c68e..1e2011c02b 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -328,6 +328,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -342,23 +343,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -374,23 +373,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -406,13 +401,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2826,22 +2818,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java index 4ccc009d04..c01d366c35 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -387,6 +387,7 @@ public class Quest extends ManagedScript return timer; } } + return null; } @@ -401,23 +402,21 @@ public class Quest extends ManagedScript return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -433,23 +432,19 @@ public class Quest extends ManagedScript return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -465,13 +460,10 @@ public class Quest extends ManagedScript return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -1668,20 +1660,21 @@ public class Quest extends ManagedScript public boolean unload() { saveGlobalData(); + // Cancel all pending timers before reloading. // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + + _questTimers.clear(); + return QuestManager.getInstance().removeQuest(this); } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/Quest.java index 4682d14b20..be133c5d7c 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -290,6 +290,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -304,23 +305,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -336,23 +335,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -368,13 +363,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2503,22 +2495,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/Quest.java index 5695fd447d..5c7fc8a395 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -292,6 +292,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -306,23 +307,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -338,23 +337,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -370,13 +365,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2546,22 +2538,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload(); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java index c399ac294d..f4fd17eeeb 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/quest/Quest.java @@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable return timer; } } + return null; } @@ -330,23 +331,21 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) - { - return; - } - - for (QuestTimer timer : timers) - { - if (timer != null) - { - timer.cancel(); - } - } - timers.clear(); + return; } + + for (QuestTimer timer : timers) + { + if (timer != null) + { + timer.cancel(); + } + } + + timers.clear(); } /** @@ -362,23 +361,19 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(name); + if ((timers == null) || timers.isEmpty()) { - final List timers = _questTimers.get(name); - if ((timers == null) || timers.isEmpty()) + return; + } + + for (QuestTimer timer : timers) + { + if ((timer != null) && timer.equals(this, name, npc, player)) { + timer.cancel(); return; } - - for (QuestTimer timer : timers) - { - if ((timer != null) && timer.equals(this, name, npc, player)) - { - timer.cancel(); - timers.remove(timer); - return; - } - } } } @@ -394,13 +389,10 @@ public class Quest extends AbstractScript implements IIdentifiable return; } - synchronized (_questTimers) + final List timers = _questTimers.get(timer.toString()); + if (timers != null) { - final List timers = _questTimers.get(timer.toString()); - if (timers != null) - { - timers.remove(timer); - } + timers.remove(timer); } } @@ -2770,22 +2762,21 @@ public class Quest extends AbstractScript implements IIdentifiable public boolean unload(boolean removeFromList) { onSave(); - // cancel all pending timers before reloading. - // if timers ought to be restarted, the quest can take care of it - // with its code (example: save global data indicating what timer must be restarted). - synchronized (_questTimers) + + // Cancel all pending timers before reloading. + // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). + for (List timers : _questTimers.values()) { - for (List timers : _questTimers.values()) + for (QuestTimer timer : timers) { - for (QuestTimer timer : timers) - { - timer.cancel(); - } - timers.clear(); + timer.cancel(); } - _questTimers.clear(); + + timers.clear(); } + _questTimers.clear(); + if (removeFromList) { return QuestManager.getInstance().removeScript(this) && super.unload();