mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 08:20:51 +01:00
Merge branch 'fix-badges-code' into 'dev'
Removed deprecated from badges See merge request morningstar/Arcturus-Community!546
This commit is contained in:
commit
1d28111207
@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
|
|||||||
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
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.habbohotel.users.inventory.BadgesComponent;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer;
|
import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer;
|
||||||
import com.eu.habbo.messages.outgoing.users.UserBadgesComposer;
|
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);
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_take_badge"), RoomChatMessageBubbles.ALERT);
|
||||||
|
|
||||||
BadgesComponent.deleteBadge(username, badge);
|
BadgesComponent.deleteBadge(userId, badge);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -46,7 +46,7 @@ public class BadgesComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delete) {
|
if (delete) {
|
||||||
deleteBadge(habbo.getHabboInfo().getUsername(), badge.getCode());
|
deleteBadge(habbo.getHabboInfo().getId(), badge.getCode());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,22 +94,6 @@ public class BadgesComponent {
|
|||||||
return badge;
|
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) {
|
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 ?")) {
|
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);
|
statement.setInt(1, userId);
|
||||||
|
Loading…
Reference in New Issue
Block a user