Timestamp that partially matches other branches.
This commit is contained in:
parent
de911015c6
commit
cd918658d1
@ -14,63 +14,92 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.model.holders;
|
package org.l2jmobius.gameserver.model;
|
||||||
|
|
||||||
import org.l2jmobius.gameserver.model.Skill;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* Simple class containing all necessary information to maintain<br>
|
||||||
|
* valid time stamps and reuse for skills and items reuse upon re-login.<br>
|
||||||
|
* <b>Filter this carefully as it becomes redundant to store reuse for small delays.</b>
|
||||||
|
* @author Yesod, Zoey76
|
||||||
*/
|
*/
|
||||||
public class TimestampHolder
|
public class Timestamp
|
||||||
{
|
{
|
||||||
private final Skill _skill;
|
private final Skill _skill;
|
||||||
private final long _reuse;
|
private final long _reuse;
|
||||||
private final long _stamp;
|
private volatile long _stamp;
|
||||||
|
|
||||||
public TimestampHolder(Skill skill, long reuse)
|
public Timestamp(Skill skill, long reuse)
|
||||||
{
|
{
|
||||||
_skill = skill;
|
_skill = skill;
|
||||||
_reuse = reuse;
|
_reuse = reuse;
|
||||||
_stamp = System.currentTimeMillis() + _reuse;
|
_stamp = System.currentTimeMillis() + _reuse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimestampHolder(Skill skill, long reuse, long stamp)
|
public Timestamp(Skill skill, long reuse, long stamp)
|
||||||
{
|
{
|
||||||
_skill = skill;
|
_skill = skill;
|
||||||
_reuse = reuse;
|
_reuse = reuse;
|
||||||
_stamp = stamp;
|
_stamp = stamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the time stamp.
|
||||||
|
* @return the time stamp, either the system time where this time stamp was created or the custom time assigned
|
||||||
|
*/
|
||||||
public long getStamp()
|
public long getStamp()
|
||||||
{
|
{
|
||||||
return _stamp;
|
return _stamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the skill.
|
||||||
|
* @return the skill
|
||||||
|
*/
|
||||||
public Skill getSkill()
|
public Skill getSkill()
|
||||||
{
|
{
|
||||||
return _skill;
|
return _skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the skill ID.
|
||||||
|
* @return the skill ID
|
||||||
|
*/
|
||||||
public int getSkillId()
|
public int getSkillId()
|
||||||
{
|
{
|
||||||
return _skill.getId();
|
return _skill.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the skill level.
|
||||||
|
* @return the skill level
|
||||||
|
*/
|
||||||
public int getSkillLevel()
|
public int getSkillLevel()
|
||||||
{
|
{
|
||||||
return _skill.getLevel();
|
return _skill.getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the reuse.
|
||||||
|
* @return the reuse
|
||||||
|
*/
|
||||||
public long getReuse()
|
public long getReuse()
|
||||||
{
|
{
|
||||||
return _reuse;
|
return _reuse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the remaining time.
|
||||||
|
* @return the remaining time for this time stamp to expire
|
||||||
|
*/
|
||||||
public long getRemaining()
|
public long getRemaining()
|
||||||
{
|
{
|
||||||
return Math.max(_stamp - System.currentTimeMillis(), 0);
|
return Math.max(_stamp - System.currentTimeMillis(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies if the reuse delay has passed.
|
||||||
|
* @return {@code true} if this time stamp has expired, {@code false} otherwise
|
||||||
|
*/
|
||||||
public boolean hasNotPassed()
|
public boolean hasNotPassed()
|
||||||
{
|
{
|
||||||
return System.currentTimeMillis() < _stamp;
|
return System.currentTimeMillis() < _stamp;
|
@ -114,6 +114,7 @@ import org.l2jmobius.gameserver.model.Skill;
|
|||||||
import org.l2jmobius.gameserver.model.Skill.SkillTargetType;
|
import org.l2jmobius.gameserver.model.Skill.SkillTargetType;
|
||||||
import org.l2jmobius.gameserver.model.Skill.SkillType;
|
import org.l2jmobius.gameserver.model.Skill.SkillType;
|
||||||
import org.l2jmobius.gameserver.model.SkillLearn;
|
import org.l2jmobius.gameserver.model.SkillLearn;
|
||||||
|
import org.l2jmobius.gameserver.model.Timestamp;
|
||||||
import org.l2jmobius.gameserver.model.TradeList;
|
import org.l2jmobius.gameserver.model.TradeList;
|
||||||
import org.l2jmobius.gameserver.model.World;
|
import org.l2jmobius.gameserver.model.World;
|
||||||
import org.l2jmobius.gameserver.model.WorldObject;
|
import org.l2jmobius.gameserver.model.WorldObject;
|
||||||
@ -148,7 +149,6 @@ import org.l2jmobius.gameserver.model.entity.siege.FortSiege;
|
|||||||
import org.l2jmobius.gameserver.model.entity.siege.Siege;
|
import org.l2jmobius.gameserver.model.entity.siege.Siege;
|
||||||
import org.l2jmobius.gameserver.model.entity.siege.clanhalls.DevastatedCastle;
|
import org.l2jmobius.gameserver.model.entity.siege.clanhalls.DevastatedCastle;
|
||||||
import org.l2jmobius.gameserver.model.holders.PlayerStatsHolder;
|
import org.l2jmobius.gameserver.model.holders.PlayerStatsHolder;
|
||||||
import org.l2jmobius.gameserver.model.holders.TimestampHolder;
|
|
||||||
import org.l2jmobius.gameserver.model.items.Armor;
|
import org.l2jmobius.gameserver.model.items.Armor;
|
||||||
import org.l2jmobius.gameserver.model.items.Henna;
|
import org.l2jmobius.gameserver.model.items.Henna;
|
||||||
import org.l2jmobius.gameserver.model.items.Item;
|
import org.l2jmobius.gameserver.model.items.Item;
|
||||||
@ -527,7 +527,7 @@ public class PlayerInstance extends Playable
|
|||||||
private final List<Integer> _selectedBlocksList = new ArrayList<>(); // Related to CB.
|
private final List<Integer> _selectedBlocksList = new ArrayList<>(); // Related to CB.
|
||||||
private int _mailPosition;
|
private int _mailPosition;
|
||||||
private FishData _fish;
|
private FishData _fish;
|
||||||
private final Map<Integer, TimestampHolder> _reuseTimestamps = new ConcurrentHashMap<>();
|
private final Map<Integer, Timestamp> _reuseTimestamps = new ConcurrentHashMap<>();
|
||||||
boolean _gmStatus = true; // true by default since this is used by GMS
|
boolean _gmStatus = true; // true by default since this is used by GMS
|
||||||
public WorldObject _saymode = null;
|
public WorldObject _saymode = null;
|
||||||
String Dropzor = "Coin of Luck";
|
String Dropzor = "Coin of Luck";
|
||||||
@ -9716,7 +9716,7 @@ public class PlayerInstance extends Playable
|
|||||||
statement.setInt(5, effect.getTime());
|
statement.setInt(5, effect.getTime());
|
||||||
if (_reuseTimestamps.containsKey(effect.getSkill().getId()))
|
if (_reuseTimestamps.containsKey(effect.getSkill().getId()))
|
||||||
{
|
{
|
||||||
final TimestampHolder t = _reuseTimestamps.get(effect.getSkill().getId());
|
final Timestamp t = _reuseTimestamps.get(effect.getSkill().getId());
|
||||||
statement.setLong(6, t.hasNotPassed() ? t.getReuse() : 0);
|
statement.setLong(6, t.hasNotPassed() ? t.getReuse() : 0);
|
||||||
statement.setLong(7, t.hasNotPassed() ? t.getStamp() : 0);
|
statement.setLong(7, t.hasNotPassed() ? t.getStamp() : 0);
|
||||||
}
|
}
|
||||||
@ -9732,7 +9732,7 @@ public class PlayerInstance extends Playable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Store the reuse delays of remaining skills which lost effect but still under reuse delay. 'restore_type' 1.
|
// Store the reuse delays of remaining skills which lost effect but still under reuse delay. 'restore_type' 1.
|
||||||
for (TimestampHolder t : _reuseTimestamps.values())
|
for (Timestamp t : _reuseTimestamps.values())
|
||||||
{
|
{
|
||||||
if (t.hasNotPassed())
|
if (t.hasNotPassed())
|
||||||
{
|
{
|
||||||
@ -10188,7 +10188,7 @@ public class PlayerInstance extends Playable
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableSkill(skill, remainingTime);
|
disableSkill(skill, remainingTime);
|
||||||
addTimestamp(new TimestampHolder(skill, reuseDelay, systime));
|
addTimestamp(new Timestamp(skill, reuseDelay, systime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rset.close();
|
rset.close();
|
||||||
@ -10218,7 +10218,7 @@ public class PlayerInstance extends Playable
|
|||||||
}
|
}
|
||||||
|
|
||||||
disableSkill(skill, remainingTime);
|
disableSkill(skill, remainingTime);
|
||||||
addTimestamp(new TimestampHolder(skill, reuseDelay, systime));
|
addTimestamp(new Timestamp(skill, reuseDelay, systime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rset.close();
|
rset.close();
|
||||||
@ -16216,14 +16216,14 @@ public class PlayerInstance extends Playable
|
|||||||
*/
|
*/
|
||||||
public void addTimestamp(Skill s, int r)
|
public void addTimestamp(Skill s, int r)
|
||||||
{
|
{
|
||||||
_reuseTimestamps.put(s.getId(), new TimestampHolder(s, r));
|
_reuseTimestamps.put(s.getId(), new Timestamp(s, r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index according to skill this TimeStamp instance for restoration purposes only.
|
* Index according to skill this TimeStamp instance for restoration purposes only.
|
||||||
* @param t the t
|
* @param t the t
|
||||||
*/
|
*/
|
||||||
private void addTimestamp(TimestampHolder t)
|
private void addTimestamp(Timestamp t)
|
||||||
{
|
{
|
||||||
_reuseTimestamps.put(t.getSkillId(), t);
|
_reuseTimestamps.put(t.getSkillId(), t);
|
||||||
}
|
}
|
||||||
@ -16237,7 +16237,7 @@ public class PlayerInstance extends Playable
|
|||||||
_reuseTimestamps.remove(skill.getId());
|
_reuseTimestamps.remove(skill.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<TimestampHolder> getReuseTimeStamps()
|
public Collection<Timestamp> getReuseTimeStamps()
|
||||||
{
|
{
|
||||||
return _reuseTimestamps.values();
|
return _reuseTimestamps.values();
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ package org.l2jmobius.gameserver.network.serverpackets;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.l2jmobius.gameserver.model.Timestamp;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.holders.TimestampHolder;
|
|
||||||
|
|
||||||
public class SkillCoolTime extends GameServerPacket
|
public class SkillCoolTime extends GameServerPacket
|
||||||
{
|
{
|
||||||
public Collection<TimestampHolder> _reuseTimestamps;
|
public Collection<Timestamp> _reuseTimestamps;
|
||||||
|
|
||||||
public SkillCoolTime(PlayerInstance player)
|
public SkillCoolTime(PlayerInstance player)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ public class SkillCoolTime extends GameServerPacket
|
|||||||
}
|
}
|
||||||
writeC(0xc1);
|
writeC(0xc1);
|
||||||
writeD(_reuseTimestamps.size());
|
writeD(_reuseTimestamps.size());
|
||||||
for (TimestampHolder reuseTimestamp : _reuseTimestamps)
|
for (Timestamp reuseTimestamp : _reuseTimestamps)
|
||||||
{
|
{
|
||||||
writeD(reuseTimestamp.getSkillId());
|
writeD(reuseTimestamp.getSkillId());
|
||||||
writeD(reuseTimestamp.getSkillLevel());
|
writeD(reuseTimestamp.getSkillLevel());
|
||||||
|
Loading…
Reference in New Issue
Block a user