This commit is contained in:
Snaiker 2022-04-13 05:08:09 +01:00
parent 797b887a98
commit a5e9fba8e4
5 changed files with 6 additions and 7 deletions

View File

@ -380,7 +380,7 @@ public class Habbo implements Runnable {
public boolean addBadge(String code) {
if (this.habboInventory.getBadgesComponent().getBadge(code) == null) {
if (!this.habboInventory.getBadgesComponent().hasBadge(code)) {
HabboBadge badge = BadgesComponent.createBadge(code, this);
this.habboInventory.getBadgesComponent().addBadge(badge);
this.client.sendResponse(new AddUserBadgeComposer(badge));

View File

@ -57,9 +57,6 @@ public class HabboBadge implements Runnable {
public void run() {
try {
if (this.needsInsert) {
if (this.habbo.getInventory().getBadgesComponent().hasBadge(this.code))
return;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (user_id, slot_id, badge_code) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, this.habbo.getHabboInfo().getId());
statement.setInt(2, this.slot);

View File

@ -160,8 +160,7 @@ public class BadgesComponent {
public void addBadge(HabboBadge badge) {
synchronized (this.badges) {
if (!this.hasBadge(badge.getCode()))
this.badges.add(badge);
this.badges.add(badge);
}
}

View File

@ -307,6 +307,9 @@ public class WiredHandler {
if (rewardReceived.value.isEmpty())
return;
if (habbo.getInventory().getBadgesComponent().hasBadge(rewardReceived.value))
return;
HabboBadge badge = new HabboBadge(0, rewardReceived.value, 0, habbo);
Emulator.getThreading().run(badge);
habbo.getInventory().getBadgesComponent().addBadge(badge);

View File

@ -52,7 +52,7 @@ public class AnswerPollEvent extends MessageHandler {
if (poll.lastQuestionId == questionId) {
if (poll.badgeReward.length() > 0) {
if (this.client.getHabbo().getInventory().getBadgesComponent().getBadge(poll.badgeReward) == null) {
if (!this.client.getHabbo().getInventory().getBadgesComponent().hasBadge(poll.badgeReward)) {
HabboBadge badge = new HabboBadge(0, poll.badgeReward, 0, this.client.getHabbo());
Emulator.getThreading().run(badge);
this.client.getHabbo().getInventory().getBadgesComponent().addBadge(badge);