From 463fb826543671cba99eabdfb224cec36080cc4b Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Sun, 10 May 2020 00:02:46 +0200 Subject: [PATCH] Fix more issues. --- .../habbohotel/commands/EventCommand.java | 16 +++++++++---- .../habbohotel/commands/MassBadgeCommand.java | 22 ++++++++++------- .../habbohotel/commands/MassGiftCommand.java | 24 ++++++++++++------- .../habbo/messages/rcon/ImageHotelAlert.java | 15 ++++++++---- .../threading/runnables/CannonKickAction.java | 20 ++++++++++------ 5 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java index 21d57835..270a3914 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java @@ -35,12 +35,18 @@ public class EventCommand extends Command { ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) - continue; + msg.retain(); - habbo.getClient().sendResponse(msg); + try { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; + + habbo.getClient().sendResponse(msg); + } + } finally { + msg.release(); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java index b584ee61..44cd3c15 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java @@ -32,21 +32,25 @@ public class MassBadgeCommand extends Command { keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); + message.retain(); + try { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); + if (habbo.isOnline()) { + if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { + HabboBadge b = BadgesComponent.createBadge(badge, habbo); - if (habbo.isOnline()) { - if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { - HabboBadge b = BadgesComponent.createBadge(badge, habbo); + if (b != null) { + habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); - if (b != null) { - habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); - - habbo.getClient().sendResponse(message); + habbo.getClient().sendResponse(message); + } } } } + } finally { + message.release(); } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java index 1c1055b1..1610f7e9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java @@ -60,20 +60,26 @@ public class MassGiftCommand extends Command { ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); Emulator.getThreading().run(() -> { - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); + giftNotificiationMessage.retain(); - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); + try { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); - Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); + HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); - String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; + Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); - Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); + String extraData = "1\t" + item.getId(); + extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; - habbo.getClient().sendResponse(new InventoryRefreshComposer()); - habbo.getClient().sendResponse(giftNotificiationMessage); + Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); + + habbo.getClient().sendResponse(new InventoryRefreshComposer()); + habbo.getClient().sendResponse(giftNotificiationMessage); + } + } finally { + giftNotificiationMessage.release(); } }); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java index a2166745..8e162a41 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java @@ -43,12 +43,17 @@ public class ImageHotelAlert extends RCONMessage { } ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose(); - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) - continue; + message.retain(); + try { + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; - habbo.getClient().sendResponse(message); + habbo.getClient().sendResponse(message); + } + } finally { + message.release(); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java index 65eff558..e1666301 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CannonKickAction.java @@ -33,18 +33,24 @@ public class CannonKickAction implements Runnable { dater.put("title", "${notification.room.kick.cannonball.title}"); dater.put("message", "${notification.room.kick.cannonball.message}"); - ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose(); - int rotation = this.cannon.getRotation(); List tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3); - for (RoomTile t : tiles) { - for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) { - if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) { - Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); - habbo.getClient().sendResponse(message); //kicked composer + ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose(); + + message.retain(); + + try { + for (RoomTile t : tiles) { + for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) { + if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) { + Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room); + habbo.getClient().sendResponse(message); //kicked composer + } } } + } finally { + message.release(); } } }