U3Games

Games | Desarrollo & Soporte => L2 | Sección de Servidores => Lineage => L2 | Implementaciones => Mensaje iniciado por: xban1x en Jul 25, 2025, 12:15 AM

Título: Cancel Return
Publicado por: xban1x en Jul 25, 2025, 12:15 AM
### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java    (revision 10369)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java    (working copy)
@@ -20,6 +20,7 @@
 
 import java.util.List;
 
+import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
@@ -27,6 +28,8 @@
 import com.l2jserver.gameserver.model.skills.BuffInfo;
 import com.l2jserver.gameserver.model.stats.Formulas;
 
+import custom.CancelReturn.CancelReturn;
+
 /**
  * Dispel By Category effect implementation.
  * @author DS, Adry_85
@@ -67,6 +70,13 @@
         }
        
         final List<BuffInfo> canceled = Formulas.calcCancelStealEffects(info.getEffector(), info.getEffected(), info.getSkill(), _slot, _rate, _max);
+        if (info.getEffected().isPlayer() && !info.getEffected().getActingPlayer().isInOlympiadMode())
+        {
+            if (!canceled.isEmpty())
+            {
+                ThreadPoolManager.getInstance().scheduleGeneral(new CancelReturn(info.getEffected(), canceled), 15 * 1000);
+            }
+        }
         for (BuffInfo can : canceled)
         {
             info.getEffected().getEffectList().stopSkillEffects(true, can.getSkill());
Index: dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java
===================================================================
--- dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java    (revision 0)
+++ dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java    (working copy)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2004-2014 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package custom.CancelReturn;
+
+import java.util.List;
+
+import com.l2jserver.gameserver.model.CharEffectList;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.skills.BuffInfo;
+
+/**
+ * @author xban1x
+ */
+public class RemoveStolen implements Runnable
+{
+    private final L2Character _character;
+    private final List<BuffInfo> _buffList;
+   
+    public RemoveStolen(L2Character character, List<BuffInfo> buffList)
+    {
+        _character = character;
+        _buffList = buffList;
+    }
+   
+    @Override
+    public void run()
+    {
+        if ((_character != null) && (_buffList != null))
+        {
+            final CharEffectList cel = _character.getEffectList();
+            for (BuffInfo bi : _buffList)
+            {
+                cel.remove(true, bi);
+            }
+        }
+    }
+}
Index: dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java    (revision 10369)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java    (working copy)
@@ -18,11 +18,14 @@
  */
 package handlers.effecthandlers;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.CharEffectList;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -32,6 +35,8 @@
 import com.l2jserver.gameserver.model.skills.AbnormalType;
 import com.l2jserver.gameserver.model.skills.BuffInfo;
 
+import custom.CancelReturn.CancelReturn;
+
 /**
  * Dispel By Slot effect implementation.
  * @author Gnacik, Zoey76, Adry_85
@@ -83,6 +88,7 @@
        
         final L2Character effected = info.getEffected();
         final CharEffectList effectList = effected.getEffectList();
+        final List<BuffInfo> buffList = new ArrayList<>();
         // There is no need to iterate over all buffs,
         // Just iterate once over all slots to dispel and get the buff with that abnormal if exists,
         // Operation of O(n) for the amount of slots to dispel (which is usually small) and O(1) to get the buff.
@@ -103,11 +109,18 @@
             {
                 continue;
             }
-           
-            if ((entry.getKey() == toDispel.getSkill().getAbnormalType()) && ((entry.getValue() < 0) || (entry.getValue() >= toDispel.getSkill().getAbnormalLvl())))
+            if (effected.isPlayer() && !effected.getActingPlayer().isInOlympiadMode())
+            {
+                buffList.add(toDispel);
+            }
+            else if ((entry.getKey() == toDispel.getSkill().getAbnormalType()) && ((entry.getValue() < 0) || (entry.getValue() >= toDispel.getSkill().getAbnormalLvl())))
             {
                 effectList.stopSkillEffects(true, entry.getKey());
             }
         }
+        if (!buffList.isEmpty())
+        {
+            ThreadPoolManager.getInstance().scheduleGeneral(new CancelReturn(effected, buffList), 15 * 1000);
+        }
     }
 }
Index: dist/game/data/scripts/custom/CancelReturn/CancelReturn.java
===================================================================
--- dist/game/data/scripts/custom/CancelReturn/CancelReturn.java    (revision 0)
+++ dist/game/data/scripts/custom/CancelReturn/CancelReturn.java    (working copy)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package custom.CancelReturn;
+
+import java.util.List;
+
+import com.l2jserver.gameserver.model.CharEffectList;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.skills.BuffInfo;
+
+/**
+ * Cancel Return.<br>
+ * It will return dispelled effects back to it's owner.
+ * @author xban1x
+ */
+public final class CancelReturn implements Runnable
+{
+    private final L2Character _character;
+    private final List<BuffInfo> _buffList;
+   
+    public CancelReturn(L2Character character, List<BuffInfo> buffList)
+    {
+        _character = character;
+        _buffList = buffList;
+    }
+   
+    @Override
+    public void run()
+    {
+        if ((_character != null) && (_buffList != null))
+        {
+            final CharEffectList cel = _character.getEffectList();
+            for (BuffInfo bi : _buffList)
+            {
+                cel.add(bi);
+            }
+        }
+    }
+   
+}
Index: dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java
===================================================================
--- dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java    (revision 0)
+++ dist/game/data/scripts/custom/CancelReturn/RemoveStolen.java    (working copy)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2004-2014 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package custom.CancelReturn;
+
+import java.util.List;
+
+import com.l2jserver.gameserver.model.CharEffectList;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.skills.BuffInfo;
+
+/**
+ * @author xban1x
+ */
+public class RemoveStolen implements Runnable
+{
+    private final L2Character _character;
+    private final List<BuffInfo> _buffList;
+   
+    public RemoveStolen(L2Character character, List<BuffInfo> buffList)
+    {
+        _character = character;
+        _buffList = buffList;
+    }
+   
+    @Override
+    public void run()
+    {
+        if ((_character != null) && (_buffList != null))
+        {
+            final CharEffectList cel = _character.getEffectList();
+            for (BuffInfo bi : _buffList)
+            {
+                cel.remove(true, bi);
+            }
+        }
+    }
+}
Index: dist/game/data/scripts/custom/CancelReturn/CancelReturn.java
===================================================================
--- dist/game/data/scripts/custom/CancelReturn/CancelReturn.java    (revision 0)
+++ dist/game/data/scripts/custom/CancelReturn/CancelReturn.java    (working copy)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package custom.CancelReturn;
+
+import java.util.List;
+
+import com.l2jserver.gameserver.model.CharEffectList;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.skills.BuffInfo;
+
+/**
+ * Cancel Return.<br>
+ * It will return dispelled effects back to it's owner.
+ * @author xban1x
+ */
+public final class CancelReturn implements Runnable
+{
+    private final L2Character _character;
+    private final List<BuffInfo> _buffList;
+   
+    public CancelReturn(L2Character character, List<BuffInfo> buffList)
+    {
+        _character = character;
+        _buffList = buffList;
+    }
+   
+    @Override
+    public void run()
+    {
+        if ((_character != null) && (_buffList != null))
+        {
+            final CharEffectList cel = _character.getEffectList();
+            for (BuffInfo bi : _buffList)
+            {
+                cel.add(bi);
+            }
+        }
+    }
+   
+}
Index: dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java    (revision 10369)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java    (working copy)
@@ -18,11 +18,14 @@
  */
 package handlers.effecthandlers;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.CharEffectList;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -33,6 +36,8 @@
 import com.l2jserver.gameserver.model.skills.BuffInfo;
 import com.l2jserver.util.Rnd;
 
+import custom.CancelReturn.CancelReturn;
+
 /**
  * Dispel By Slot Probability effect implementation.
  * @author Adry_85, Zoey76
@@ -86,6 +91,7 @@
        
         final L2Character effected = info.getEffected();
         final CharEffectList effectList = effected.getEffectList();
+        final List<BuffInfo> buffList = new ArrayList<>();
         // There is no need to iterate over all buffs,
         // Just iterate once over all slots to dispel and get the buff with that abnormal if exists,
         // Operation of O(n) for the amount of slots to dispel (which is usually small) and O(1) to get the buff.
@@ -107,12 +113,19 @@
                 {
                     continue;
                 }
-               
-                if ((toDispel.getSkill().getAbnormalType() == entry.getKey()) && (entry.getValue() >= toDispel.getSkill().getAbnormalLvl()))
+                if (effected.isPlayer() && !effected.getActingPlayer().isInOlympiadMode())
+                {
+                    buffList.add(toDispel);
+                }
+                else if ((toDispel.getSkill().getAbnormalType() == entry.getKey()) && (entry.getValue() >= toDispel.getSkill().getAbnormalLvl()))
                 {
                     effectList.stopSkillEffects(true, entry.getKey());
                 }
             }
         }
+        if (!buffList.isEmpty())
+        {
+            ThreadPoolManager.getInstance().scheduleGeneral(new CancelReturn(effected, buffList), 15 * 1000);
+        }
     }
 }
Index: dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java    (revision 10369)
+++ dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java    (working copy)
@@ -18,8 +18,10 @@
  */
 package handlers.effecthandlers;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import com.l2jserver.gameserver.ThreadPoolManager;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
@@ -29,6 +31,9 @@
 import com.l2jserver.gameserver.model.stats.Env;
 import com.l2jserver.gameserver.model.stats.Formulas;
 
+import custom.CancelReturn.CancelReturn;
+import custom.CancelReturn.RemoveStolen;
+
 /**
  * Steal Abnormal effect implementation.
  * @author Adry_85, Zoey76
@@ -70,7 +75,7 @@
             {
                 return;
             }
-           
+            final List<BuffInfo> stolenEffects = new ArrayList<>();
             for (BuffInfo infoToSteal : toSteal)
             {
                 // Invert effected and effector.
@@ -84,7 +89,10 @@
                 infoToSteal.getSkill().applyEffectScope(EffectScope.GENERAL, stolen, true, true);
                 info.getEffected().getEffectList().remove(true, infoToSteal);
                 info.getEffector().getEffectList().add(stolen);
+                stolenEffects.add(stolen);
             }
+            ThreadPoolManager.getInstance().scheduleGeneral(new RemoveStolen(info.getEffector(), stolenEffects), 15 * 1000);
+            ThreadPoolManager.getInstance().scheduleGeneral(new CancelReturn(info.getEffected(), toSteal), 15 * 1000);
         }
     }
 }
\ No newline at end of file

INFO: https://www.l2jserver.com/forum/viewtopic.php?t=28868&hilit=Cancel+Return