From ddef2543fea13a3f5b36efe4bef6247b78c44eab Mon Sep 17 00:00:00 2001 From: Snaiker Date: Fri, 18 Mar 2022 02:46:18 +0000 Subject: [PATCH] Fix issue NPE --- .../subscriptions/SubscriptionHabboClub.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java index 66c3d041..0c7fc193 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java @@ -15,6 +15,8 @@ import com.eu.habbo.messages.outgoing.generic.PickMonthlyClubGiftNotificationCom import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.*; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -29,6 +31,7 @@ import java.util.TreeMap; * @author Beny */ public class SubscriptionHabboClub extends Subscription { + private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionHabboClub.class); public static boolean HC_PAYDAY_ENABLED = false; public static int HC_PAYDAY_NEXT_DATE = Integer.MAX_VALUE; // yyyy-MM-dd HH:mm:ss @@ -393,9 +396,18 @@ public class SubscriptionHabboClub extends Subscription { break; default: - pointCurrency = Integer.parseInt(currency); - habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); - habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); + pointCurrency = -1; + try { + pointCurrency = Integer.parseInt(currency); + } + catch (NumberFormatException ex) { + LOGGER.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); + } + + if (pointCurrency >= 0) { + habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(pointCurrency, amount); + habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(pointCurrency), amount, pointCurrency)); + } break; }