From ea9280bb3009a97c760d72f18a62cb949d4dc0cd Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 25 Nov 2022 04:28:54 +0000 Subject: [PATCH] Addition of RequestSkillCoolTime. Thanks to Fakee. --- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/Timestamp.java | 4 +++ .../l2jmobius/gameserver/model/Timestamp.java | 4 +++ .../clientpackets/RequestSkillCoolTime.java | 6 ++-- .../network/serverpackets/SkillCoolTime.java | 5 ++- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../clientpackets/RequestSkillCoolTime.java | 6 ++-- .../network/serverpackets/SkillCoolTime.java | 17 +++++---- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 17 +++++---- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 17 +++++---- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- .../l2jmobius/gameserver/model/TimeStamp.java | 4 +++ .../gameserver/network/ClientPackets.java | 2 +- .../clientpackets/RequestSkillCoolTime.java | 36 +++++++++++++++++++ .../network/serverpackets/SkillCoolTime.java | 19 +++++----- 119 files changed, 1428 insertions(+), 322 deletions(-) create mode 100644 L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java create mode 100644 L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/ClientPackets.java index 28ee80d533..5d619dc2f6 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java index 2f81ed238e..1ba7c69e0d 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -163,7 +163,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), diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java index 2f81ed238e..1ba7c69e0d 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -163,7 +163,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), diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Timestamp.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Timestamp.java index 9f9ed44eec..1e0dddad20 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Timestamp.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Timestamp.java @@ -98,11 +98,13 @@ public class Timestamp { return 0; } + final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0); if (remainingTime == 0) { _stamp = 0; } + return remainingTime; } @@ -116,11 +118,13 @@ public class Timestamp { return false; } + final boolean hasNotPassed = System.currentTimeMillis() < _stamp; if (!hasNotPassed) { _stamp = 0; } + return hasNotPassed; } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Timestamp.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Timestamp.java index 9f9ed44eec..1e0dddad20 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Timestamp.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Timestamp.java @@ -98,11 +98,13 @@ public class Timestamp { return 0; } + final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0); if (remainingTime == 0) { _stamp = 0; } + return remainingTime; } @@ -116,11 +118,13 @@ public class Timestamp { return false; } + final boolean hasNotPassed = System.currentTimeMillis() < _stamp; if (!hasNotPassed) { _stamp = 0; } + return hasNotPassed; } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java index 923b78bb06..46967fe593 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -26,9 +26,11 @@ public class RequestSkillCoolTime implements ClientPacket public void run(GameClient client) { final Player player = client.getPlayer(); - if (player != null) + if (player == null) { - player.sendPacket(new SkillCoolTime(player)); + return; } + + player.sendPacket(new SkillCoolTime(player)); } } \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index 5fa1203d9c..6c108e092e 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -28,18 +28,17 @@ import org.l2jmobius.gameserver.network.ServerPackets; */ public class SkillCoolTime extends ServerPacket { - private final long _currentTime; public Collection _reuseTimestamps; public SkillCoolTime(Player player) { - _currentTime = System.currentTimeMillis(); _reuseTimestamps = player.getReuseTimeStamps(); } @Override public void write() { + final long currentTime = System.currentTimeMillis(); ServerPackets.SKILL_COOL_TIME.writeId(this); writeInt(_reuseTimestamps.size()); for (Timestamp ts : _reuseTimestamps) @@ -47,7 +46,7 @@ public class SkillCoolTime extends ServerPacket writeInt(ts.getSkillId()); 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); } } } \ No newline at end of file diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java index 72f604df3a..919d90a7f5 100644 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -142,11 +142,13 @@ public class TimeStamp { return 0; } + final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0); if (remainingTime == 0) { _stamp = 0; } + return remainingTime; } @@ -160,11 +162,13 @@ public class TimeStamp { return false; } + final boolean hasNotPassed = System.currentTimeMillis() < _stamp; if (!hasNotPassed) { _stamp = 0; } + return hasNotPassed; } } diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java index 923b78bb06..46967fe593 100644 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java +++ b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -26,9 +26,11 @@ public class RequestSkillCoolTime implements ClientPacket public void run(GameClient client) { final Player player = client.getPlayer(); - if (player != null) + if (player == null) { - player.sendPacket(new SkillCoolTime(player)); + return; } + + player.sendPacket(new SkillCoolTime(player)); } } \ No newline at end of file diff --git a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index a251c04e51..3a0ebc6c36 100644 --- a/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_CT_0_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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.model.TimeStamp; @@ -29,17 +29,15 @@ import org.l2jmobius.gameserver.network.ServerPackets; */ public class SkillCoolTime extends ServerPacket { - private final long _currentTime; - private final List _skillReuseTimeStamps = new ArrayList<>(); + private final List _reuseTimestamps = new LinkedList<>(); public SkillCoolTime(Player player) { - _currentTime = System.currentTimeMillis(); for (TimeStamp ts : player.getSkillReuseTimeStamps().values()) { - if (_currentTime < ts.getStamp()) + if (ts.hasNotPassed()) { - _skillReuseTimeStamps.add(ts); + _reuseTimestamps.add(ts); } } } @@ -47,14 +45,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(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); } } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/TimeStamp.java index 72f604df3a..919d90a7f5 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -142,11 +142,13 @@ public class TimeStamp { return 0; } + final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0); if (remainingTime == 0) { _stamp = 0; } + return remainingTime; } @@ -160,11 +162,13 @@ public class TimeStamp { return false; } + final boolean hasNotPassed = System.currentTimeMillis() < _stamp; if (!hasNotPassed) { _stamp = 0; } + return hasNotPassed; } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/ClientPackets.java index 98ec4a256c..aed43d11d8 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -157,7 +157,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), diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index a251c04e51..3a0ebc6c36 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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.model.TimeStamp; @@ -29,17 +29,15 @@ import org.l2jmobius.gameserver.network.ServerPackets; */ public class SkillCoolTime extends ServerPacket { - private final long _currentTime; - private final List _skillReuseTimeStamps = new ArrayList<>(); + private final List _reuseTimestamps = new LinkedList<>(); public SkillCoolTime(Player player) { - _currentTime = System.currentTimeMillis(); for (TimeStamp ts : player.getSkillReuseTimeStamps().values()) { - if (_currentTime < ts.getStamp()) + if (ts.hasNotPassed()) { - _skillReuseTimeStamps.add(ts); + _reuseTimestamps.add(ts); } } } @@ -47,14 +45,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(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); } } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/TimeStamp.java index 72f604df3a..919d90a7f5 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -142,11 +142,13 @@ public class TimeStamp { return 0; } + final long remainingTime = Math.max(_stamp - System.currentTimeMillis(), 0); if (remainingTime == 0) { _stamp = 0; } + return remainingTime; } @@ -160,11 +162,13 @@ public class TimeStamp { return false; } + final boolean hasNotPassed = System.currentTimeMillis() < _stamp; if (!hasNotPassed) { _stamp = 0; } + return hasNotPassed; } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/ClientPackets.java index 27a89b0aab..65b43b7e31 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -157,7 +157,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), diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index a251c04e51..3a0ebc6c36 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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.model.TimeStamp; @@ -29,17 +29,15 @@ import org.l2jmobius.gameserver.network.ServerPackets; */ public class SkillCoolTime extends ServerPacket { - private final long _currentTime; - private final List _skillReuseTimeStamps = new ArrayList<>(); + private final List _reuseTimestamps = new LinkedList<>(); public SkillCoolTime(Player player) { - _currentTime = System.currentTimeMillis(); for (TimeStamp ts : player.getSkillReuseTimeStamps().values()) { - if (_currentTime < ts.getStamp()) + if (ts.hasNotPassed()) { - _skillReuseTimeStamps.add(ts); + _reuseTimestamps.add(ts); } } } @@ -47,14 +45,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(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); } } } diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/ClientPackets.java index 28ee80d533..5d619dc2f6 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_1.0/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_1.5_AgeOfSplendor/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.5_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.7_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.8_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.9.5_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_2.9_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/ClientPackets.java index 596ca4a3c5..37f3a5e5a9 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -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), diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ClientPackets.java index 577d76d9bc..5328c125bf 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -167,7 +167,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), diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ClientPackets.java index 577d76d9bc..5328c125bf 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -167,7 +167,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), diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ClientPackets.java index 5fbceb9117..e3f4fd8794 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -168,7 +168,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), diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } } diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/TimeStamp.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/TimeStamp.java index c1364e3e14..ea895f04a2 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/TimeStamp.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/TimeStamp.java @@ -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; } } diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/ClientPackets.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/ClientPackets.java index 5fbceb9117..e3f4fd8794 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/ClientPackets.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/ClientPackets.java @@ -168,7 +168,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), diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java new file mode 100644 index 0000000000..46967fe593 --- /dev/null +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/clientpackets/RequestSkillCoolTime.java @@ -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 . + */ +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)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java index e228eb1e6b..65529821ce 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/network/serverpackets/SkillCoolTime.java @@ -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 _skillReuseTimeStamps = new ArrayList<>(); + private final List _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); } } }