🆙 Fix subscription when user is removed

This commit is contained in:
DuckieTM 2025-02-25 22:27:38 +01:00
parent 6e59026141
commit 3cafc02a02
2 changed files with 12 additions and 1 deletions

View File

@ -270,7 +270,18 @@ public class SubscriptionHabboClub extends Subscription {
HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(userId);
if (habboInfo == null) {
SubscriptionManager.LOGGER.error("HabboInfo is null for user #" + userId);
SubscriptionManager.LOGGER.error("HabboInfo is null for user #" + userId + ". Removing subscription.");
// Remove subscription from the database
try (PreparedStatement removeStatement = connection.prepareStatement(
"DELETE FROM users_subscriptions WHERE user_id = ? AND subscription_type = ?")) {
removeStatement.setInt(1, userId);
removeStatement.setString(2, Subscription.HABBO_CLUB);
removeStatement.executeUpdate();
} catch (SQLException e) {
SubscriptionManager.LOGGER.error("SQL exception when trying to remove subscription for user #" + userId, e);
}
continue;
}