diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 3a48026e36..a7a40e5461 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9627,6 +9627,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9686,10 +9693,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index ec9c4a221f..c51767af1b 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9634,6 +9634,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9693,10 +9700,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 71977bad6b..0ac366429b 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9644,6 +9644,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9703,10 +9710,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 62dbed3b01..8b1c0e0e73 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9637,6 +9637,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9696,10 +9703,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 952d989696..3aae6cd376 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -10092,9 +10092,12 @@ public final class L2PcInstance extends L2Playable return false; } - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } getSubClasses().remove(classIndex); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 325b493cb4..6641d786fd 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9569,6 +9569,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9628,10 +9635,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally { diff --git a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 2d84d56b25..7d583443fd 100644 --- a/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Classic_2.0_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -9569,6 +9569,13 @@ public final class L2PcInstance extends L2Playable try { + // Notify to scripts before class is removed. + if (!getSubClasses().isEmpty()) // also null check + { + final int classId = getSubClasses().get(classIndex).getClassId(); + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); + } + final SubClass subClass = getSubClasses().remove(classIndex); if (subClass == null) { @@ -9628,10 +9635,6 @@ public final class L2PcInstance extends L2Playable _log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e); return false; } - - // Notify to scripts - int classId = getSubClasses().get(classIndex).getClassId(); - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerProfessionCancel(this, classId), this); } finally {