From 492c8f61422af713994a02a8446d9bd10423438d Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Wed, 13 May 2020 20:55:07 +0200 Subject: [PATCH] Revert ServerMessage release/retain. --- .../habbohotel/commands/EventCommand.java | 16 +- .../commands/HotelAlertCommand.java | 16 +- .../habbohotel/commands/MassBadgeCommand.java | 22 +- .../habbohotel/commands/MassGiftCommand.java | 24 +- .../commands/ReloadRoomCommand.java | 9 +- .../habbohotel/gameclients/GameClient.java | 4 +- .../gameclients/GameClientManager.java | 39 +--- .../com/eu/habbo/habbohotel/rooms/Room.java | 214 +++++++----------- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 13 +- .../habbo/habbohotel/users/HabboManager.java | 11 +- .../com/eu/habbo/messages/ServerMessage.java | 52 +---- .../FloorPlanEditorSaveEvent.java | 9 +- .../eu/habbo/messages/rcon/HotelAlert.java | 15 +- .../habbo/messages/rcon/ImageHotelAlert.java | 16 +- .../networking/gameserver/GameServer.java | 3 - .../decoders/GameMessageHandler.java | 9 +- .../encoders/GameServerMessageLogger.java | 2 +- .../threading/runnables/CannonKickAction.java | 16 +- 18 files changed, 148 insertions(+), 342 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 270a3914..21d57835 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EventCommand.java @@ -35,18 +35,12 @@ public class EventCommand extends Command { ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); - msg.retain(); + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; - 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(); + habbo.getClient().sendResponse(msg); } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java index 0d5bfdd1..52a3d454 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java @@ -24,17 +24,13 @@ public class HotelAlertCommand extends Command { } ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); - msg.retain(); - 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(); + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; + + habbo.getClient().sendResponse(msg); } } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT); 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 44cd3c15..b584ee61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java @@ -32,25 +32,21 @@ 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(); - if (habbo.isOnline()) { - if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { - HabboBadge b = BadgesComponent.createBadge(badge, habbo); + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); - if (b != null) { - habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); + if (habbo.isOnline()) { + if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { + HabboBadge b = BadgesComponent.createBadge(badge, habbo); - habbo.getClient().sendResponse(message); - } + if (b != null) { + habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); + + 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 1610f7e9..1c1055b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java @@ -60,26 +60,20 @@ public class MassGiftCommand extends Command { ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); Emulator.getThreading().run(() -> { - giftNotificiationMessage.retain(); + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); - try { - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); + HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); - HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); + Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); - Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); + String extraData = "1\t" + item.getId(); + extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; - String extraData = "1\t" + item.getId(); - extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0"; + Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); - Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); - - habbo.getClient().sendResponse(new InventoryRefreshComposer()); - habbo.getClient().sendResponse(giftNotificiationMessage); - } - } finally { - giftNotificiationMessage.release(); + habbo.getClient().sendResponse(new InventoryRefreshComposer()); + habbo.getClient().sendResponse(giftNotificiationMessage); } }); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java index 42c11e50..1ccd20d0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java @@ -24,13 +24,8 @@ public class ReloadRoomCommand extends Command { Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); - message.retain(); - try { - for (Habbo habbo : habbos) { - habbo.getClient().sendResponse(message); - } - } finally { - message.release(); + for (Habbo habbo : habbos) { + habbo.getClient().sendResponse(message); } } }, 100); diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java index 4242467d..9f871543 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -96,7 +96,7 @@ public class GameClient { return; } - this.channel.write(response.retain(), this.channel.voidPromise()); + this.channel.write(response, this.channel.voidPromise()); this.channel.flush(); } } @@ -108,7 +108,7 @@ public class GameClient { return; } - this.channel.write(response.retain()); + this.channel.write(response); } this.channel.flush(); diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java index dfbb7273..ad9b28ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java @@ -134,47 +134,32 @@ public class GameClientManager { public void sendBroadcastResponse(ServerMessage message) { - message.retain(); - try { - for (GameClient client : this.clients.values()) { - client.sendResponse(message); - } - } finally { - message.release(); + for (GameClient client : this.clients.values()) { + client.sendResponse(message); } } public void sendBroadcastResponse(ServerMessage message, GameClient exclude) { - message.retain(); - try { - for (GameClient client : this.clients.values()) { - if (client.equals(exclude)) - continue; + for (GameClient client : this.clients.values()) { + if (client.equals(exclude)) + continue; - client.sendResponse(message); - } - } finally { - message.release(); + client.sendResponse(message); } } public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) { - message.retain(); - try { - for (GameClient client : this.clients.values()) { - if (client.equals(exclude)) - continue; + for (GameClient client : this.clients.values()) { + if (client.equals(exclude)) + continue; - if (client.getHabbo() != null) { - if (client.getHabbo().hasPermission(minPermission)) { - client.sendResponse(message); - } + if (client.getHabbo() != null) { + if (client.getHabbo().hasPermission(minPermission)) { + client.sendResponse(message); } } - } finally { - message.release(); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 83ba308a..483744f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -3115,107 +3115,69 @@ public class Room implements Comparable, ISerialize, Runnable { roomChatMessage.setMessage(trimmedMessage); - if (prefixMessage != null) { - prefixMessage.retain(); - } - - if (clearPrefixMessage != null) { - clearPrefixMessage.retain(); - } - - try { - if (chatType == RoomChatType.WHISPER) { - if (roomChatMessage.getTargetHabbo() == null) { - return; - } - - RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); - staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage()); - - final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose(); - final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose(); - - message.retain(); - staffMessage.retain(); - - try { - for (Habbo h : this.getHabbos()) { - if (h == roomChatMessage.getTargetHabbo() || h == habbo) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - if (prefixMessage != null) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - - if (clearPrefixMessage != null) { - h.getClient().sendResponse(clearPrefixMessage); - } - } - - continue; - } - if (h.hasPermission("acc_see_whispers")) { - h.getClient().sendResponse(staffMessage); - } - } - } finally { - message.release(); - staffMessage.release(); - } - } else if (chatType == RoomChatType.TALK) { - ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose(); - boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit"); - - message.retain(); - - try { - for (Habbo h : this.getHabbos()) { - if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance || - h.equals(habbo) || - this.hasRights(h) || - noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { - if (prefixMessage != null && !h.getHabboStats().preferOldChat) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { - h.getClient().sendResponse(clearPrefixMessage); - } - } - } - } - } finally { - message.release(); - } - } else if (chatType == RoomChatType.SHOUT) { - ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose(); - - message.retain(); - - try { - for (Habbo h : this.getHabbos()) { - if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { - if (prefixMessage != null && !h.getHabboStats().preferOldChat) { - h.getClient().sendResponse(prefixMessage); - } - h.getClient().sendResponse(message); - if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { - h.getClient().sendResponse(clearPrefixMessage); - } - } - } - } finally { - message.release(); - } - } - } finally { - if (prefixMessage != null) { - prefixMessage.release(); + if (chatType == RoomChatType.WHISPER) { + if (roomChatMessage.getTargetHabbo() == null) { + return; } - if (clearPrefixMessage != null) { - clearPrefixMessage.release(); + RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage); + staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage()); + + final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose(); + final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose(); + + for (Habbo h : this.getHabbos()) { + if (h == roomChatMessage.getTargetHabbo() || h == habbo) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + + if (clearPrefixMessage != null) { + h.getClient().sendResponse(clearPrefixMessage); + } + } + + continue; + } + if (h.hasPermission("acc_see_whispers")) { + h.getClient().sendResponse(staffMessage); + } + } + } else if (chatType == RoomChatType.TALK) { + ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose(); + boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit"); + + for (Habbo h : this.getHabbos()) { + if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance || + h.equals(habbo) || + this.hasRights(h) || + noChatLimit) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) { + if (prefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(clearPrefixMessage); + } + } + } + } + } else if (chatType == RoomChatType.SHOUT) { + ServerMessage message = new RoomUserShoutComposer(roomChatMessage).compose(); + + for (Habbo h : this.getHabbos()) { + if (!h.getHabboStats().userIgnored(habbo.getHabboInfo().getId()) && (show == null || RoomLayout.tileInSquare(show, h.getRoomUnit().getCurrentLocation()))) { + if (prefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(prefixMessage); + } + h.getClient().sendResponse(message); + if (clearPrefixMessage != null && !h.getHabboStats().preferOldChat) { + h.getClient().sendResponse(clearPrefixMessage); + } + } } } @@ -3765,46 +3727,28 @@ public class Room implements Comparable, ISerialize, Runnable { } public void sendComposer(ServerMessage message) { - message.retain(); - - try { - for (Habbo habbo : this.getHabbos()) { - if (habbo.getClient() == null) { - this.removeHabbo(habbo, true); - continue; - } - - habbo.getClient().sendResponse(message); + for (Habbo habbo : this.getHabbos()) { + if (habbo.getClient() == null) { + this.removeHabbo(habbo, true); + continue; } - } finally { - message.release(); + + habbo.getClient().sendResponse(message); } } public void sendComposerToHabbosWithRights(ServerMessage message) { - message.retain(); - - try { - for (Habbo habbo : this.getHabbos()) { - if (this.hasRights(habbo)) { - habbo.getClient().sendResponse(message); - } + for (Habbo habbo : this.getHabbos()) { + if (this.hasRights(habbo)) { + habbo.getClient().sendResponse(message); } - } finally { - message.release(); } } public void petChat(ServerMessage message) { - message.retain(); - - try { - for (Habbo habbo : this.getHabbos()) { - if (!habbo.getHabboStats().ignorePets) - habbo.getClient().sendResponse(message); - } - } finally { - message.release(); + for (Habbo habbo : this.getHabbos()) { + if (!habbo.getHabboStats().ignorePets) + habbo.getClient().sendResponse(message); } } @@ -3813,15 +3757,9 @@ public class Room implements Comparable, ISerialize, Runnable { return; } - message.retain(); - - try { - for (Habbo habbo : this.getHabbos()) { - if (!habbo.getHabboStats().ignoreBots) - habbo.getClient().sendResponse(message); - } - } finally { - message.release(); + for (Habbo habbo : this.getHabbos()) { + if (!habbo.getHabboStats().ignoreBots) + habbo.getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index 3a443447..c6ba64e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; -import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; @@ -311,16 +310,8 @@ public class RoomTrade { } public void sendMessageToUsers(MessageComposer message) { - ServerMessage messageComposed = message.compose(); - - messageComposed.retain(); - - try { - for (RoomTradeUser roomTradeUser : this.users) { - roomTradeUser.getHabbo().getClient().sendResponse(message); - } - } finally { - messageComposed.release(); + for (RoomTradeUser roomTradeUser : this.users) { + roomTradeUser.getHabbo().getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java index f21e385f..8975b888 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -179,15 +179,10 @@ public class HabboManager { public void sendPacketToHabbosWithPermission(ServerMessage message, String perm) { synchronized (this.onlineHabbos) { - message.retain(); - try { - for (Habbo habbo : this.onlineHabbos.values()) { - if (habbo.hasPermission(perm)) { - habbo.getClient().sendResponse(message); - } + for (Habbo habbo : this.onlineHabbos.values()) { + if (habbo.hasPermission(perm)) { + habbo.getClient().sendResponse(message); } - } finally { - message.release(); } } } diff --git a/src/main/java/com/eu/habbo/messages/ServerMessage.java b/src/main/java/com/eu/habbo/messages/ServerMessage.java index 7a7e7c4f..8754ce5c 100644 --- a/src/main/java/com/eu/habbo/messages/ServerMessage.java +++ b/src/main/java/com/eu/habbo/messages/ServerMessage.java @@ -4,15 +4,13 @@ import com.eu.habbo.util.PacketUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; -import io.netty.util.IllegalReferenceCountException; -import io.netty.util.ReferenceCounted; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; -public class ServerMessage implements ReferenceCounted { +public class ServerMessage { private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class); private boolean initialized; @@ -35,6 +33,7 @@ public class ServerMessage implements ReferenceCounted { throw new ServerMessageException("ServerMessage was already initialized."); } + this.initialized = true; this.header = id; this.refs = new AtomicInteger(0); this.channelBuffer = Unpooled.buffer(); @@ -186,51 +185,4 @@ public class ServerMessage implements ReferenceCounted { return this.channelBuffer.copy(); } - @Override - public int refCnt() { - return this.refs.get(); - } - - @Override - public ReferenceCounted retain() { - this.refs.incrementAndGet(); - return this; - } - - @Override - public ReferenceCounted retain(int i) { - this.refs.addAndGet(i); - return this; - } - - @Override - public ReferenceCounted touch() { - return this; - } - - @Override - public ReferenceCounted touch(Object o) { - return this; - } - - @Override - public boolean release() { - return this.release(1); - } - - @Override - public boolean release(int i) { - int value = this.refs.addAndGet(-i); - if (value < 0) { - throw new IllegalReferenceCountException("Decremented below 0 (packet " + this.header + " value " + value + ")."); - } - - if (value == 0) { - this.channelBuffer.release(this.channelBuffer.refCnt()); - return true; - } - - return false; - } - } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index 5f6279df..113dd0e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -148,13 +148,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler { Emulator.getGameEnvironment().getRoomManager().unloadRoom(room); room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId()); ServerMessage message = new ForwardToRoomComposer(room.getId()).compose(); - message.retain(); - try { - for (Habbo habbo : habbos) { - habbo.getClient().sendResponse(message); - } - } finally { - message.release(); + for (Habbo habbo : habbos) { + habbo.getClient().sendResponse(message); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java b/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java index 912c52e1..70989239 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/HotelAlert.java @@ -25,17 +25,12 @@ public class HotelAlert extends RCONMessage { } if (serverMessage != null) { - serverMessage.retain(); - try { - for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { - Habbo habbo = set.getValue(); - if (habbo.getHabboStats().blockStaffAlerts) - continue; + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; - habbo.getClient().sendResponse(serverMessage); - } - } finally { - serverMessage.release(); + habbo.getClient().sendResponse(serverMessage); } } } 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 8e162a41..d392a6b2 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ImageHotelAlert.java @@ -43,17 +43,13 @@ public class ImageHotelAlert extends RCONMessage { } ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose(); - 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); - } - } finally { - message.release(); + for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { + Habbo habbo = set.getValue(); + if (habbo.getHabboStats().blockStaffAlerts) + continue; + + habbo.getClient().sendResponse(message); } } diff --git a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java index bbd2f4bf..90514484 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java @@ -30,9 +30,6 @@ public class GameServer extends Server { public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("logger", new LoggingHandler()); - // Logger. - - // Decoders. ch.pipeline().addLast(new GamePolicyDecoder()); ch.pipeline().addLast(new GameByteFrameDecoder()); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index a0ba3112..2da3032e 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -63,14 +63,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { if (cause instanceof TooLongFrameException) { LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); } else { - cause.printStackTrace(); - - LOGGER.error("Disconnecting client, exception in GameMessageHander:"); - LOGGER.error(cause.toString()); - - for (StackTraceElement element : cause.getStackTrace()) { - LOGGER.error(element.toString()); - } + LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); } ctx.channel().close(); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java index a21edde9..fd351942 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java @@ -27,7 +27,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder