Sharing a new useful code for some servers
Java:
diff --git a/aCis_gameserver/config/players.properties b/aCis_gameserver/config/players.properties
index 3e58ec8..42b9fcd 100644
--- a/aCis_gameserver/config/players.properties
+++ b/aCis_gameserver/config/players.properties
@@ -250,3 +250,12 @@
# Allow player subclass addition without checking for unique quest items. Default : False.
SubClassWithoutQuests = False
+#=============================================================
+# Custom Cancel Task
+#=============================================================
+# this setting back the buffs after the set time in CustomCancelSeconds
+# Default : False
+AllowCustomCancelTask = True
+# 5 = 5 seconds.
+CustomCancelSeconds = 7
+
diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
index 146971c..bf447a0 100644
--- a/aCis_gameserver/java/net/sf/l2j/Config.java
+++ b/aCis_gameserver/java/net/sf/l2j/Config.java
@@ -435,6 +435,9 @@
public static boolean DIVINE_SP_BOOK_NEEDED;
public static boolean SUBCLASS_WITHOUT_QUESTS;
+ /** Custom Cansel Segunds */
+ public static boolean ALLOW_CUSTOM_CANCEL;
+ public static int CUSTOM_CANCEL_SECONDS;
// --------------------------------------------------
// Sieges
@@ -1078,6 +1081,9 @@
DIVINE_SP_BOOK_NEEDED = players.getProperty("DivineInspirationSpBookNeeded", true);
SUBCLASS_WITHOUT_QUESTS = players.getProperty("SubClassWithoutQuests", false);
+ ALLOW_CUSTOM_CANCEL = players.getProperty("AllowCustomCancelTask", false);
+ CUSTOM_CANCEL_SECONDS = players.getProperty("CustomCancelSeconds", 5);
+
}
/**
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
index 9722407..ebe3c59 100644
--- a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/skillhandlers/Cancel.java
@@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Vector;
import net.sf.l2j.commons.math.MathUtil;
+import net.sf.l2j.commons.pool.ThreadPool;
@@ -13,8 +14,10 @@
import net.sf.l2j.gameserver.enums.skills.EffectType;
import net.sf.l2j.gameserver.enums.skills.SkillType;
import net.sf.l2j.gameserver.handler.ISkillHandler;
+import net.sf.l2j.gameserver.model.CustomCancelTask;
import net.sf.l2j.gameserver.model.WorldObject;
import net.sf.l2j.gameserver.model.actor.Creature;
+import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.skills.AbstractEffect;
import net.sf.l2j.gameserver.skills.Formulas;
import net.sf.l2j.gameserver.skills.L2Skill;
@@ -31,6 +34,7 @@
@Override
public void useSkill(Creature activeChar, L2Skill skill, WorldObject[] targets)
{
+ Vector<L2Skill> cancelledBuffs = new Vector<>();
// Delimit min/max % success.
final int minRate = (skill.getSkillType() == SkillType.CANCEL) ? 25 : 40;
final int maxRate = (skill.getSkillType() == SkillType.CANCEL) ? 75 : 95;
@@ -58,6 +62,15 @@
for (AbstractEffect effect : list)
{
+
+ if (Config.ALLOW_CUSTOM_CANCEL)
+ {
+ if (!cancelledBuffs.contains(effect.getSkill()))
+ {
+ cancelledBuffs.add(effect.getSkill());
+ }
+ }
+
// Don't cancel toggles or debuffs.
if (effect.getSkill().isToggle() || effect.getSkill().isDebuff())
continue;
@@ -88,6 +101,14 @@
continue;
}
+ if (Config.ALLOW_CUSTOM_CANCEL)
+ {
+ if (cancelledBuffs.size() > 0)
+ {
+ ThreadPool.schedule(new CustomCancelTask((Player) target, cancelledBuffs), Config.CUSTOM_CANCEL_SECONDS * 1000);
+ }
+ }
+
// Calculate the success chance following previous variables.
if (calcCancelSuccess(effect.getPeriod(), diffLevel, skillPower, skillVuln, minRate, maxRate))
effect.exit();
diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java
new file mode 100644
index 0000000..412d6d0
--- /dev/null
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/CustomCancelTask.java
@@ -0,0 +1,41 @@
+package net.sf.l2j.gameserver.model;
+
+import java.util.Vector;
+
+import net.sf.l2j.gameserver.model.actor.Player;
+import net.sf.l2j.gameserver.skills.L2Skill;
+
+
+/**
+ * @author Anarchy
+ *
+ */
+public class CustomCancelTask implements Runnable
+{
+ private Player _player = null;
+ private Vector<L2Skill> _buffs = null;
+
+ public CustomCancelTask(Player _player, Vector<L2Skill> _buffs)
+ {
+ this._player = _player;
+ this._buffs = _buffs;
+ }
+
+ @Override
+ public void run()
+ {
+ if (_player == null || !_player.isOnline())
+ {
+ return;
+ }
+ for (L2Skill s : _buffs)
+ {
+ if (s == null)
+ {
+ continue;
+ }
+
+ s.getEffects(_player, _player);
+ }
+ }
+}