From df75af358007ec50289d49ffa202b286b5802ece Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 18 Dec 2022 07:43:11 +0000 Subject: [PATCH] Reworked HuntPass class. --- .../org/l2jmobius/gameserver/model/HuntPass.java | 16 +++++++--------- .../org/l2jmobius/gameserver/model/HuntPass.java | 16 +++++++--------- .../org/l2jmobius/gameserver/model/HuntPass.java | 16 +++++++--------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/HuntPass.java b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/HuntPass.java index 811bfc6009..418b99547f 100644 --- a/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/HuntPass.java +++ b/L2J_Mobius_10.3_MasterClass/java/org/l2jmobius/gameserver/model/HuntPass.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.threads.ThreadPool; +import org.l2jmobius.gameserver.data.xml.HuntPassData; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -39,6 +40,7 @@ import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInf public class HuntPass { private static final Logger LOGGER = Logger.getLogger(HuntPass.class.getName()); + private static final String INSERT_SEASONPASS = "REPLACE INTO huntpass (`account_name`, `current_step`, `points`, `reward_step`, `is_paytowin`, `premium_reward_step`, `sayha_points_available`, `sayha_points_used`, `unclaimed_reward`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String RESTORE_SEASONPASS = "SELECT * FROM huntpass WHERE account_name=?"; @@ -198,12 +200,10 @@ public class HuntPass public void inTimeHuntingZone(int points) // TODO: points is unused. { - final boolean Inhuntingzone = _user.isInTimedHuntingZone(_user.getX(), _user.getY()); - if (Inhuntingzone) + if (_user.isInTimedHuntingZone()) { _points += 1; } - return; } public void setPoints(int points) @@ -230,12 +230,10 @@ public class HuntPass { if (_isPremium && (_premiumRewardStep <= _rewardStep)) { - _rewardStep += 0; - } - else - { - _rewardStep = step; + return; } + + _rewardStep = Math.min(step, HuntPassData.getInstance().getRewardsCount() - 1); } public boolean isPremium() @@ -255,7 +253,7 @@ public class HuntPass public void setPremiumRewardStep(int step) { - _premiumRewardStep = step; + _premiumRewardStep = Math.min(step, HuntPassData.getInstance().getPremiumRewardsCount() - 1); } public boolean rewardAlert() diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java index afd96af57c..f24053965c 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.threads.ThreadPool; +import org.l2jmobius.gameserver.data.xml.HuntPassData; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -39,6 +40,7 @@ import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInf public class HuntPass { private static final Logger LOGGER = Logger.getLogger(HuntPass.class.getName()); + private static final String INSERT_SEASONPASS = "REPLACE INTO huntpass (`account_name`, `current_step`, `points`, `reward_step`, `is_paytowin`, `premium_reward_step`, `sayha_points_available`, `sayha_points_used`, `unclaimed_reward`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String RESTORE_SEASONPASS = "SELECT * FROM huntpass WHERE account_name=?"; @@ -198,12 +200,10 @@ public class HuntPass public void inTimeHuntingZone(int points) // TODO: points is unused. { - final boolean Inhuntingzone = _user.isInTimedHuntingZone(_user.getX(), _user.getY()); - if (Inhuntingzone) + if (_user.isInTimedHuntingZone()) { _points += 1; } - return; } public void setPoints(int points) @@ -230,12 +230,10 @@ public class HuntPass { if (_isPremium && (_premiumRewardStep <= _rewardStep)) { - _rewardStep += 0; - } - else - { - _rewardStep = step; + return; } + + _rewardStep = Math.min(step, HuntPassData.getInstance().getRewardsCount() - 1); } public boolean isPremium() @@ -255,7 +253,7 @@ public class HuntPass public void setPremiumRewardStep(int step) { - _premiumRewardStep = step; + _premiumRewardStep = Math.min(step, HuntPassData.getInstance().getPremiumRewardsCount() - 1); } public boolean rewardAlert() diff --git a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/HuntPass.java b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/HuntPass.java index 85efcabfae..e112379764 100644 --- a/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/HuntPass.java +++ b/L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/HuntPass.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.threads.ThreadPool; +import org.l2jmobius.gameserver.data.xml.HuntPassData; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; @@ -39,6 +40,7 @@ import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInf public class HuntPass { private static final Logger LOGGER = Logger.getLogger(HuntPass.class.getName()); + private static final String INSERT_SEASONPASS = "REPLACE INTO huntpass (`account_name`, `current_step`, `points`, `reward_step`, `is_paytowin`, `premium_reward_step`, `sayha_points_available`, `sayha_points_used`, `unclaimed_reward`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String RESTORE_SEASONPASS = "SELECT * FROM huntpass WHERE account_name=?"; @@ -198,12 +200,10 @@ public class HuntPass public void inTimeHuntingZone(int points) // TODO: points is unused. { - final boolean Inhuntingzone = _user.isInTimedHuntingZone(_user.getX(), _user.getY()); - if (Inhuntingzone) + if (_user.isInTimedHuntingZone()) { _points += 1; } - return; } public void setPoints(int points) @@ -230,12 +230,10 @@ public class HuntPass { if (_isPremium && (_premiumRewardStep <= _rewardStep)) { - _rewardStep += 0; - } - else - { - _rewardStep = step; + return; } + + _rewardStep = Math.min(step, HuntPassData.getInstance().getRewardsCount() - 1); } public boolean isPremium() @@ -255,7 +253,7 @@ public class HuntPass public void setPremiumRewardStep(int step) { - _premiumRewardStep = step; + _premiumRewardStep = Math.min(step, HuntPassData.getInstance().getPremiumRewardsCount() - 1); } public boolean rewardAlert()