Addition of RequestSkillCoolTime.
Thanks to Fakee.
This commit is contained in:
		@@ -155,11 +155,13 @@ public class TimeStamp
 | 
			
		||||
		{
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0);
 | 
			
		||||
		if (remainingTime == 0)
 | 
			
		||||
		{
 | 
			
		||||
			_stamp = 0;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return remainingTime;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -173,11 +175,13 @@ public class TimeStamp
 | 
			
		||||
		{
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final boolean hasNotPassed = System.currentTimeMillis() < _stamp;
 | 
			
		||||
		if (!hasNotPassed)
 | 
			
		||||
		{
 | 
			
		||||
			_stamp = 0;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return hasNotPassed;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -162,7 +162,7 @@ public enum ClientPackets
 | 
			
		||||
	SET_PRIVATE_STORE_MSG_BUY(0x9D, SetPrivateStoreMsgBuy::new, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_PRIVATE_STORE_SELL(0x9F, RequestPrivateStoreSell::new, ConnectionState.IN_GAME),
 | 
			
		||||
	SEND_TIME_CHECK_PACKET(0xA0, null, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_SKILL_COOL_TIME(0xA6, null, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_SKILL_COOL_TIME(0xA6, RequestSkillCoolTime::new, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_PACKAGE_SENDABLE_ITEM_LIST(0xA7, RequestPackageSendableItemList::new, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_PACKAGE_SEND(0xA8, RequestPackageSend::new, ConnectionState.IN_GAME),
 | 
			
		||||
	REQUEST_BLOCK(0xA9, RequestBlock::new, ConnectionState.IN_GAME),
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.network.clientpackets;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
 | 
			
		||||
 | 
			
		||||
public class RequestSkillCoolTime implements ClientPacket
 | 
			
		||||
{
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run(GameClient client)
 | 
			
		||||
	{
 | 
			
		||||
		final Player player = client.getPlayer();
 | 
			
		||||
		if (player == null)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		player.sendPacket(new SkillCoolTime(player));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.LinkedList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.SkillData;
 | 
			
		||||
@@ -30,17 +30,15 @@ import org.l2jmobius.gameserver.network.ServerPackets;
 | 
			
		||||
 */
 | 
			
		||||
public class SkillCoolTime extends ServerPacket
 | 
			
		||||
{
 | 
			
		||||
	private final long _currentTime;
 | 
			
		||||
	private final List<TimeStamp> _skillReuseTimeStamps = new ArrayList<>();
 | 
			
		||||
	private final List<TimeStamp> _reuseTimestamps = new LinkedList<>();
 | 
			
		||||
	
 | 
			
		||||
	public SkillCoolTime(Player player)
 | 
			
		||||
	{
 | 
			
		||||
		_currentTime = System.currentTimeMillis();
 | 
			
		||||
		for (TimeStamp ts : player.getSkillReuseTimeStamps().values())
 | 
			
		||||
		{
 | 
			
		||||
			if ((_currentTime < ts.getStamp()) && !SkillData.getInstance().getSkill(ts.getSkillId(), ts.getSkillLevel(), ts.getSkillSubLevel()).isNotBroadcastable())
 | 
			
		||||
			if (ts.hasNotPassed() && !SkillData.getInstance().getSkill(ts.getSkillId(), ts.getSkillLevel(), ts.getSkillSubLevel()).isNotBroadcastable())
 | 
			
		||||
			{
 | 
			
		||||
				_skillReuseTimeStamps.add(ts);
 | 
			
		||||
				_reuseTimestamps.add(ts);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -48,14 +46,15 @@ public class SkillCoolTime extends ServerPacket
 | 
			
		||||
	@Override
 | 
			
		||||
	public void write()
 | 
			
		||||
	{
 | 
			
		||||
		final long currentTime = System.currentTimeMillis();
 | 
			
		||||
		ServerPackets.SKILL_COOL_TIME.writeId(this);
 | 
			
		||||
		writeInt(_skillReuseTimeStamps.size());
 | 
			
		||||
		for (TimeStamp ts : _skillReuseTimeStamps)
 | 
			
		||||
		writeInt(_reuseTimestamps.size());
 | 
			
		||||
		for (TimeStamp ts : _reuseTimestamps)
 | 
			
		||||
		{
 | 
			
		||||
			writeInt(ts.getSkillId());
 | 
			
		||||
			writeInt(0); // ?
 | 
			
		||||
			writeInt(ts.getSkillLevel());
 | 
			
		||||
			writeInt((int) ts.getReuse() / 1000);
 | 
			
		||||
			writeInt((int) Math.max(ts.getStamp() - _currentTime, 0) / 1000);
 | 
			
		||||
			writeInt((int) Math.max(ts.getStamp() - currentTime, 0) / 1000);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user