From d77d18b27fadecce859b755a95291962bd7ea79f Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 17 Dec 2019 12:41:18 +0000 Subject: [PATCH 1/3] Started fixing teleporters - credits to quadral --- src/main/java/com/eu/habbo/Emulator.java | 4 +- .../habbohotel/gameclients/GameClient.java | 169 +++++++++++------- .../interactions/InteractionTeleport.java | 23 ++- .../com/eu/habbo/habbohotel/rooms/Room.java | 62 +++++++ .../teleport/TeleportActionThree.java | 5 +- 5 files changed, 192 insertions(+), 71 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 7b2cfa5d..8130ceaa 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-2"; + public final static String PREVIEW = "RC-3"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'RC Stands for Race Car.' \n" ; + " 'the only emulator with broken teleporters' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; 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 376f910c..943e1b14 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -1,3 +1,22 @@ +/* + * Morning Star + * Copyright (C) 2019 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; @@ -16,114 +35,134 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -public class GameClient { - - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); - private final Channel channel; - public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); - private Habbo habbo; - private String machineId = ""; - - public GameClient(Channel channel) { - this.channel = channel; +public class GameClient +{ + /// Constructor + /// @p_Channel : Channel + public GameClient(Channel p_Channel) { + this.m_Channel = p_Channel; } - public void sendResponse(MessageComposer composer) { - if (this.channel.isOpen()) { - try { - ServerMessage msg = composer.compose(); - this.sendResponse(msg); - } catch (Exception e) { - Emulator.getLogging().logPacketError(e); + /// Composer class - Abstract class + /// @p_Composer : Composer + public void sendResponse(MessageComposer p_Composer) { + if (this.m_Channel.isOpen()) + { + try + { + ServerMessage l_ServerMessage = p_Composer.compose(); + this.sendResponse(l_ServerMessage); + + } catch (Exception l_Exception) + { + Emulator.getLogging().logPacketError(l_Exception); } } } - - public void sendResponse(ServerMessage response) { - if (this.channel.isOpen()) { - if (response == null || response.getHeader() <= 0) { + /// Send Raw Response + /// @p_Response : Response + public void sendResponse(ServerMessage p_Response) + { + if (this.m_Channel.isOpen()) + { + if (p_Response == null || p_Response.getHeader() <= 0) + { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + p_Response.getHeader() + "] -> " + p_Response.getBodyString()); - this.channel.write(response.get(), this.channel.voidPromise()); - this.channel.flush(); + this.m_Channel.write(p_Response.get(), this.m_Channel.voidPromise()); + this.m_Channel.flush(); } } + /// Send packed response + /// @p_Responses : Response Array + public void sendResponses(ArrayList p_Responses) + { + ByteBuf l_Buffer = Unpooled.buffer(); - public void sendResponses(ArrayList responses) { - ByteBuf buffer = Unpooled.buffer(); - - if (this.channel.isOpen()) { - for (ServerMessage response : responses) { - if (response == null || response.getHeader() <= 0) { + if (this.m_Channel.isOpen()) { + for (ServerMessage l_Itr : p_Responses) + { + if (l_Itr == null || l_Itr.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + l_Itr.getHeader() + "] -> " + l_Itr.getBodyString()); - buffer.writeBytes(response.get()); + l_Buffer.writeBytes(l_Itr.get()); } - this.channel.write(buffer.copy(), this.channel.voidPromise()); - this.channel.flush(); + this.m_Channel.write(l_Buffer.copy(), this.m_Channel.voidPromise()); + this.m_Channel.flush(); } - buffer.release(); + l_Buffer.release(); } - + /// Dispose Habbo public void dispose() { - try { - this.channel.close(); - if (this.habbo != null) { - if (this.habbo.isOnline()) { - this.habbo.getHabboInfo().setOnline(false); - this.habbo.disconnect(); + try + { + this.m_Channel.close(); + + if (this.m_Habbo != null) { + if (this.m_Habbo.isOnline()) + { + this.m_Habbo.getHabboInfo().setOnline(false); + this.m_Habbo.disconnect(); } - this.habbo = null; + this.m_Habbo = null; } - } catch (Exception e) { + } catch (Exception e) + { Emulator.getLogging().logErrorLine(e); } } - public Channel getChannel() { - return this.channel; - } + /////////////////////////////////////////// + // GETTERS/SETTERS + /////////////////////////////////////////// - public Habbo getHabbo() { - return this.habbo; - } + public Channel getChannel() { return this.m_Channel; } + public String getMachineId() { return this.m_MachineId; } + public Habbo getHabbo() { return this.m_Habbo; } - public void setHabbo(Habbo habbo) { - this.habbo = habbo; - } - - public String getMachineId() { - return this.machineId; - } - - public void setMachineId(String machineId) { - if (machineId == null) { + public void setHabbo(Habbo p_Habbo) { this.m_Habbo = p_Habbo; } + public void setMachineId(String p_MachineId) + { + if (p_MachineId == null) + { throw new RuntimeException("Cannot set machineID to NULL"); } - this.machineId = machineId; + this.m_MachineId = p_MachineId; - if (this.habbo != null) { + if (this.m_MachineId != null) + { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) { - statement.setString(1, this.machineId); - statement.setInt(2, this.habbo.getHabboInfo().getId()); + statement.setString(1, this.m_MachineId); + statement.setInt(2, this.m_Habbo.getHabboInfo().getId()); statement.execute(); - } catch (SQLException e) { + } catch (SQLException e) + { Emulator.getLogging().logSQLException(e); } } } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); + public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); + + private final Channel m_Channel; + private Habbo m_Habbo; + private String m_MachineId; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 0106e1b8..041b10cc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -17,6 +17,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; + +/// how u find files? where is file search bar on this ide public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; @@ -62,27 +64,37 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); + /// Habbo must exist if (habbo == null) return; + /// Get Unit of habbo (extension class) RoomUnit unit = habbo.getRoomUnit(); + /// Unit must exit - this should be logged as this should never happen if (unit == null) return; + /// Get current tile habbo is standing on RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); + /// dont proceed is our current tile is null - this should never happen if (currentLocation == null) return; + /// Get the tile infront RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); + /// Check whether we can use the teleport if (!canUseTeleport(client, room)) return; - if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { + if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) + { startTeleport(room, habbo); - } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { + + } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) + { // set state 1 and walk on item this.roomUnitID = unit.getId(); this.setExtradata("1"); @@ -187,19 +199,25 @@ public class InteractionTeleport extends HabboItem { public boolean canUseTeleport(GameClient client, Room room) { + /// Get habbo Habbo habbo = client.getHabbo(); + /// this should never happen.... if (habbo == null) return false; + /// Get extension class RoomUnit unit = habbo.getRoomUnit(); + /// this should never happen... if (unit == null) return false; + /// Habbo cannot use the teleport if riding if (habbo.getHabboInfo().getRiding() != null) return false; + /// check whether the room unit Id is valid return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); } @@ -208,6 +226,7 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { + /// dont teleport if we are already teleporting if (habbo.getRoomUnit().isTeleporting) return; 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 7dd1b524..1f6fdfe5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4318,6 +4318,60 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NO_RIGHTS; } + public HabboItem OverrideItem(HabboItem p_Item, Habbo p_Owner) + { + if (p_Item instanceof InteractionTeleport) + { + TIntObjectIterator l_Itr = this.roomItems.iterator(); + + for (int l_I = 0; l_I < this.roomItems.size(); l_I++) + { + l_Itr.advance(); + + if (l_Itr.value() instanceof InteractionTeleport) + { + InteractionTeleport l_Item = (InteractionTeleport)l_Itr.value(); + + /// If the item matches our hand item, then we have the correct item + if (p_Item.getId() == l_Item.getTargetId()) + { + return p_Item; + } + + /// If the pair item is not placed in the room, check whether its placed in any other rooms + if (this.getHabboItem(l_Item.getTargetId()) == null) + { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM items WHERE id = ?")) + { + statement.setInt(1, l_Item.getTargetId()); + try (ResultSet set = statement.executeQuery()) + { + set.next(); + + /// Check if pair item is placed in any rooms, if not then return that i + if (set.getInt("room_id") == 0) + { + HabboItem l_HandItem = p_Owner.getInventory().getItemsComponent().getHabboItem(l_Item.getTargetId()); + + if (l_HandItem != null) + { + return l_HandItem; + } + } + } + } + catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + } + } + } + } + } + + return p_Item; + } + + public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; @@ -4368,6 +4422,14 @@ public class Room implements Comparable, ISerialize, Runnable { return fits; } + if (item instanceof InteractionTeleport) + { + InteractionTeleport l_Test = (InteractionTeleport)item; + int hello = 0; + } + + item = this.OverrideItem(item, owner); + item.setZ(tile.getStackHeight()); item.setX(tile.x); item.setY(tile.y); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 036ce89c..31cf5d0a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -65,8 +65,9 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); - //targetRoom.updateHabbo(this.client.getHabbo()); - //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); + targetRoom.updateHabbo(this.client.getHabbo()); + //System.out.println(targetTeleport.getX() + " | " + tokay so basically + // after goargetTeleport.getY()); this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500); From 2d83bca51381479e1b34ef6d5bc051c911c29ee9 Mon Sep 17 00:00:00 2001 From: KrewsOrg Date: Tue, 17 Dec 2019 13:20:58 +0000 Subject: [PATCH 2/3] Wordfilter fix. Credits to Layne, requires more testing. --- .../com/eu/habbo/habbohotel/modtool/WordFilter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index b000c0b4..6b214a77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -72,8 +72,15 @@ public class WordFilter { } public String normalise(String message) { - return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD).replaceAll("[,.;:'\"]", "").replace("I", "l") - .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", "").replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i").replace("2", "z").replace("3", "e").replace("4", "a").replace("5", "s").replace("8", "b").replace("0", "o").replace(" ", "").replace("$", "s").replace("ß", "b").trim()).replaceAll(""); + return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD) + .replaceAll("[,.;:'\"]", " ").replace("I", "l") + .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", " ") + .replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i") + .replace("2", "z").replace("3", "e") + .replace("4", "a").replace("5", "s") + .replace("8", "b").replace("0", "o") + .replace(" ", " ").replace("$", "s") + .replace("ß", "b").trim()).replaceAll(" "); } public boolean autoReportCheck(RoomChatMessage roomChatMessage) { @@ -139,7 +146,7 @@ public class WordFilter { if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } - filteredMessage = filteredMessage.replaceAll("(?i)" + word.key, word.replacement); + filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement); foundShit = true; if (habbo != null && word.muteTime > 0) { From ca5431671528125623b9f12e964d0dd3a1e19dd6 Mon Sep 17 00:00:00 2001 From: Harmonic Date: Wed, 18 Dec 2019 14:49:02 -0500 Subject: [PATCH 3/3] Revert "Started fixing teleporters - credits to quadral" This reverts commit d77d18b27fadecce859b755a95291962bd7ea79f --- src/main/java/com/eu/habbo/Emulator.java | 4 +- .../habbohotel/gameclients/GameClient.java | 169 +++++++----------- .../interactions/InteractionTeleport.java | 23 +-- .../com/eu/habbo/habbohotel/rooms/Room.java | 62 ------- .../teleport/TeleportActionThree.java | 5 +- 5 files changed, 71 insertions(+), 192 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 8130ceaa..7b2cfa5d 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -37,7 +37,7 @@ public final class Emulator { public final static int BUILD = 0; - public final static String PREVIEW = "RC-3"; + public final static String PREVIEW = "RC-2"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; private static final String logo = @@ -49,7 +49,7 @@ public final class Emulator { " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + " /____/ \n" + - " 'the only emulator with broken teleporters' \n" ; + " 'RC Stands for Race Car.' \n" ; public static String build = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; 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 943e1b14..376f910c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -1,22 +1,3 @@ -/* - * Morning Star - * Copyright (C) 2019 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; @@ -35,134 +16,114 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -public class GameClient -{ - /// Constructor - /// @p_Channel : Channel - public GameClient(Channel p_Channel) { - this.m_Channel = p_Channel; +public class GameClient { + + public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); + private final Channel channel; + public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); + private Habbo habbo; + private String machineId = ""; + + public GameClient(Channel channel) { + this.channel = channel; } - /// Composer class - Abstract class - /// @p_Composer : Composer - public void sendResponse(MessageComposer p_Composer) { - if (this.m_Channel.isOpen()) - { - try - { - ServerMessage l_ServerMessage = p_Composer.compose(); - this.sendResponse(l_ServerMessage); - - } catch (Exception l_Exception) - { - Emulator.getLogging().logPacketError(l_Exception); + public void sendResponse(MessageComposer composer) { + if (this.channel.isOpen()) { + try { + ServerMessage msg = composer.compose(); + this.sendResponse(msg); + } catch (Exception e) { + Emulator.getLogging().logPacketError(e); } } } - /// Send Raw Response - /// @p_Response : Response - public void sendResponse(ServerMessage p_Response) - { - if (this.m_Channel.isOpen()) - { - if (p_Response == null || p_Response.getHeader() <= 0) - { + + public void sendResponse(ServerMessage response) { + if (this.channel.isOpen()) { + if (response == null || response.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + p_Response.getHeader() + "] -> " + p_Response.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); - this.m_Channel.write(p_Response.get(), this.m_Channel.voidPromise()); - this.m_Channel.flush(); + this.channel.write(response.get(), this.channel.voidPromise()); + this.channel.flush(); } } - /// Send packed response - /// @p_Responses : Response Array - public void sendResponses(ArrayList p_Responses) - { - ByteBuf l_Buffer = Unpooled.buffer(); - if (this.m_Channel.isOpen()) { - for (ServerMessage l_Itr : p_Responses) - { - if (l_Itr == null || l_Itr.getHeader() <= 0) { + public void sendResponses(ArrayList responses) { + ByteBuf buffer = Unpooled.buffer(); + + if (this.channel.isOpen()) { + for (ServerMessage response : responses) { + if (response == null || response.getHeader() <= 0) { return; } if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + l_Itr.getHeader() + "] -> " + l_Itr.getBodyString()); + Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString()); - l_Buffer.writeBytes(l_Itr.get()); + buffer.writeBytes(response.get()); } - this.m_Channel.write(l_Buffer.copy(), this.m_Channel.voidPromise()); - this.m_Channel.flush(); + this.channel.write(buffer.copy(), this.channel.voidPromise()); + this.channel.flush(); } - l_Buffer.release(); + buffer.release(); } - /// Dispose Habbo + public void dispose() { + try { + this.channel.close(); - try - { - this.m_Channel.close(); - - if (this.m_Habbo != null) { - if (this.m_Habbo.isOnline()) - { - this.m_Habbo.getHabboInfo().setOnline(false); - this.m_Habbo.disconnect(); + if (this.habbo != null) { + if (this.habbo.isOnline()) { + this.habbo.getHabboInfo().setOnline(false); + this.habbo.disconnect(); } - this.m_Habbo = null; + this.habbo = null; } - } catch (Exception e) - { + } catch (Exception e) { Emulator.getLogging().logErrorLine(e); } } - /////////////////////////////////////////// - // GETTERS/SETTERS - /////////////////////////////////////////// + public Channel getChannel() { + return this.channel; + } - public Channel getChannel() { return this.m_Channel; } - public String getMachineId() { return this.m_MachineId; } - public Habbo getHabbo() { return this.m_Habbo; } + public Habbo getHabbo() { + return this.habbo; + } - public void setHabbo(Habbo p_Habbo) { this.m_Habbo = p_Habbo; } - public void setMachineId(String p_MachineId) - { - if (p_MachineId == null) - { + public void setHabbo(Habbo habbo) { + this.habbo = habbo; + } + + public String getMachineId() { + return this.machineId; + } + + public void setMachineId(String machineId) { + if (machineId == null) { throw new RuntimeException("Cannot set machineID to NULL"); } - this.m_MachineId = p_MachineId; + this.machineId = machineId; - if (this.m_MachineId != null) - { + if (this.habbo != null) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) { - statement.setString(1, this.m_MachineId); - statement.setInt(2, this.m_Habbo.getHabboInfo().getId()); + statement.setString(1, this.machineId); + statement.setInt(2, this.habbo.getHabboInfo().getId()); statement.execute(); - } catch (SQLException e) - { + } catch (SQLException e) { Emulator.getLogging().logSQLException(e); } } } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); - public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); - - private final Channel m_Channel; - private Habbo m_Habbo; - private String m_MachineId; } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java index 041b10cc..0106e1b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java @@ -17,8 +17,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; - -/// how u find files? where is file search bar on this ide public class InteractionTeleport extends HabboItem { private int targetId; private int targetRoomId; @@ -64,37 +62,27 @@ public class InteractionTeleport extends HabboItem { Habbo habbo = client.getHabbo(); - /// Habbo must exist if (habbo == null) return; - /// Get Unit of habbo (extension class) RoomUnit unit = habbo.getRoomUnit(); - /// Unit must exit - this should be logged as this should never happen if (unit == null) return; - /// Get current tile habbo is standing on RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY()); - /// dont proceed is our current tile is null - this should never happen if (currentLocation == null) return; - /// Get the tile infront RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation()); - /// Check whether we can use the teleport if (!canUseTeleport(client, room)) return; - if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) - { + if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { startTeleport(room, habbo); - - } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) - { + } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { // set state 1 and walk on item this.roomUnitID = unit.getId(); this.setExtradata("1"); @@ -199,25 +187,19 @@ public class InteractionTeleport extends HabboItem { public boolean canUseTeleport(GameClient client, Room room) { - /// Get habbo Habbo habbo = client.getHabbo(); - /// this should never happen.... if (habbo == null) return false; - /// Get extension class RoomUnit unit = habbo.getRoomUnit(); - /// this should never happen... if (unit == null) return false; - /// Habbo cannot use the teleport if riding if (habbo.getHabboInfo().getRiding() != null) return false; - /// check whether the room unit Id is valid return this.roomUnitID == -1 || this.roomUnitID == unit.getId(); } @@ -226,7 +208,6 @@ public class InteractionTeleport extends HabboItem { } public void startTeleport(Room room, Habbo habbo, int delay) { - /// dont teleport if we are already teleporting if (habbo.getRoomUnit().isTeleporting) return; 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 1f6fdfe5..7dd1b524 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -4318,60 +4318,6 @@ public class Room implements Comparable, ISerialize, Runnable { return FurnitureMovementError.NO_RIGHTS; } - public HabboItem OverrideItem(HabboItem p_Item, Habbo p_Owner) - { - if (p_Item instanceof InteractionTeleport) - { - TIntObjectIterator l_Itr = this.roomItems.iterator(); - - for (int l_I = 0; l_I < this.roomItems.size(); l_I++) - { - l_Itr.advance(); - - if (l_Itr.value() instanceof InteractionTeleport) - { - InteractionTeleport l_Item = (InteractionTeleport)l_Itr.value(); - - /// If the item matches our hand item, then we have the correct item - if (p_Item.getId() == l_Item.getTargetId()) - { - return p_Item; - } - - /// If the pair item is not placed in the room, check whether its placed in any other rooms - if (this.getHabboItem(l_Item.getTargetId()) == null) - { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM items WHERE id = ?")) - { - statement.setInt(1, l_Item.getTargetId()); - try (ResultSet set = statement.executeQuery()) - { - set.next(); - - /// Check if pair item is placed in any rooms, if not then return that i - if (set.getInt("room_id") == 0) - { - HabboItem l_HandItem = p_Owner.getInventory().getItemsComponent().getHabboItem(l_Item.getTargetId()); - - if (l_HandItem != null) - { - return l_HandItem; - } - } - } - } - catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - } - } - } - } - - return p_Item; - } - - public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) { if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation)) return FurnitureMovementError.INVALID_MOVE; @@ -4422,14 +4368,6 @@ public class Room implements Comparable, ISerialize, Runnable { return fits; } - if (item instanceof InteractionTeleport) - { - InteractionTeleport l_Test = (InteractionTeleport)item; - int hello = 0; - } - - item = this.OverrideItem(item, owner); - item.setZ(tile.getStackHeight()); item.setX(tile.x); item.setY(tile.y); diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 31cf5d0a..036ce89c 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -65,9 +65,8 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); - targetRoom.updateHabbo(this.client.getHabbo()); - //System.out.println(targetTeleport.getX() + " | " + tokay so basically - // after goargetTeleport.getY()); + //targetRoom.updateHabbo(this.client.getHabbo()); + //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom); //Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500); Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500);