Fixed rank badges disappearing

This commit is contained in:
Beny 2019-05-12 05:04:46 +01:00
parent d14f5a8f49
commit 4deccd7535
3 changed files with 4 additions and 4 deletions

View File

@ -54,7 +54,7 @@ public class BadgeCommand extends Command
{
boolean found;
try (PreparedStatement statement = connection.prepareStatement("SELECT badge_code FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1"))
try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1"))
{
statement.setString(1, params[1]);
statement.setString(2, params[2]);
@ -71,7 +71,7 @@ public class BadgeCommand extends Command
}
else
{
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges VALUES (null, (SELECT id FROM users WHERE username = ? LIMIT 1), 0, ?)"))
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)"))
{
statement.setString(1, params[1]);
statement.setString(2, params[2]);

View File

@ -333,7 +333,7 @@ public class HabboManager
if (!oldRank.getBadge().isEmpty())
{
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
BadgesComponent.deleteBadge(userId, oldRank.getBadge());
//BadgesComponent.deleteBadge(userId, oldRank.getBadge()); // unnecessary as Habbo.deleteBadge does this
}
habbo.getHabboInfo().setRank(newRank);

View File

@ -43,7 +43,7 @@ public class BadgesComponent
for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanks(badge.getCode()))
{
if (rank.getId() == habbo.getHabboInfo().getId())
if (rank.getId() == habbo.getHabboInfo().getRank().getId())
{
delete = false;
break;