From a5e9fba8e49d9ae177d1106c53ea45adb13eed2b Mon Sep 17 00:00:00 2001 From: Snaiker Date: Wed, 13 Apr 2022 05:08:09 +0100 Subject: [PATCH] Fixs --- src/main/java/com/eu/habbo/habbohotel/users/Habbo.java | 2 +- src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java | 3 --- .../eu/habbo/habbohotel/users/inventory/BadgesComponent.java | 3 +-- src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java | 3 +++ .../com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index dcc5a05e..f867a8a2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -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)); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 18176593..5903cdc5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -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); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index 845ba2cb..02573ff4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -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); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 1cb10037..94bc3da6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -306,6 +306,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); diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index 4a3b11fb..180b0a29 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -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);