Start Re-Base: start from 5.3.4

This commit is contained in:
DuckieTM 2024-04-06 21:00:17 +02:00
parent 91cb726c03
commit 4610904002
25 changed files with 187 additions and 72 deletions

View File

@ -69,9 +69,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
<additionalOptions><additionalOption>-Xdoclint:none</additionalOption></additionalOptions>
<show>public</show>
</configuration>
</plugin>
@ -106,9 +104,9 @@
<!-- MySQL Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.3.0</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
<scope>runtime</scope>
</dependency>

View File

@ -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();

View File

@ -22,7 +22,6 @@ class DatabasePool {
DatabasePool() {
// Private constructor for singleton pattern
}
public static synchronized DatabasePool getInstance() {
if (instance == null) {
instance = new DatabasePool();

View File

@ -183,6 +183,10 @@ public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem
return this.orderNumber;
}
public void setNeedsUpdate(boolean needsUpdate) {
this.needsUpdate = needsUpdate;
}
public synchronized void sellRare() {
this.limitedSells++;

View File

@ -674,9 +674,13 @@ public class CatalogManager {
page = this.getCatalogPage(pageId);
if (page == null)
return false;
page.getCatalogItems().put(item.getId(), item);
item.setPageId(pageId);
item.setNeedsUpdate(true);
item.run();
return true;
@ -898,7 +902,9 @@ public class CatalogManager {
boolean badgeFound = false;
for (int i = 0; i < amount; i++) {
habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp());
if(item.isLimited()) {
habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp());
}
for (Item baseItem : item.getBaseItems()) {
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) {

View File

@ -27,7 +27,7 @@ public class AddYoutubePlaylistCommand extends Command {
int itemId;
try {
itemId = Integer.valueOf(params[1]);
itemId = Integer.parseInt(params[1]);
} catch (NumberFormatException e) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item"));
return true;
@ -45,7 +45,7 @@ public class AddYoutubePlaylistCommand extends Command {
return true;
}
Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.valueOf(params[1]), playlist);
Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.parseInt(params[1]), playlist);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `youtube_playlists` (`item_id`, `playlist_id`) VALUES (?, ?)")) {
statement.setInt(1, itemId);

View File

@ -62,7 +62,7 @@ public class CommandHandler {
public static boolean handleCommand(GameClient gameClient, String commandLine) {
if (gameClient != null) {
if (gameClient != null && commandLine != null) {
if (commandLine.startsWith(":")) {
commandLine = commandLine.replaceFirst(":", "");

View File

@ -95,20 +95,15 @@ public class YoutubeManager {
final String playlistId = set.getString("playlist_id");
youtubeDataLoaderPool.submit(() -> {
ArrayList<YoutubePlaylist> 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);
});
}
}

View File

@ -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<Long,Long> 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;
}
}

View File

@ -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});
}
}

View File

@ -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});
}
}

View File

@ -194,6 +194,10 @@ public class WordFilter {
}
}
public THashSet<WordFilterWord> getWords() {
return new THashSet<>(this.words);
}
public void addWord(WordFilterWord word) {
this.words.add(word);
}

View File

@ -213,6 +213,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private TraxManager traxManager;
private boolean cycleOdd;
private long cycleTimestamp;
public Map<String, Long> repeatersLastTick = new HashMap<>();
public Room(ResultSet set) throws SQLException {
this.id = set.getInt("id");

View File

@ -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<String> 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);
}
}

View File

@ -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);

View File

@ -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()) {

View File

@ -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<Integer, List<Integer>> newLog = new THashMap<>();
for (Map.Entry<Integer, List<Integer>> 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<Integer, List<Integer>> newLog = new THashMap<>();
for (Map.Entry<Integer, List<Integer>> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) {
List<Integer> 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;

View File

@ -102,7 +102,7 @@ public class HabboStats implements Runnable {
public THashSet<Subscription> 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);

View File

@ -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);

View File

@ -154,6 +154,18 @@ public class WiredHighscoreManager {
return false;
}
public HashMap<Integer, List<WiredHighscoreDataEntry>> getData() {
return this.data;
}
public List<WiredHighscoreDataEntry> getEntriesForItemId(int itemId) {
return this.data.get(itemId);
}
public void setEntriesForItemId(int itemId, List<WiredHighscoreDataEntry> entries) {
this.data.put(itemId, entries);
}
private long getTodayStartTimestamp() {
return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond();
}

View File

@ -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);
}
}

View File

@ -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<HabboItem> {
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<String> 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());
}
}

View File

@ -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()]);

View File

@ -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();
}
}