diff --git a/Emulator/pom.xml b/Emulator/pom.xml index 850f932..cf63987 100644 --- a/Emulator/pom.xml +++ b/Emulator/pom.xml @@ -69,9 +69,7 @@ maven-javadoc-plugin 3.2.0 - - -Xdoclint:none - + -Xdoclint:none public @@ -106,9 +104,9 @@ - com.mysql - mysql-connector-j - 8.3.0 + mysql + mysql-connector-java + 8.0.22 runtime diff --git a/Emulator/src/main/java/com/eu/habbo/Emulator.java b/Emulator/src/main/java/com/eu/habbo/Emulator.java index 9dc8065..0968e22 100644 --- a/Emulator/src/main/java/com/eu/habbo/Emulator.java +++ b/Emulator/src/main/java/com/eu/habbo/Emulator.java @@ -36,8 +36,8 @@ public final class Emulator { private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown"); public final static int MAJOR = 3; - public final static int MINOR = 5; - public final static int BUILD = 1; + public final static int MINOR = 6; + public final static int BUILD = 0; public final static String PREVIEW = ""; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; @@ -48,8 +48,8 @@ public final class Emulator { "██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" + "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" + "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" + - "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" ; - + "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" + + "Still Rocking in 2024.\n"; public static String build = ""; public static boolean isReady = false; @@ -115,11 +115,13 @@ public final class Emulator { System.out.println("Warning, this is a beta build, this means that there may be unintended consequences so make sure you take regular backups while using this build. If you notice any issues you should make an issue on the Krews Git."); promptEnterKey(); } - LOGGER.info("eek. Has it really been a year?"); + System.out.println(""); + LOGGER.warn("Arcturus Morningstar 3.x is no longer accepting merge requests. Please target MS4 branches if you wish to contribute."); + LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community, "); + System.out.println(""); LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); LOGGER.info("Version: {}", version); LOGGER.info("Build: {}", build); - LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community"); long startTime = System.nanoTime(); diff --git a/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java b/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java index a2e8bac..d840b68 100644 --- a/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java +++ b/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java @@ -22,7 +22,6 @@ class DatabasePool { DatabasePool() { // Private constructor for singleton pattern } - public static synchronized DatabasePool getInstance() { if (instance == null) { instance = new DatabasePool(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java index c8d015e..b266111 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -183,6 +183,10 @@ public class CatalogItem implements ISerialize, Runnable, Comparable { - ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); - YoutubePlaylist playlist; - try { playlist = this.getPlaylistDataById(playlistId); if (playlist != null) { - playlists.add(playlist); + this.addPlaylistToItem(itemId, playlist); } } catch (IOException e) { LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); } - - this.playlists.put(itemId, playlists); }); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 166768c..f2541e1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -16,11 +16,12 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashMap; public abstract class InteractionWired extends InteractionDefault { private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class); private long cooldown; - private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); + private final HashMap userExecutionCache = new HashMap<>(); InteractionWired(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -76,8 +77,10 @@ public abstract class InteractionWired extends InteractionDefault { } public void activateBox(Room room, RoomUnit roomUnit, long millis) { - this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); - room.sendComposer(new ItemStateComposer(this).compose()); + if(!room.isHideWired()) { + this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); + room.sendComposer(new ItemStateComposer(this).compose()); + } if (roomUnit != null) { this.addUserExecutionCache(roomUnit.getId(), millis); } @@ -112,7 +115,7 @@ public abstract class InteractionWired extends InteractionDefault { } else { if (this.userExecutionCache.containsKey((long)roomUnitId)) { long lastTimestamp = this.userExecutionCache.get((long)roomUnitId); - if (timestamp - lastTimestamp < 100L) { + if (timestamp - lastTimestamp < Math.max(100L, this.requiredCooldown())) { return false; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index f43ffac..d7e6af0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -125,10 +125,16 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy @Override public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) { + long currentMillis = System.currentTimeMillis(); + String Key = Double.toString(this.getX()) + Double.toString(this.getY()); + + room.repeatersLastTick.putIfAbsent(Key, currentMillis); + + if (this.counter >= this.repeatTime && room.repeatersLastTick.get(Key) < currentMillis - 450) { this.counter = 0; if (this.getRoomId() != 0) { if (room.isLoaded()) { + room.repeatersLastTick.put(Key, currentMillis); WiredHandler.handle(this, null, room, new Object[]{this}); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 536aca8..0723ba1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -119,10 +119,16 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements @Override public void cycle(Room room) { this.counter += 500; - if (this.counter >= this.repeatTime) { + long currentMillis = System.currentTimeMillis(); + String Key = Double.toString(this.getX()) + Double.toString(this.getY()); + + room.repeatersLastTick.putIfAbsent(Key, currentMillis); + + if (this.counter >= this.repeatTime && room.repeatersLastTick.get(Key) < currentMillis - 4950) { this.counter = 0; if (this.getRoomId() != 0) { if (room.isLoaded()) { + room.repeatersLastTick.put(Key, currentMillis); WiredHandler.handle(this, null, room, new Object[]{this}); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 791d12d..68168d6 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -194,6 +194,10 @@ public class WordFilter { } } + public THashSet getWords() { + return new THashSet<>(this.words); + } + public void addWord(WordFilterWord word) { this.words.add(word); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 119df29..e98dd69 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -213,6 +213,7 @@ public class Room implements Comparable, ISerialize, Runnable { private TraxManager traxManager; private boolean cycleOdd; private long cycleTimestamp; + public Map repeatersLastTick = new HashMap<>(); public Room(ResultSet set) throws SQLException { this.id = set.getInt("id"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index 6fc98bb..27fbec4 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -8,14 +8,19 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Arrays; import java.util.List; + public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomChatMessage.class); private static final String QUERY = "INSERT INTO chatlogs_room (user_from_id, user_to_id, message, timestamp, room_id) VALUES (?, ?, ?, ?, ?)"; + private static final List chatColors = Arrays.asList("@red@", "@cyan@", "@blue@", "@green@", "@purple@"); public static int MAXIMUM_LENGTH = 100; //Configuration. Loaded from database & updated accordingly. @@ -32,11 +37,10 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { private RoomChatMessageBubbles bubble; private Habbo targetHabbo; private byte emotion; - private String RoomChatColour; //Added ChatColor - + private String RoomChatColour; + ; //Added ChatColor public RoomChatMessage(MessageHandler message) { - if (message.packet.getMessageId() == Incoming.RoomUserWhisperEvent) { String data = message.packet.readString(); this.targetHabbo = message.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(data.split(" ")[0]); @@ -44,14 +48,13 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { } else { this.message = message.packet.readString(); } - try { this.bubble = RoomChatMessageBubbles.getBubble(message.packet.readInt()); } catch (Exception e) { this.bubble = RoomChatMessageBubbles.NORMAL; } - this.RoomChatColour = message.packet.readString(); // Added for Room Chat Colour + this.RoomChatColour = message.packet.readString(); if (!message.client.getHabbo().hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { @@ -138,7 +141,8 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { try { this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH - 1); } catch (Exception e) { - } + LOGGER.error("Caught exception", e); + } } Emulator.getDatabaseLogger().store(this); @@ -174,8 +178,6 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { @Override public void serialize(ServerMessage message) { - - if (this.habbo != null && this.bubble.isOverridable()) { if (!this.habbo.hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { @@ -199,10 +201,10 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { message.appendInt(this.getEmotion()); message.appendInt(this.getBubble().getType()); message.appendInt(0); - message.appendString(this.RoomChatColour); //Added packet for Room Chat Color + message.appendString(this.RoomChatColour); //Added packet for room chat message.appendInt(this.getMessage().length()); - } catch (Exception e) { + LOGGER.error("Caught exception", e); } } @@ -225,6 +227,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { if (muteTime > 0) { this.habbo.mute(muteTime, false); } else { + LOGGER.error("Invalid hotel.wordfilter.automute defined in emulator_settings ({}).", muteTime); } } @@ -258,4 +261,4 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { statement.addBatch(); } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index f70f3d3..7459e42 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -275,7 +275,13 @@ public class RoomLayout { RoomTile doorTile = this.room.getLayout().getDoorTile(); + long startMillis = System.currentTimeMillis(); + while (!openList.isEmpty()) { + if (System.currentTimeMillis() - startMillis > Emulator.getConfig().getInt("pathfinder.execution_time.milli", 25) && Emulator.getConfig().getBoolean("pathfinder.max_execution_time.enabled", false)) { + return null; + } + RoomTile current = this.lowestFInOpen(openList); if (current.x == newTile.x && current.y == newTile.y) { return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index ab50771..3bf26bc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -294,6 +294,10 @@ public class RoomManager { public Room loadRoom(int id, boolean loadData) { Room room = null; + if(id == 0) { + return null; + } + if (this.activeRooms.containsKey(id)) { room = this.activeRooms.get(id); @@ -414,7 +418,7 @@ public class RoomManager { public RoomLayout loadLayout(String name, Room room) { RoomLayout layout = null; - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name LIKE ? LIMIT 1")) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name = ? LIMIT 1")) { statement.setString(1, name); try (ResultSet set = statement.executeQuery()) { if (set.next()) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index f867a8a..ddccb55 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -118,10 +118,15 @@ public class Habbo implements Runnable { public boolean connect() { String ip = ""; + String ProxyIP = ""; if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { SocketAddress address = this.client.getChannel().remoteAddress(); ip = ((InetSocketAddress) address).getAddress().getHostAddress(); + ProxyIP = "- no proxy server used"; + } else { + SocketAddress address = this.client.getChannel().remoteAddress(); + ProxyIP = ((InetSocketAddress) address).getAddress().getHostAddress(); } if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) { @@ -135,6 +140,12 @@ public class Habbo implements Runnable { this.habboInfo.setIpLogin(ip); } + if (this.client.getMachineId() == null || this.client.getMachineId().length() == 0) { + return false; + } + + this.habboInfo.setMachineID(this.client.getMachineId()); + if (Emulator.getGameEnvironment().getModToolManager().hasMACBan(this.client)) { return false; } @@ -149,7 +160,8 @@ public class Habbo implements Runnable { this.messenger.connectionChanged(this, true, false); Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); - LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); + LOGGER.info("{} logged in from IP {} using proxyserver {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin(), ProxyIP); + LOGGER.info("{} client MachineId = {}", this.habboInfo.getUsername(), this.client.getMachineId()); return true; } @@ -441,18 +453,23 @@ public class Habbo implements Runnable { } public void clearCaches() { - int timestamp = Emulator.getIntUnixTimestamp(); - THashMap> newLog = new THashMap<>(); - for (Map.Entry> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) { - for (Integer time : ltdLog.getValue()) { - if (time > timestamp) { - if (!newLog.containsKey(ltdLog.getKey())) { - newLog.put(ltdLog.getKey(), new ArrayList<>()); - } + int currentTimestamp = Emulator.getIntUnixTimestamp(); + int twentyFourHoursInSeconds = 24 * 60 * 60; // 24 hours in seconds - newLog.get(ltdLog.getKey()).add(time); + THashMap> newLog = new THashMap<>(); + + for (Map.Entry> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) { + List filteredTimestamps = new ArrayList<>(); + + for (Integer time : ltdLog.getValue()) { + if (currentTimestamp - time <= twentyFourHoursInSeconds) { + filteredTimestamps.add(time); } } + + if (!filteredTimestamps.isEmpty()) { + newLog.put(ltdLog.getKey(), filteredTimestamps); + } } this.habboStats.ltdPurchaseLog = newLog; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 462af84..29ef2a2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -102,7 +102,7 @@ public class HabboStats implements Runnable { public THashSet subscriptions; private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException { - this.cache = new THashMap<>(0); + this.cache = new THashMap<>(1000); this.achievementProgress = new THashMap<>(0); this.achievementCache = new THashMap<>(0); this.recentPurchases = new THashMap<>(0); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 1d2b20f..955cf26 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -234,7 +234,7 @@ public class WiredHandler { executed = true; if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { Emulator.getThreading().run(() -> { - if (room.isLoaded()) { + if (room.isLoaded() && room.getHabbos().size() > 0) { try { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index e7cf9ce..d1769ac 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -154,6 +154,18 @@ public class WiredHighscoreManager { return false; } + public HashMap> getData() { + return this.data; + } + + public List getEntriesForItemId(int itemId) { + return this.data.get(itemId); + } + + public void setEntriesForItemId(int itemId, List entries) { + this.data.put(itemId, entries); + } + private long getTodayStartTimestamp() { return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond(); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java index 9949ffa..57ab3ad 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java @@ -2,12 +2,14 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.handshake.MachineIDComposer; -import com.eu.habbo.util.HexUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @NoAuthMessage public class MachineIDEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(MachineIDEvent.class); + private static final int HASH_LENGTH = 64; @Override @@ -16,13 +18,12 @@ public class MachineIDEvent extends MessageHandler { String clientFingerprint = this.packet.readString(); String capabilities = this.packet.readString(); - // Update stored machine id if it doesn't match our requirements. - if (storedMachineId.startsWith("~") || storedMachineId.length() != HASH_LENGTH) { - storedMachineId = HexUtils.getRandom(HASH_LENGTH); - this.client.sendResponse(new MachineIDComposer(storedMachineId)); + if (storedMachineId.length() > HASH_LENGTH) { + storedMachineId = storedMachineId.substring(0, HASH_LENGTH); } this.client.setMachineId(storedMachineId); - } -} + LOGGER.debug("Setting client MachineId to {}", storedMachineId); + } +} \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index a8a24ed..e8dbd93 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -11,6 +11,9 @@ import gnu.trove.procedure.TIntObjectProcedure; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.List; + public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure { private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); @@ -48,7 +51,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.response.appendInt(habboItem.getId()); this.response.appendInt(habboItem.getBaseItem().getSpriteId()); - if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { + if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("song_disk") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { switch (habboItem.getBaseItem().getName()) { case "landscape": this.response.appendInt(4); @@ -62,10 +65,11 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec case "poster": this.response.appendInt(6); break; + case "song_disk": + this.response.appendInt(8); + break; } - - this.response.appendInt(0); - this.response.appendString(habboItem.getExtradata()); + this.addExtraDataToResponse(habboItem); } else { if (habboItem.getBaseItem().getName().equals("gnome_box")) this.response.appendInt(13); @@ -82,12 +86,25 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.response.appendBoolean(true); this.response.appendInt(-1); + if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { this.response.appendString(""); + if(habboItem.getBaseItem().getName().equals("song_disk")) { + List extraDataAsList = Arrays.asList(habboItem.getExtradata().split("\n")); + this.response.appendInt(Integer.valueOf(extraDataAsList.get(extraDataAsList.size() - 1))); + return true; + } this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); } + + return true; } -} + public void addExtraDataToResponse(HabboItem habboItem) { + this.response.appendInt(0); + this.response.appendString(habboItem.getExtradata()); + } + +} \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index a6d5d64..9da42a6 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -8,6 +8,8 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import java.util.Objects; + public class UpdateStackHeightComposer extends MessageComposer { private int x; private int y; @@ -34,6 +36,7 @@ public class UpdateStackHeightComposer extends MessageComposer { //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done this.response.init(Outgoing.UpdateStackHeightComposer); if (this.updateTiles != null) { + this.updateTiles.removeIf(Objects::isNull); // prevent overflow. Byte max value is 127 if(this.updateTiles.size() > 127) { RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index c85f331..e593600 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -7,11 +7,18 @@ import com.eu.habbo.threading.runnables.ChannelReadHandler; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.TooLongFrameException; +import io.netty.handler.codec.UnsupportedMessageTypeException; +import io.netty.handler.ssl.NotSslRecordException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; import java.io.IOException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; @ChannelHandler.Sharable public class GameMessageHandler extends ChannelInboundHandlerAdapter { @@ -60,13 +67,34 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { return; } if (Emulator.getConfig().getBoolean("debug.mode")) { - if (cause instanceof TooLongFrameException) { - LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); - } else { - LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); + if (cause instanceof NotSslRecordException) { + LOGGER.error("Plaintext received instead of ssl, closing channel"); + } + else if (cause instanceof DecoderException) { + LOGGER.error("Plaintext received instead of ssl, closing channel"); + } + else if (cause instanceof TooLongFrameException) { + LOGGER.error("Disconnecting client, reason " + cause.getMessage()); + } + else if (cause instanceof SSLHandshakeException) { + LOGGER.error("URL Request error from source " + ctx.channel().remoteAddress()); + } + else if (cause instanceof NoSuchAlgorithmException) { + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); + } + else if (cause instanceof KeyManagementException) { + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); + } + else if (cause instanceof UnsupportedMessageTypeException) { + LOGGER.error("There was an illegal SSL request from (X-forwarded-for/CF-Connecting-IP has not being injected yet!) " + ctx.channel().remoteAddress()); + } + else if (cause instanceof SSLException) { + LOGGER.error("SSL Problem: "+ cause.getMessage() + cause); + } + else { + LOGGER.error("Disconnecting client, exception in GameMessageHandler.", cause); } } ctx.channel().close(); } - -} \ No newline at end of file +} diff --git a/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar b/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar index c405cb1..b07c9c0 100644 Binary files a/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar and b/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar differ