Merge branch 'fix-badges-code' into 'dev'

Removed deprecated from badges

See merge request morningstar/Arcturus-Community!546
This commit is contained in:
Harmonic 2022-04-15 01:03:52 +00:00
commit 1d28111207
2 changed files with 17 additions and 19 deletions

View File

@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer;
import com.eu.habbo.messages.outgoing.users.UserBadgesComposer;
@ -44,9 +46,21 @@ public class TakeBadgeCommand extends Command {
}
}
int userId = 0;
if (habbo != null)
userId = habbo.getHabboInfo().getId();
else {
HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username);
if (habboInfo != null)
userId = habboInfo.getId();
}
if (userId > 0) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_take_badge"), RoomChatMessageBubbles.ALERT);
BadgesComponent.deleteBadge(username, badge);
BadgesComponent.deleteBadge(userId, badge);
}
}
return true;

View File

@ -46,7 +46,7 @@ public class BadgesComponent {
}
if (delete) {
deleteBadge(habbo.getHabboInfo().getUsername(), badge.getCode());
deleteBadge(habbo.getHabboInfo().getId(), badge.getCode());
continue;
}
}
@ -94,22 +94,6 @@ public class BadgesComponent {
return badge;
}
@Deprecated
public static void deleteBadge(String username, HabboBadge badge) {
deleteBadge(username, badge.getCode());
}
@Deprecated
public static void deleteBadge(String username, String badge) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges INNER JOIN users ON users_badges.user_id = users.id WHERE users.username LIKE ? AND badge_code LIKE ?")) {
statement.setString(1, username);
statement.setString(2, badge);
statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
public static void deleteBadge(int userId, String badge) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges WHERE user_id = ? AND badge_code LIKE ?")) {
statement.setInt(1, userId);