diff --git a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_01.0_Ertheia/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_02.5_Underground/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_03.0_Helios/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_04.0_GrandCrusade/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_05.0_Salvation/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_05.5_EtinasFate/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_06.0_Fafurion/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java index 71f1c02986..a15130cf08 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/NightStatModify.java @@ -18,7 +18,6 @@ package handlers.effecthandlers; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; import org.l2jmobius.gameserver.enums.StatModifierType; import org.l2jmobius.gameserver.model.StatSet; @@ -41,10 +40,11 @@ import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager; */ public class NightStatModify extends AbstractEffect { - private static final AtomicBoolean DAY_TIME = new AtomicBoolean(GameTimeTaskManager.getInstance().isNight()); private static final Set NIGHT_STAT_CHARACTERS = ConcurrentHashMap.newKeySet(); private static final int SHADOW_SENSE = 294; + private static boolean START_LISTENER = true; + private final Stat _stat; private final int _amount; protected final StatModifierType _mode; @@ -55,9 +55,15 @@ public class NightStatModify extends AbstractEffect _amount = params.getInt("amount"); _mode = params.getEnum("mode", StatModifierType.class, StatModifierType.DIFF); - // Init a global day-night change listener. - final ListenersContainer container = Containers.Global(); - container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + // Run only once per daytime change. + if (START_LISTENER) + { + START_LISTENER = false; + + // Init a global day-night change listener. + final ListenersContainer container = Containers.Global(); + container.addListener(new ConsumerEventListener(container, EventType.ON_DAY_NIGHT_CHANGE, (OnDayNightChange event) -> onDayNightChange(event), this)); + } } @Override @@ -99,31 +105,19 @@ public class NightStatModify extends AbstractEffect public void onDayNightChange(OnDayNightChange event) { - synchronized (DAY_TIME) + // System message for Shadow Sense. + final SystemMessage msg = new SystemMessage(event.isNight() ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); + msg.addSkillName(SHADOW_SENSE); + + for (Creature creature : NIGHT_STAT_CHARACTERS) { - final boolean isNight = event.isNight(); + // Pump again. + creature.getStat().recalculateStats(true); - // Run only once per daytime change. - if (isNight == DAY_TIME.get()) + // Send Shadow Sense message when player has skill. + if (creature.getKnownSkill(SHADOW_SENSE) != null) { - return; - } - DAY_TIME.set(isNight); - - // System message for Shadow Sense. - final SystemMessage msg = new SystemMessage(isNight ? SystemMessageId.IT_IS_NOW_MIDNIGHT_AND_THE_EFFECT_OF_S1_CAN_BE_FELT : SystemMessageId.IT_IS_DAWN_AND_THE_EFFECT_OF_S1_WILL_NOW_DISAPPEAR); - msg.addSkillName(SHADOW_SENSE); - - for (Creature creature : NIGHT_STAT_CHARACTERS) - { - // Pump again. - creature.getStat().recalculateStats(true); - - // Send Shadow Sense message when player has skill. - if (creature.getKnownSkill(SHADOW_SENSE) != null) - { - creature.sendPacket(msg); - } + creature.sendPacket(msg); } } }