Addition of BuffFinishTask.
This commit is contained in:
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5412,4 +5418,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.StampedLock;
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -114,6 +115,7 @@ import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
|
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.CommonSkill;
|
import org.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||||
import org.l2jmobius.gameserver.model.skills.EffectScope;
|
import org.l2jmobius.gameserver.model.skills.EffectScope;
|
||||||
@@ -243,6 +245,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
/** Map 32 bits, containing all abnormal visual effects in progress. */
|
/** Map 32 bits, containing all abnormal visual effects in progress. */
|
||||||
private int _abnormalVisualEffects;
|
private int _abnormalVisualEffects;
|
||||||
/** Map 32 bits, containing all special abnormal visual effects in progress. */
|
/** Map 32 bits, containing all special abnormal visual effects in progress. */
|
||||||
@@ -2439,6 +2443,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
getAI().stopAITask();
|
getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -6741,4 +6748,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,8 +52,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks = new ConcurrentHashMap<>();
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks = new ConcurrentHashMap<>();
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -227,11 +225,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +248,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
@@ -463,6 +458,6 @@ public final class BuffInfo
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "BuffInfo [effector=" + _effector + ", effected=" + _effected + ", skill=" + _skill + ", effects=" + _effects + ", tasks=" + _tasks + ", scheduledFutureTimeTask=" + _scheduledFutureTimeTask + ", abnormalTime=" + _abnormalTime + ", periodStartTicks=" + _periodStartTicks + ", isRemoved=" + _isRemoved + ", isInUse=" + _isInUse + "]";
|
return "BuffInfo [effector=" + _effector + ", effected=" + _effected + ", skill=" + _skill + ", effects=" + _effects + ", tasks=" + _tasks + ", abnormalTime=" + _abnormalTime + ", periodStartTicks=" + _periodStartTicks + ", isRemoved=" + _isRemoved + ", isInUse=" + _isInUse + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5411,4 +5417,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5411,4 +5417,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5411,4 +5417,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5411,4 +5417,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.model.items.type.WeaponType;
|
|||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillHolder;
|
||||||
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
import org.l2jmobius.gameserver.model.options.OptionsSkillType;
|
||||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.BuffFinishTask;
|
||||||
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
import org.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
import org.l2jmobius.gameserver.model.skills.SkillCaster;
|
||||||
@@ -243,6 +244,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
|
|
||||||
private SkillChannelized _channelized = null;
|
private SkillChannelized _channelized = null;
|
||||||
|
|
||||||
|
private BuffFinishTask _buffFinishTask = null;
|
||||||
|
|
||||||
private Optional<Transform> _transform = Optional.empty();
|
private Optional<Transform> _transform = Optional.empty();
|
||||||
|
|
||||||
/** Movement data of this Creature */
|
/** Movement data of this Creature */
|
||||||
@@ -1694,6 +1697,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
// Cancel all timers related to this Creature
|
// Cancel all timers related to this Creature
|
||||||
TimersManager.getInstance().cancelTimers(getObjectId());
|
TimersManager.getInstance().cancelTimers(getObjectId());
|
||||||
|
|
||||||
|
// Cancel the BuffFinishTask related to this creature.
|
||||||
|
cancelBuffFinishTask();
|
||||||
|
|
||||||
// Set world region to null.
|
// Set world region to null.
|
||||||
setWorldRegion(null);
|
setWorldRegion(null);
|
||||||
|
|
||||||
@@ -5411,4 +5417,34 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
|||||||
{
|
{
|
||||||
return _fakePlayerDrops;
|
return _fakePlayerDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask == null)
|
||||||
|
{
|
||||||
|
_buffFinishTask = new BuffFinishTask();
|
||||||
|
}
|
||||||
|
_buffFinishTask.addBuffInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfoTime(BuffInfo info)
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
_buffFinishTask.removeBuffInfo(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelBuffFinishTask()
|
||||||
|
{
|
||||||
|
if (_buffFinishTask != null)
|
||||||
|
{
|
||||||
|
final ScheduledFuture<?> task = _buffFinishTask.getTask();
|
||||||
|
if ((task != null) && !task.isCancelled() && !task.isDone())
|
||||||
|
{
|
||||||
|
task.cancel(true);
|
||||||
|
}
|
||||||
|
_buffFinishTask = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 org.l2jmobius.gameserver.model.skills;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class BuffFinishTask
|
||||||
|
{
|
||||||
|
private final Map<BuffInfo, AtomicInteger> _buffInfos = new ConcurrentHashMap<>();
|
||||||
|
private final ScheduledFuture<?> _task = ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
for (Entry<BuffInfo, AtomicInteger> entry : _buffInfos.entrySet())
|
||||||
|
{
|
||||||
|
final BuffInfo info = entry.getKey();
|
||||||
|
if ((info.getEffected() != null) && (entry.getValue().incrementAndGet() > info.getAbnormalTime()))
|
||||||
|
{
|
||||||
|
info.getEffected().getEffectList().stopSkillEffects(false, info.getSkill().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
|
||||||
|
public ScheduledFuture<?> getTask()
|
||||||
|
{
|
||||||
|
return _task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.put(info, new AtomicInteger());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBuffInfo(BuffInfo info)
|
||||||
|
{
|
||||||
|
_buffInfos.remove(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,6 @@ public final class BuffInfo
|
|||||||
// Tasks
|
// Tasks
|
||||||
/** Effect tasks for ticks. */
|
/** Effect tasks for ticks. */
|
||||||
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
private volatile Map<AbstractEffect, EffectTaskInfo> _tasks;
|
||||||
/** Scheduled future. */
|
|
||||||
private ScheduledFuture<?> _scheduledFutureTimeTask;
|
|
||||||
// Time and ticks
|
// Time and ticks
|
||||||
/** Abnormal time. */
|
/** Abnormal time. */
|
||||||
private int _abnormalTime;
|
private int _abnormalTime;
|
||||||
@@ -296,11 +294,8 @@ public final class BuffInfo
|
|||||||
public void stopAllEffects(boolean removed)
|
public void stopAllEffects(boolean removed)
|
||||||
{
|
{
|
||||||
setRemoved(removed);
|
setRemoved(removed);
|
||||||
// Cancels the task that will end this buff info
|
// Remove this buff info from BuffFinishTask.
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
finishEffects();
|
finishEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +317,7 @@ public final class BuffInfo
|
|||||||
// Creates a task that will stop all the effects.
|
// Creates a task that will stop all the effects.
|
||||||
if (_abnormalTime > 0)
|
if (_abnormalTime > 0)
|
||||||
{
|
{
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
_effected.addBuffInfoTime(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbstractEffect effect : _effects)
|
for (AbstractEffect effect : _effects)
|
||||||
@@ -453,11 +448,8 @@ public final class BuffInfo
|
|||||||
{
|
{
|
||||||
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
_periodStartTicks = GameTimeController.getInstance().getGameTicks();
|
||||||
_abnormalTime = abnormalTime;
|
_abnormalTime = abnormalTime;
|
||||||
if ((_scheduledFutureTimeTask != null) && !_scheduledFutureTimeTask.isCancelled())
|
_effected.removeBuffInfoTime(this);
|
||||||
{
|
_effected.addBuffInfoTime(this);
|
||||||
_scheduledFutureTimeTask.cancel(true);
|
|
||||||
}
|
|
||||||
_scheduledFutureTimeTask = ThreadPool.scheduleAtFixedRate(new BuffTimeTask(this), 0, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 org.l2jmobius.gameserver.model.skills;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Effect time task finish the effect when the abnormal time is reached.
|
|
||||||
* @author Zoey76
|
|
||||||
*/
|
|
||||||
public class BuffTimeTask implements Runnable
|
|
||||||
{
|
|
||||||
private final AtomicInteger _time = new AtomicInteger();
|
|
||||||
private final BuffInfo _info;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EffectTimeTask constructor.
|
|
||||||
* @param info the buff info
|
|
||||||
*/
|
|
||||||
public BuffTimeTask(BuffInfo info)
|
|
||||||
{
|
|
||||||
_info = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the elapsed time.
|
|
||||||
* @return the tick count
|
|
||||||
*/
|
|
||||||
public int getElapsedTime()
|
|
||||||
{
|
|
||||||
return _time.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if ((_info.getEffected() != null) && (_time.incrementAndGet() > _info.getAbnormalTime()))
|
|
||||||
{
|
|
||||||
_info.getEffected().getEffectList().stopSkillEffects(false, _info.getSkill().getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user