Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Cancel Return (by d!g0)

Iniciado por Swarlog, Sep 01, 2022, 12:10 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java    (revision 10148)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelBySlot.java    (working copy)
@@ -18,14 +18,18 @@
  */
 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.Config;
 import com.l2jserver.gameserver.model.CharEffectList;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
@@ -80,6 +84,8 @@
             return;
         }
        
+        final List<BuffInfo> canceled = new ArrayList<>();
+       
         final L2Character effected = info.getEffected();
         final CharEffectList effectList = effected.getEffectList();
         // There is no need to iterate over all buffs,
@@ -105,8 +111,18 @@
            
             if ((entry.getKey() == toDispel.getSkill().getAbnormalType()) && (entry.getValue() >= toDispel.getSkill().getAbnormalLvl()))
             {
+                if (Config.RESTORE_CANCELED_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !((L2PcInstance) info.getEffected()).isInOlympiadMode())
+                {
+                    canceled.add(toDispel);
+                }
+               
                 effectList.stopSkillEffects(true, entry.getKey());
             }
         }
+       
+        if (Config.RESTORE_CANCELED_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !canceled.isEmpty())
+        {
+            ((L2PcInstance) info.getEffected()).recoverCancelledBuffs(canceled, Config.RESTORE_CANCELED_BUFFS_TIME);
+        }
     }
 }
Index: dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java    (revision 10148)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelBySlotProbability.java    (working copy)
@@ -18,14 +18,18 @@
  */
 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.Config;
 import com.l2jserver.gameserver.model.CharEffectList;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
@@ -83,6 +87,8 @@
             return;
         }
        
+        final List<BuffInfo> canceled = new ArrayList<>();
+       
         final L2Character effected = info.getEffected();
         final CharEffectList effectList = effected.getEffectList();
         // There is no need to iterate over all buffs,
@@ -109,9 +115,19 @@
                
                 if ((toDispel.getSkill().getAbnormalType() == entry.getKey()) && (entry.getValue() >= toDispel.getSkill().getAbnormalLvl()))
                 {
+                    if (Config.RESTORE_CANCELED_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !((L2PcInstance) info.getEffected()).isInOlympiadMode())
+                    {
+                        canceled.add(toDispel);
+                    }
+                   
                     effectList.stopSkillEffects(true, entry.getKey());
                 }
             }
         }
+       
+        if (Config.RESTORE_CANCELED_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !canceled.isEmpty())
+        {
+            ((L2PcInstance) info.getEffected()).recoverCancelledBuffs(canceled, Config.RESTORE_CANCELED_BUFFS_TIME);
+        }
     }
 }
Index: dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java    (revision 10148)
+++ dist/game/data/scripts/handlers/effecthandlers/StealAbnormal.java    (working copy)
@@ -20,7 +20,9 @@
 
 import java.util.List;
 
+import com.l2jserver.Config;
 import com.l2jserver.gameserver.model.StatsSet;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
@@ -85,6 +87,11 @@
                 info.getEffected().getEffectList().remove(true, infoToSteal);
                 info.getEffector().getEffectList().add(stolen);
             }
+           
+            if (Config.RESTORE_STOLEN_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !toSteal.isEmpty())
+            {
+                ((L2PcInstance) info.getEffected()).recoverCancelledBuffs(toSteal, Config.RESTORE_STOLEN_BUFFS_TIME);
+            }
         }
     }
 }
\ No newline at end of file
Index: dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java
===================================================================
--- dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java    (revision 10148)
+++ dist/game/data/scripts/handlers/effecthandlers/DispelByCategory.java    (working copy)
@@ -20,7 +20,9 @@
 
 import java.util.List;
 
+import com.l2jserver.Config;
 import com.l2jserver.gameserver.model.StatsSet;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.AbstractEffect;
 import com.l2jserver.gameserver.model.effects.L2EffectType;
@@ -70,5 +72,10 @@
         {
             info.getEffected().getEffectList().stopSkillEffects(true, can.getSkill());
         }
+       
+        if (Config.RESTORE_CANCELED_BUFFS_ENABLED && info.getEffected().isPlayer() && !info.getEffected().equals(info.getEffector()) && !canceled.isEmpty())
+        {
+            ((L2PcInstance) info.getEffected()).recoverCancelledBuffs(canceled, Config.RESTORE_CANCELED_BUFFS_TIME);
+        }
     }
 }
\ No newline at end of file
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 6364)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
@@ -176,6 +176,7 @@
 import com.l2jserver.gameserver.model.actor.tasks.player.PvPFlagTask;
 import com.l2jserver.gameserver.model.actor.tasks.player.RecoBonusTaskEnd;
 import com.l2jserver.gameserver.model.actor.tasks.player.RecoGiveTask;
+import com.l2jserver.gameserver.model.actor.tasks.player.RecoverCancelledBuffsTask;
 import com.l2jserver.gameserver.model.actor.tasks.player.RentPetTask;
 import com.l2jserver.gameserver.model.actor.tasks.player.ResetChargesTask;
 import com.l2jserver.gameserver.model.actor.tasks.player.ResetSoulsTask;
@@ -843,6 +844,8 @@
     /** Map containing all custom skills of this player. */
     private Map<Integer, L2Skill> _customSkills = null;
    
+    private final List<ScheduledFuture<?>> _cancelledBuffsTasks = new FastList<>();
+   
     private boolean _canRevive = true;
    
     private volatile int _actionMask;
@@ -5381,6 +5384,19 @@
                     pk.getEventStatus().getKills().add(this);
                 }
                
+                if ((_cancelledBuffsTasks != null) && !_cancelledBuffsTasks.isEmpty())
+                {
+                    for (ScheduledFuture<?> task : _cancelledBuffsTasks)
+                    {
+                        if (task != null)
+                        {
+                            task.cancel(true);
+                        }
+                    }
+                   
+                    _cancelledBuffsTasks.clear();
+                }
+               
                 // announce pvp/pk
                 if (Config.ANNOUNCE_PK_PVP && !pk.isGM())
                 {
@@ -14885,6 +14901,11 @@
         return 0;
     }
    
+    public void recoverCancelledBuffs(List<BuffInfo> buffsToRecover, int time)
+    {
+        _cancelledBuffsTasks.add(ThreadPoolManager.getInstance().scheduleGeneral(new RecoverCancelledBuffsTask(buffsToRecover, this), time * 1000));
+    }
+   
     public boolean isPartyBanned()
     {
         return PunishmentManager.getInstance().hasPunishment(getObjectId(), PunishmentAffect.CHARACTER, PunishmentType.PARTY_BAN);
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java    (revision 6364)
+++ java/com/l2jserver/Config.java    (working copy)
@@ -788,6 +788,10 @@
     public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
     public static Map<Integer, Integer> L2JMOD_DUALBOX_CHECK_WHITELIST;
     public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
+    public static boolean RESTORE_CANCELED_BUFFS_ENABLED;
+    public static boolean RESTORE_STOLEN_BUFFS_ENABLED;
+    public static int RESTORE_CANCELED_BUFFS_TIME;
+    public static int RESTORE_STOLEN_BUFFS_TIME;
     // --------------------------------------------------
     // NPC Settings
     // --------------------------------------------------
@@ -2586,6 +2590,11 @@
             }
             L2JMOD_ALLOW_CHANGE_PASSWORD = L2JModSettings.getBoolean("AllowChangePassword", false);
            
+            RESTORE_CANCELED_BUFFS_ENABLED = L2JModSettings.getBoolean("RestoreCanceledBuffs", false);
+            RESTORE_STOLEN_BUFFS_ENABLED = L2JModSettings.getBoolean("RestoreStolenBuffs", false);
+            RESTORE_CANCELED_BUFFS_TIME = L2JModSettings.getInt("RestoreCanceledBuffsTime", 60);
+            RESTORE_STOLEN_BUFFS_TIME = L2JModSettings.getInt("RestoreStolenBuffsTime", 60);
+           
             // Load PvP L2Properties file (if exists)
             final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
            
Index: java/com/l2jserver/gameserver/model/actor/tasks/player/RecoverCancelledBuffsTask.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/tasks/player/RecoverCancelledBuffsTask.java    (revision 0)
+++ java/com/l2jserver/gameserver/model/actor/tasks/player/RecoverCancelledBuffsTask.java    (working copy)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ *
+ * This file is part of L2J Server.
+ *
+ * L2J Server 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 Server 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 com.l2jserver.gameserver.model.actor.tasks.player;
+
+import java.util.List;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.skills.BuffInfo;
+import com.l2jserver.gameserver.model.skills.EffectScope;
+import com.l2jserver.gameserver.model.stats.Env;
+import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
+
+/**
+ * @author nuLL
+ */
+public class RecoverCancelledBuffsTask implements Runnable
+{
+    private final List<BuffInfo> _buffs;
+    private final L2PcInstance _player;
+   
+    public RecoverCancelledBuffsTask(List<BuffInfo> buffs, L2PcInstance player)
+    {
+        _player = player;
+        _buffs = buffs;
+    }
+   
+    @Override
+    public void run()
+    {
+        for (BuffInfo buff : _buffs)
+        {
+            final Env env = new Env();
+            env.setCharacter(_player);
+            env.setTarget(_player);
+            env.setSkill(buff.getSkill());
+            final BuffInfo stolenOrCanceled = new BuffInfo(env);
+            stolenOrCanceled.setAbnormalTime(buff.getTime());
+            buff.getSkill().applyEffectScope(EffectScope.GENERAL, stolenOrCanceled, true, true);
+           
+            if (stolenOrCanceled.getAbnormalTime() > 0)
+            {
+                _player.getEffectList().add(stolenOrCanceled);
+            }
+        }
+       
+        _player.sendPacket(new ExShowScreenMessage("Your cancelled buffs has been given back.", 2000));
+    }
+}
\ No newline at end of file