From 4748c033adbd2a851e8ba02dfe6884b9863537d7 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Sun, 3 May 2020 01:46:07 +0200 Subject: [PATCH 01/12] Dependencies and logging progress --- pom.xml | 72 +--- src/main/java/com/eu/habbo/Emulator.java | 87 +++-- .../java/com/eu/habbo/core/CleanerThread.java | 62 +--- .../java/com/eu/habbo/core/CommandLog.java | 12 +- .../eu/habbo/core/ConfigurationManager.java | 40 +-- .../com/eu/habbo/core/CreditsScheduler.java | 6 +- .../{Loggable.java => DatabaseLoggable.java} | 8 +- .../com/eu/habbo/core/DatabaseLogger.java | 46 +++ src/main/java/com/eu/habbo/core/ErrorLog.java | 16 +- .../eu/habbo/core/GotwPointsScheduler.java | 6 +- src/main/java/com/eu/habbo/core/Logging.java | 338 ------------------ .../com/eu/habbo/core/PixelScheduler.java | 6 +- .../com/eu/habbo/core/PointsScheduler.java | 6 +- .../java/com/eu/habbo/core/TextsManager.java | 25 +- .../core/consolecommands/ConsoleCommand.java | 12 +- .../eu/habbo/crypto/HabboDiffieHellman.java | 2 +- .../com/eu/habbo/crypto/utils/HexUtils.java | 27 -- .../java/com/eu/habbo/database/Database.java | 20 +- .../eu/habbo/habbohotel/GameEnvironment.java | 16 +- .../achievements/AchievementManager.java | 18 +- .../achievements/TalentTrackLevel.java | 2 +- .../com/eu/habbo/habbohotel/bots/Bot.java | 2 +- .../eu/habbo/habbohotel/bots/BotManager.java | 22 +- .../eu/habbo/habbohotel/bots/ButlerBot.java | 2 +- .../habbo/habbohotel/catalog/CatalogItem.java | 6 +- .../catalog/CatalogLimitedConfiguration.java | 6 +- .../habbohotel/catalog/CatalogManager.java | 63 ++-- .../habbo/habbohotel/catalog/CatalogPage.java | 2 +- .../eu/habbo/habbohotel/catalog/Voucher.java | 4 +- .../catalog/layouts/RoomBundleLayout.java | 4 +- .../catalog/marketplace/MarketPlace.java | 18 +- .../catalog/marketplace/MarketPlaceOffer.java | 6 +- .../commands/AddYoutubePlaylistCommand.java | 2 +- .../habbohotel/commands/BadgeCommand.java | 2 +- .../habbohotel/commands/CommandHandler.java | 18 +- .../habbohotel/commands/EnableCommand.java | 2 +- .../commands/FilterWordCommand.java | 2 +- .../commands/RoomBundleCommand.java | 2 +- .../habbohotel/crafting/CraftingManager.java | 4 +- .../habbohotel/gameclients/GameClient.java | 14 +- .../com/eu/habbo/habbohotel/games/Game.java | 2 +- .../games/battlebanzai/BattleBanzaiGame.java | 2 +- .../habbohotel/games/freeze/FreezeGame.java | 2 +- .../com/eu/habbo/habbohotel/guilds/Guild.java | 4 +- .../habbo/habbohotel/guilds/GuildManager.java | 44 +-- .../habbohotel/guilds/forums/ForumThread.java | 10 +- .../guilds/forums/ForumThreadComment.java | 6 +- .../habbohotel/hotelview/HallOfFame.java | 2 +- .../hotelview/HotelViewManager.java | 11 +- .../habbo/habbohotel/hotelview/NewsList.java | 2 +- .../habbohotel/items/CrackableReward.java | 2 +- .../habbo/habbohotel/items/ItemManager.java | 61 ++-- .../habbohotel/items/YoutubeManager.java | 6 +- .../interactions/InteractionColorPlate.java | 2 +- .../InteractionRentableSpace.java | 4 +- .../items/interactions/InteractionWired.java | 2 +- .../InteractionWiredHighscore.java | 6 +- .../games/InteractionGameTimer.java | 4 +- .../WiredConditionHabboHasHandItem.java | 2 +- .../wired/effects/WiredEffectMatchFurni.java | 2 +- .../wired/effects/WiredEffectToggleFurni.java | 2 +- .../effects/WiredEffectToggleRandom.java | 2 +- .../triggers/WiredTriggerBotReachedFurni.java | 2 +- .../habbo/habbohotel/messenger/Message.java | 2 +- .../habbo/habbohotel/messenger/Messenger.java | 26 +- .../habbohotel/messenger/MessengerBuddy.java | 6 +- .../habbo/habbohotel/modtool/ModToolBan.java | 2 +- .../habbohotel/modtool/ModToolManager.java | 40 +-- .../habbohotel/modtool/ModToolSanctions.java | 14 +- .../habbo/habbohotel/modtool/WordFilter.java | 6 +- .../navigation/NavigatorManager.java | 22 +- .../permissions/PermissionsManager.java | 6 +- .../eu/habbo/habbohotel/pets/GnomePet.java | 2 +- .../eu/habbo/habbohotel/pets/HorsePet.java | 2 +- .../habbohotel/pets/MonsterplantPet.java | 2 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 2 +- .../eu/habbo/habbohotel/pets/PetManager.java | 26 +- .../habbo/habbohotel/polls/PollManager.java | 4 +- .../habbohotel/rooms/CustomRoomLayout.java | 2 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 94 ++--- .../eu/habbo/habbohotel/rooms/RoomBan.java | 4 +- .../habbohotel/rooms/RoomChatMessage.java | 23 +- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 2 +- .../habbo/habbohotel/rooms/RoomManager.java | 53 +-- .../habbo/habbohotel/rooms/RoomPromotion.java | 2 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 2 +- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 2 +- .../habbo/habbohotel/rooms/TraxManager.java | 10 +- .../com/eu/habbo/habbohotel/users/Habbo.java | 4 +- .../eu/habbo/habbohotel/users/HabboBadge.java | 2 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 16 +- .../habbohotel/users/HabboInventory.java | 12 +- .../eu/habbo/habbohotel/users/HabboItem.java | 6 +- .../habbo/habbohotel/users/HabboManager.java | 30 +- .../users/HabboNavigatorWindowSettings.java | 4 +- .../eu/habbo/habbohotel/users/HabboStats.java | 16 +- .../users/cache/HabboOfferPurchase.java | 2 +- .../users/inventory/BadgesComponent.java | 8 +- .../users/inventory/BotsComponent.java | 2 +- .../users/inventory/EffectsComponent.java | 10 +- .../users/inventory/ItemsComponent.java | 4 +- .../users/inventory/PetsComponent.java | 2 +- .../users/inventory/WardrobeComponent.java | 4 +- .../habbo/habbohotel/wired/WiredHandler.java | 8 +- .../highscores/WiredHighscoreManager.java | 6 +- .../com/eu/habbo/messages/PacketManager.java | 26 +- .../com/eu/habbo/messages/ServerMessage.java | 51 ++- .../camera/CameraPublishToWebEvent.java | 2 +- .../catalog/CatalogBuyItemAsGiftEvent.java | 4 +- .../incoming/friends/FriendRequestEvent.java | 2 +- .../guilds/forums/GuildForumListEvent.java | 4 +- .../incoming/handshake/SecureLoginEvent.java | 2 +- .../hotelview/HotelViewDataEvent.java | 2 +- .../inventory/RequestInventoryItemsEvent.java | 2 +- .../navigator/RequestDeleteRoomEvent.java | 2 +- .../RequestNewNavigatorRoomsEvent.java | 4 +- .../incoming/polls/AnswerPollEvent.java | 2 +- .../incoming/polls/CancelPollEvent.java | 2 +- .../rooms/items/RedeemClothingEvent.java | 2 +- .../rooms/items/ToggleFloorItemEvent.java | 2 +- .../rooms/items/UseRandomStateItemEvent.java | 2 +- .../rooms/pets/CompostMonsterplantEvent.java | 2 +- .../rooms/pets/HorseRemoveSaddleEvent.java | 2 +- .../rooms/users/RoomUserWalkEvent.java | 2 +- .../users/ConfirmChangeNameEvent.java | 2 +- .../achievements/AchievementListComposer.java | 2 +- .../catalog/CatalogPagesListComposer.java | 2 +- .../MarketplaceOwnItemsComposer.java | 2 +- .../outgoing/friends/FriendsComposer.java | 2 +- .../guilds/forums/GuildForumDataComposer.java | 2 +- .../inventory/InventoryItemsComposer.java | 2 +- .../modtool/ModToolUserInfoComposer.java | 2 +- .../navigator/PrivateRoomsComposer.java | 2 +- .../users/ProfileFriendsComposer.java | 4 +- .../outgoing/users/UserCurrencyComposer.java | 2 +- .../outgoing/users/UserProfileComposer.java | 2 +- .../habbo/messages/rcon/ExecuteCommand.java | 2 +- .../com/eu/habbo/messages/rcon/GiveBadge.java | 2 +- .../eu/habbo/messages/rcon/GiveCredits.java | 2 +- .../eu/habbo/messages/rcon/GivePixels.java | 2 +- .../eu/habbo/messages/rcon/GivePoints.java | 2 +- .../eu/habbo/messages/rcon/GiveRespect.java | 2 +- .../habbo/messages/rcon/GiveUserClothing.java | 2 +- .../eu/habbo/messages/rcon/IgnoreUser.java | 2 +- .../com/eu/habbo/messages/rcon/MuteUser.java | 2 +- .../com/eu/habbo/messages/rcon/SendGift.java | 2 +- .../com/eu/habbo/messages/rcon/SetMotto.java | 2 +- .../eu/habbo/messages/rcon/UpdateUser.java | 2 +- .../java/com/eu/habbo/networking/Server.java | 16 +- .../habbo/networking/camera/CameraClient.java | 12 +- .../camera/CameraPacketHandler.java | 2 +- .../incoming/CameraLoginStatusEvent.java | 31 +- .../incoming/CameraUpdateNotification.java | 12 +- .../decoders/GameMessageHandler.java | 2 +- .../encoders/GameServerMessageLogger.java | 13 +- .../networking/rconserver/RCONServer.java | 16 +- .../rconserver/RCONServerHandler.java | 13 +- .../com/eu/habbo/plugin/PluginManager.java | 35 +- .../com/eu/habbo/threading/ThreadPooling.java | 16 +- .../runnables/CameraClientAutoReconnect.java | 12 +- .../runnables/InsertModToolIssue.java | 7 +- .../habbo/threading/runnables/OpenGift.java | 2 +- .../runnables/QueryDeleteHabboBadge.java | 2 +- .../runnables/QueryDeleteHabboItem.java | 2 +- .../runnables/QueryDeleteHabboItems.java | 2 +- .../threading/runnables/RoomUnitTeleport.java | 2 +- .../RoomUnitTeleportWalkToAction.java | 2 +- .../RoomUnitVendingMachineAction.java | 2 +- .../threading/runnables/SaveScoreForTeam.java | 2 +- .../runnables/TeleportInteraction.java | 2 +- .../runnables/UpdateModToolIssue.java | 2 +- .../freeze/FreezeHandleSnowballExplosion.java | 2 +- .../runnables/hopper/HopperActionTwo.java | 2 +- .../runnables/teleport/TeleportActionTwo.java | 2 +- src/main/java/com/eu/habbo/util/HexUtils.java | 57 +++ .../habbo/util/callback/HTTPVersionCheck.java | 2 +- .../habbo/util/imager/badges/BadgeImager.java | 22 +- 177 files changed, 963 insertions(+), 1180 deletions(-) rename src/main/java/com/eu/habbo/core/{Loggable.java => DatabaseLoggable.java} (71%) create mode 100644 src/main/java/com/eu/habbo/core/DatabaseLogger.java delete mode 100644 src/main/java/com/eu/habbo/core/Logging.java delete mode 100644 src/main/java/com/eu/habbo/crypto/utils/HexUtils.java create mode 100644 src/main/java/com/eu/habbo/util/HexUtils.java diff --git a/pom.xml b/pom.xml index 1389b284..68c85820 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 + 3.8.1 1.8 1.8 @@ -42,7 +42,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.4.1 + 3.3.0 jar-with-dependencies @@ -67,7 +67,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.0 + 3.2.0 -Xdoclint:none public @@ -92,50 +92,21 @@ io.netty netty-all - 4.1.36.Final - - - - - org.fusesource.jansi - jansi - 1.18 - - - - - io.netty - netty-codec-http - 4.1.36.Final - compile - - - - io.netty - netty-codec-http2 - 4.1.36.Final - compile - - - - io.netty - netty-handler - 4.1.36.Final - compile + 4.1.49.Final com.google.code.gson gson - 2.8.4 + 2.8.6 mysql mysql-connector-java - 5.1.46 + 5.1.49 runtime @@ -151,16 +122,17 @@ com.zaxxer HikariCP - 3.1.0 + 3.4.3 compile org.apache.commons commons-lang3 - 3.7 + 3.10 compile + org.apache.commons commons-math3 @@ -171,35 +143,21 @@ org.jsoup jsoup - 1.11.3 + 1.13.1 compile - org.slf4j - slf4j-api - 1.7.25 - - - - org.slf4j - slf4j-simple - 1.7.25 + ch.qos.logback + logback-classic + 1.2.3 + compile joda-time joda-time - 2.9.9 + 2.10.6 - - - - - internal.repo - Internal repo - file:///home/thara/testesb/in - - \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 4457d58a..8aece311 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -1,5 +1,6 @@ package com.eu.habbo; +import ch.qos.logback.classic.Level; import com.eu.habbo.core.*; import com.eu.habbo.core.consolecommands.ConsoleCommand; import com.eu.habbo.database.Database; @@ -14,7 +15,8 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent; import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent; import com.eu.habbo.threading.ThreadPooling; import com.eu.habbo.util.imager.badges.BadgeImager; -import org.fusesource.jansi.AnsiConsole; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; import java.security.MessageDigest; @@ -23,20 +25,17 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; public final class Emulator { + private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); public final static int MAJOR = 2; public final static int MINOR = 4; public final static int BUILD = 0; - public static final String ANSI_RED = "\u001B[31m"; - public static final String ANSI_BLUE = "\u001B[34m"; - public static final String ANSI_PURPLE = "\u001B[35m"; - public static final String ANSI_WHITE = "\u001B[37m"; - public static final String ANSI_YELLOW = "\u001B[33m"; -// This Build of 2.4.0 will not be released anytime soon. :) + // This Build of 2.4.0 will not be released anytime soon. :) public final static String PREVIEW = "RC-1"; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + "-" + PREVIEW; @@ -55,8 +54,6 @@ public final class Emulator { public static boolean isShuttingDown = false; public static boolean stopped = false; public static boolean debugging = false; - private static String classPath = System.getProperty("java.class.path"); - private static String osName = System.getProperty("os.name"); private static int timeStarted = 0; private static Runtime runtime; private static ConfigurationManager config; @@ -66,11 +63,10 @@ public final class Emulator { private static RCONServer rconServer; private static CameraClient cameraClient; private static Database database; - private static Logging logging; + private static DatabaseLogger databaseLogger; private static ThreadPooling threading; private static GameEnvironment gameEnvironment; private static PluginManager pluginManager; - private static Random random; private static BadgeImager badgeImager; static { @@ -85,21 +81,19 @@ public final class Emulator { public static void main(String[] args) throws Exception { try { - if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) { - AnsiConsole.systemInstall(); - } Locale.setDefault(new Locale("en")); setBuild(); Emulator.stopped = false; ConsoleCommand.load(); - Emulator.logging = new Logging(); - System.out.println(ANSI_PURPLE + logo ); - System.out.println(ANSI_WHITE + "This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); - System.out.println(ANSI_BLUE + "[VERSION] " + ANSI_WHITE + version); - System.out.println(ANSI_RED + "[BUILD] " + ANSI_WHITE + build + "\n"); - System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq" ); - System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Join our discord at https://discord.gg/syuqgN" + "\n"); - random = new Random(); + + System.out.println(logo); + + 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("Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq"); + LOGGER.info("Join our discord at https://discord.gg/syuqgN"); + long startTime = System.nanoTime(); Emulator.runtime = Runtime.getRuntime(); @@ -110,6 +104,7 @@ public final class Emulator { Emulator.getConfig().getValue("enc.n"), Emulator.getConfig().getValue("enc.d")); Emulator.database = new Database(Emulator.getConfig()); + Emulator.databaseLogger = new DatabaseLogger(); Emulator.config.loaded = true; Emulator.config.loadFromDatabase(); Emulator.threading = new ThreadPooling(Emulator.getConfig().getInt("runtime.threads")); @@ -129,13 +124,17 @@ public final class Emulator { Emulator.rconServer.initializePipeline(); Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version); - Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!"); - Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB"); + + LOGGER.info("Arcturus Morningstar has succesfully loaded."); + LOGGER.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2); + LOGGER.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024)); Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode"); + if (debugging) { - Emulator.getLogging().logDebugLine("Debugging Enabled!"); + ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + root.setLevel(Level.DEBUG); + LOGGER.debug("Debugging enabled."); } Emulator.getPluginManager().fireEvent(new EmulatorLoadedEvent()); @@ -143,7 +142,9 @@ public final class Emulator { Emulator.timeStarted = getIntUnixTimestamp(); if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) { - Emulator.getLogging().logStart("Emulator settings runtime.threads (" + Emulator.getConfig().getInt("runtime.threads") + ") can be increased to " + (Runtime.getRuntime().availableProcessors() * 2) + " to possibly increase performance."); + LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to {} to possibly increase performance.", + Emulator.getConfig().getInt("runtime.threads"), + Runtime.getRuntime().availableProcessors() * 2); } @@ -154,7 +155,6 @@ public final class Emulator { while (!isShuttingDown && isReady) { try { - String line = reader.readLine(); if (line != null) { @@ -163,7 +163,7 @@ public final class Emulator { System.out.println("Waiting for command: "); } catch (Exception e) { if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Error while reading command", e); } } } @@ -199,11 +199,12 @@ public final class Emulator { } private static void dispose() { - Emulator.getThreading().setCanAdd(false); Emulator.isShuttingDown = true; Emulator.isReady = false; - Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "..."); + + LOGGER.info("Stopping Arcturus Morningstar {}", version); + try { if (Emulator.getPluginManager() != null) Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent()); @@ -222,7 +223,6 @@ public final class Emulator { } catch (Exception e) { } - try { if (Emulator.gameEnvironment != null) Emulator.gameEnvironment.dispose(); @@ -241,8 +241,6 @@ public final class Emulator { } catch (Exception e) { } - Emulator.getLogging().saveLogs(); - try { if (Emulator.config != null) { Emulator.config.saveToDatabase(); @@ -255,16 +253,17 @@ public final class Emulator { Emulator.gameServer.stop(); } catch (Exception e) { } - Emulator.getLogging().logShutdownLine("Stopped Arcturus Emulator " + version + "..."); + + LOGGER.info("Stopped Arcturus Morningstar {}", version); if (Emulator.database != null) { Emulator.getDatabase().dispose(); } Emulator.stopped = true; - if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) { - AnsiConsole.systemUninstall(); - } + // if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) { + // AnsiConsole.systemUninstall(); + // } try { if (Emulator.threading != null) @@ -289,6 +288,10 @@ public final class Emulator { return database; } + public static DatabaseLogger getDatabaseLogger() { + return databaseLogger; + } + public static Runtime getRuntime() { return runtime; } @@ -301,10 +304,6 @@ public final class Emulator { return rconServer; } - public static Logging getLogging() { - return logging; - } - public static ThreadPooling getThreading() { return threading; } @@ -318,7 +317,7 @@ public final class Emulator { } public static Random getRandom() { - return random; + return ThreadLocalRandom.current(); } public static BadgeImager getBadgeImager() { @@ -361,7 +360,7 @@ public final class Emulator { try { res = format.parse(date); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Error parsing date", e); } return res; } diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java index 764770d0..b9a721dc 100644 --- a/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.friends.SearchUserEvent; import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent; import com.eu.habbo.threading.runnables.AchievementUpdater; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,57 +17,26 @@ import java.util.Map; public class CleanerThread implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(CleanerThread.class); - public static final int DELAY = 10000; - - - public static final int RELOAD_HALL_OF_FAME = 1800; - - - public static final int RELOAD_NEWS_LIST = 3600; - - - public static final int REMOVE_INACTIVE_ROOMS = 120; - - - public static final int REMOVE_INACTIVE_GUILDS = 60; - - - public static final int REMOVE_INACTIVE_TOURS = 600; - - - public static final int SAVE_ERROR_LOGS = 30; - - - public static final int CLEAR_CACHED_VALUES = 60 * 60; - - + private static final int DELAY = 10000; + private static final int RELOAD_HALL_OF_FAME = 1800; + private static final int RELOAD_NEWS_LIST = 3600; + private static final int REMOVE_INACTIVE_ROOMS = 120; + private static final int REMOVE_INACTIVE_GUILDS = 60; + private static final int REMOVE_INACTIVE_TOURS = 600; + private static final int SAVE_ERROR_LOGS = 30; + private static final int CLEAR_CACHED_VALUES = 60 * 60; private static final int CALLBACK_TIME = 60 * 15; - private static int LAST_HOF_RELOAD = Emulator.getIntUnixTimestamp(); - - private static int LAST_NL_RELOAD = Emulator.getIntUnixTimestamp(); - - private static int LAST_INACTIVE_ROOMS_CLEARED = Emulator.getIntUnixTimestamp(); - - private static int LAST_INACTIVE_GUILDS_CLEARED = Emulator.getIntUnixTimestamp(); - - private static int LAST_INACTIVE_TOURS_CLEARED = Emulator.getIntUnixTimestamp(); - - private static int LAST_ERROR_LOGS_SAVED = Emulator.getIntUnixTimestamp(); - - private static int LAST_DAILY_REFILL = Emulator.getIntUnixTimestamp(); - private static int LAST_CALLBACK = Emulator.getIntUnixTimestamp(); - - private static int LAST_HABBO_CACHE_CLEARED = Emulator.getIntUnixTimestamp(); public CleanerThread() { @@ -110,7 +81,7 @@ public class CleanerThread implements Runnable { } if (time - LAST_ERROR_LOGS_SAVED > SAVE_ERROR_LOGS) { - Emulator.getLogging().saveLogs(); + Emulator.getDatabaseLogger().save(); LAST_ERROR_LOGS_SAVED = time; } @@ -156,9 +127,10 @@ public class CleanerThread implements Runnable { statement.execute("DELETE FROM users_effects WHERE total <= 0"); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } - Emulator.getLogging().logStart("Database -> Cleaned!"); + + LOGGER.info("Database -> Cleaned!"); } public void refillDailyRespects() { @@ -167,7 +139,7 @@ public class CleanerThread implements Runnable { statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets")); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } if (Emulator.isReady) { @@ -188,7 +160,7 @@ public class CleanerThread implements Runnable { habbo.clearCaches(); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/CommandLog.java b/src/main/java/com/eu/habbo/core/CommandLog.java index 1f4cefbc..1dfb2847 100644 --- a/src/main/java/com/eu/habbo/core/CommandLog.java +++ b/src/main/java/com/eu/habbo/core/CommandLog.java @@ -6,8 +6,9 @@ import com.eu.habbo.habbohotel.commands.Command; import java.sql.PreparedStatement; import java.sql.SQLException; -public class CommandLog implements Loggable { - public static final String insertQuery = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)"; +public class CommandLog implements DatabaseLoggable { + + private static final String INSERT_QUERY = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)"; private final int userId; private final int timestamp = Emulator.getIntUnixTimestamp(); @@ -15,7 +16,6 @@ public class CommandLog implements Loggable { private final String params; private final boolean succes; - public CommandLog(int userId, Command command, String params, boolean succes) { this.userId = userId; this.command = command; @@ -23,6 +23,11 @@ public class CommandLog implements Loggable { this.succes = succes; } + @Override + public String getQuery() { + return CommandLog.INSERT_QUERY; + } + @Override public void log(PreparedStatement statement) throws SQLException { statement.setInt(1, this.userId); @@ -32,4 +37,5 @@ public class CommandLog implements Loggable { statement.setString(5, this.succes ? "yes" : "no"); statement.addBatch(); } + } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/src/main/java/com/eu/habbo/core/ConfigurationManager.java index 719fc4e4..29e50f73 100644 --- a/src/main/java/com/eu/habbo/core/ConfigurationManager.java +++ b/src/main/java/com/eu/habbo/core/ConfigurationManager.java @@ -3,6 +3,8 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -14,6 +16,8 @@ import java.util.Properties; public class ConfigurationManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class); + private final Properties properties; private final String configurationPath; public boolean loaded = false; @@ -25,7 +29,6 @@ public class ConfigurationManager { this.reload(); } - public void reload() { this.isLoading = true; this.properties.clear(); @@ -43,7 +46,7 @@ public class ConfigurationManager { this.properties.load(input); } catch (IOException ex) { - Emulator.getLogging().logErrorLine("[CRITICAL] FAILED TO LOAD CONFIG FILE! (" + this.configurationPath + ")"); + LOGGER.error("Failed to load config file.", ex); ex.printStackTrace(); } finally { if (input != null) { @@ -80,35 +83,31 @@ public class ConfigurationManager { envMapping.put("runtime.threads", "RT_THREADS"); envMapping.put("logging.errors.runtime", "RT_LOG_ERRORS"); - for (Map.Entry entry : envMapping.entrySet()) { String envValue = System.getenv(entry.getValue()); if (envValue == null || envValue.length() == 0) { - Emulator.getLogging().logStart("Cannot find environment-value for variable `" + entry.getValue() + "`"); + LOGGER.info("Cannot find environment-value for variable `" + entry.getValue() + "`"); } else { this.properties.setProperty(entry.getKey(), envValue); } } } - if (this.loaded) { this.loadFromDatabase(); } - this.isLoading = false; - Emulator.getLogging().logStart("Configuration Manager -> Loaded!"); + LOGGER.info("Configuration Manager -> Loaded!"); if (Emulator.getPluginManager() != null) { Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent()); } } - public void loadFromDatabase() { - Emulator.getLogging().logStart("Loading configuration from database..."); + LOGGER.info("Loading configuration from database..."); long millis = System.currentTimeMillis(); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) { @@ -120,10 +119,10 @@ public class ConfigurationManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } - Emulator.getLogging().logStart("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void saveToDatabase() { @@ -134,7 +133,7 @@ public class ConfigurationManager { statement.executeUpdate(); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -149,17 +148,15 @@ public class ConfigurationManager { return defaultValue; if (!this.properties.containsKey(key)) { - Emulator.getLogging().logErrorLine("[CONFIG] Key not found: " + key); + LOGGER.error("Config key not found {}", key); } return this.properties.getProperty(key, defaultValue); } - public boolean getBoolean(String key) { return this.getBoolean(key, false); } - public boolean getBoolean(String key, boolean defaultValue) { if (this.isLoading) return defaultValue; @@ -167,17 +164,15 @@ public class ConfigurationManager { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type boolean."); + LOGGER.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key)); } return defaultValue; } - public int getInt(String key) { return this.getInt(key, 0); } - public int getInt(String key, Integer defaultValue) { if (this.isLoading) return defaultValue; @@ -185,17 +180,15 @@ public class ConfigurationManager { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type integer."); + LOGGER.error("Failed to parse key {} with value '{}' to type integer.", key, this.getValue(key)); } return defaultValue; } - public double getDouble(String key) { return this.getDouble(key, 0.0); } - public double getDouble(String key, Double defaultValue) { if (this.isLoading) return defaultValue; @@ -203,13 +196,12 @@ public class ConfigurationManager { try { return Double.parseDouble(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type double."); + LOGGER.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key)); } return defaultValue; } - public void update(String key, String value) { this.properties.setProperty(key, value); } @@ -223,7 +215,7 @@ public class ConfigurationManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } this.update(key, value); diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java index ce136ede..d5442bbf 100644 --- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java @@ -2,11 +2,15 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class CreditsScheduler extends Scheduler { + private static final Logger LOGGER = LoggerFactory.getLogger(CreditsScheduler.class); + public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; @@ -48,7 +52,7 @@ public class CreditsScheduler extends Scheduler { habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount()); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/Loggable.java b/src/main/java/com/eu/habbo/core/DatabaseLoggable.java similarity index 71% rename from src/main/java/com/eu/habbo/core/Loggable.java rename to src/main/java/com/eu/habbo/core/DatabaseLoggable.java index 90826717..821ea7aa 100644 --- a/src/main/java/com/eu/habbo/core/Loggable.java +++ b/src/main/java/com/eu/habbo/core/DatabaseLoggable.java @@ -3,6 +3,10 @@ package com.eu.habbo.core; import java.sql.PreparedStatement; import java.sql.SQLException; -public interface Loggable { +public interface DatabaseLoggable { + + String getQuery(); + void log(PreparedStatement statement) throws SQLException; -} \ No newline at end of file + +} diff --git a/src/main/java/com/eu/habbo/core/DatabaseLogger.java b/src/main/java/com/eu/habbo/core/DatabaseLogger.java new file mode 100644 index 00000000..2f8806a9 --- /dev/null +++ b/src/main/java/com/eu/habbo/core/DatabaseLogger.java @@ -0,0 +1,46 @@ +package com.eu.habbo.core; + +import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class DatabaseLogger { + + private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseLogger.class); + + private final ConcurrentLinkedQueue loggables = new ConcurrentLinkedQueue<>(); + + public void store(DatabaseLoggable loggable) { + this.loggables.add(loggable); + } + + public void save() { + if (Emulator.getDatabase() == null || Emulator.getDatabase().getDataSource() == null) { + return; + } + + if (this.loggables.isEmpty()) { + return; + } + + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + while (!this.loggables.isEmpty()) { + DatabaseLoggable loggable = this.loggables.remove(); + + try (PreparedStatement statement = connection.prepareStatement(loggable.getQuery())) { + loggable.log(statement); + statement.executeBatch(); + } + + } + } catch (SQLException e) { + LOGGER.error("Exception caught while saving loggables to database.", e); + } + } + +} diff --git a/src/main/java/com/eu/habbo/core/ErrorLog.java b/src/main/java/com/eu/habbo/core/ErrorLog.java index 44d0176f..f0d62072 100644 --- a/src/main/java/com/eu/habbo/core/ErrorLog.java +++ b/src/main/java/com/eu/habbo/core/ErrorLog.java @@ -1,6 +1,8 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.PrintWriter; @@ -8,9 +10,11 @@ import java.io.StringWriter; import java.sql.PreparedStatement; import java.sql.SQLException; +public class ErrorLog implements DatabaseLoggable { + + private static final Logger LOGGER = LoggerFactory.getLogger(ErrorLog.class); + private static final String QUERY = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)"; -public class ErrorLog implements Loggable { - public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)"; public final String version; public final String buildHash; @@ -19,7 +23,6 @@ public class ErrorLog implements Loggable { public final String stackTrace; public ErrorLog(String type, Throwable e) { - this.version = Emulator.version; this.buildHash = Emulator.version; @@ -35,7 +38,7 @@ public class ErrorLog implements Loggable { pw.close(); sw.close(); } catch (IOException e1) { - Emulator.getLogging().logErrorLine(e1); + LOGGER.error("Exception caught", e1); } } @@ -48,6 +51,11 @@ public class ErrorLog implements Loggable { this.stackTrace = message; } + @Override + public String getQuery() { + return QUERY; + } + @Override public void log(PreparedStatement statement) throws SQLException { statement.setInt(1, this.timeStamp); diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java index 4a85969e..58b3acc7 100644 --- a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java @@ -2,11 +2,15 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class GotwPointsScheduler extends Scheduler { + private static final Logger LOGGER = LoggerFactory.getLogger(GotwPointsScheduler.class); + public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; public static String GOTW_POINTS_NAME; @@ -63,7 +67,7 @@ public class GotwPointsScheduler extends Scheduler { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java deleted file mode 100644 index c364f2ec..00000000 --- a/src/main/java/com/eu/habbo/core/Logging.java +++ /dev/null @@ -1,338 +0,0 @@ -package com.eu.habbo.core; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.rooms.RoomChatMessage; -import gnu.trove.set.hash.THashSet; -import io.netty.util.internal.ConcurrentSet; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -public class Logging { - - public static final String ANSI_BRIGHT = "\u001B[1m"; - public static final String ANSI_ITALICS = "\u001B[3m"; - public static final String ANSI_UNDERLINE = "\u001B[4m"; - public static final String ANSI_RESET = "\u001B[0m"; - public static final String ANSI_BLACK = "\u001B[30m"; - public static final String ANSI_RED = "\u001B[31m"; - public static final String ANSI_GREEN = "\u001B[32m"; - public static final String ANSI_YELLOW = "\u001B[33m"; - public static final String ANSI_BLUE = "\u001B[34m"; - public static final String ANSI_PURPLE = "\u001B[35m"; - public static final String ANSI_CYAN = "\u001B[36m"; - public static final String ANSI_WHITE = "\u001B[37m"; - private static PrintWriter packetsWriter; - private static PrintWriter packetsUndefinedWriter; - private static PrintWriter errorsPacketsWriter; - private static PrintWriter errorsSQLWriter; - private static PrintWriter errorsRuntimeWriter; - private static PrintWriter debugFileWriter; - private final THashSet errorLogs = new THashSet<>(100); - - - private final THashSet commandLogs = new THashSet<>(100); - - private ConcurrentSet chatLogs = new ConcurrentSet<>(); - - public Logging() { - - File packets = new File("logging//packets//defined.txt"); - - File packetsUndefined = new File("logging//packets//packets.txt"); - - File errorsPackets = new File("logging//errors//packets.txt"); - - File errorsSQL = new File("logging//errors//sql.txt"); - - File errorsRuntime = new File("logging//errors//runtime.txt"); - - File debugFile = new File("logging//debug.txt"); - - try { - if (!packets.exists()) { - if (!packets.getParentFile().exists()) { - packets.getParentFile().mkdirs(); - } - - packets.createNewFile(); - } - - if (!packetsUndefined.exists()) { - if (!packetsUndefined.getParentFile().exists()) { - packetsUndefined.getParentFile().mkdirs(); - } - - packetsUndefined.createNewFile(); - } - - if (!errorsPackets.exists()) { - if (!errorsPackets.getParentFile().exists()) { - errorsPackets.getParentFile().mkdirs(); - } - - errorsPackets.createNewFile(); - } - - if (!errorsSQL.exists()) { - if (!errorsSQL.getParentFile().exists()) { - errorsSQL.getParentFile().mkdirs(); - } - - errorsSQL.createNewFile(); - } - - if (!errorsRuntime.exists()) { - if (!errorsRuntime.getParentFile().exists()) { - errorsRuntime.getParentFile().mkdirs(); - } - - errorsRuntime.createNewFile(); - } - - if (!debugFile.exists()) { - if (!debugFile.getParentFile().exists()) { - debugFile.getParentFile().mkdirs(); - } - - debugFile.createNewFile(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - try { - packetsWriter = new PrintWriter(new FileWriter(packets, true)); - packetsUndefinedWriter = new PrintWriter(new FileWriter(packetsUndefined, true)); - errorsPacketsWriter = new PrintWriter(new FileWriter(errorsPackets, true)); - errorsSQLWriter = new PrintWriter(new FileWriter(errorsSQL, true)); - errorsRuntimeWriter = new PrintWriter(new FileWriter(errorsRuntime, true)); - debugFileWriter = new PrintWriter(new FileWriter(debugFile, true)); - } catch (IOException e) { - System.out.println("[CRITICAL] FAILED TO LOAD LOGGING COMPONENT!"); - } - } - - public static PrintWriter getPacketsWriter() { - return packetsWriter; - } - - public static PrintWriter getPacketsUndefinedWriter() { - return packetsUndefinedWriter; - } - - public void logStart(Object line) { - System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "LOADING" + Logging.ANSI_RESET + "] " + line.toString()); - } - - public void logShutdownLine(Object line) { - if (Emulator.getConfig().getBoolean("logging.debug")) { - this.write(debugFileWriter, line.toString()); - } - System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_RED + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString()); - } - - public void logUserLine(Object line) { - if (Emulator.getConfig().getBoolean("logging.debug")) { - this.write(debugFileWriter, line.toString()); - } - - if (Emulator.getConfig().getBoolean("debug.show.users")) { - System.out.println("[USER] " + line.toString()); - } - } - - public synchronized void logDebugLine(Object line) { - if (line instanceof Throwable) { - this.logErrorLine(line); - return; - } - if (Emulator.getConfig().getBoolean("debug.mode")) { - System.out.println("[DEBUG] " + line.toString()); - } - - if (Emulator.getConfig().getBoolean("logging.debug")) { - this.write(debugFileWriter, line.toString()); - } - } - - public synchronized void logPacketLine(Object line) { - if (Emulator.getConfig().getBoolean("debug.show.packets")) { - System.out.println("[" + Logging.ANSI_BLUE + "PACKET" + Logging.ANSI_RESET + "]" + line.toString()); - } - - if (Emulator.getConfig().getBoolean("logging.packets")) { - this.write(packetsWriter, line.toString()); - } - } - - public synchronized void logUndefinedPacketLine(Object line) { - if (Emulator.getConfig().getBoolean("debug.show.packets.undefined")) { - System.out.println("[PACKET] [UNDEFINED] " + line.toString()); - } - - if (Emulator.getConfig().getBoolean("logging.packets.undefined")) { - this.write(packetsUndefinedWriter, line.toString()); - } - } - - public synchronized void logErrorLine(Object line) { - if (Emulator.isReady && Emulator.getConfig().getBoolean("debug.show.errors")) { - System.err.println("[ERROR] " + line.toString()); - } - - if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime")) { - this.write(errorsRuntimeWriter, line); - } - - if (line instanceof Throwable) { - ((Throwable) line).printStackTrace(); - if (line instanceof SQLException) { - this.logSQLException((SQLException) line); - return; - } - // Emulator.getThreading().run(new HTTPPostError((Throwable) line)); - - this.errorLogs.add(new ErrorLog("Exception", (Throwable) line)); - - return; - } - - this.errorLogs.add(new ErrorLog("Emulator", line.toString())); - } - - public void logSQLException(SQLException e) { - if (Emulator.getConfig().getBoolean("logging.errors.sql")) { - e.printStackTrace(); - this.write(errorsSQLWriter, e); - - //Emulator.getThreading().run(new HTTPPostError(e)); - } - } - - public void logPacketError(Object e) { - if (Emulator.getConfig().getBoolean("logging.errors.packets")) { - if (e instanceof Throwable) - ((Exception) e).printStackTrace(); - - this.write(errorsPacketsWriter, e); - } - - if (e instanceof Throwable) { - ((Throwable) e).printStackTrace(); - if (e instanceof SQLException) { - this.logSQLException((SQLException) e); - return; - } - - // Emulator.getThreading().run(new HTTPPostError((Throwable) e)); - } - } - - public void handleException(Exception e) { - e.printStackTrace(); - } - - private synchronized void write(PrintWriter printWriter, Object message) { - if (printWriter != null && message != null) { - if (message instanceof Throwable) { - ((Exception) message).printStackTrace(printWriter); - } else { - printWriter.write("MSG: " + message.toString() + "\r\n"); - } - - printWriter.flush(); - } - } - - public void addLog(Loggable log) { - if (log instanceof ErrorLog) { - synchronized (this.errorLogs) { - this.errorLogs.add(log); - } - } else if (log instanceof CommandLog) { - synchronized (this.commandLogs) { - this.commandLogs.add(log); - } - } - } - - public void addChatLog(Loggable chatLog) { - this.chatLogs.add(chatLog); - } - - public void saveLogs() { - if (Emulator.getDatabase() != null && Emulator.getDatabase().getDataSource() != null) { - if (!this.errorLogs.isEmpty() || !this.commandLogs.isEmpty() || !this.chatLogs.isEmpty()) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - if (!this.errorLogs.isEmpty()) { - synchronized (this.errorLogs) { - try (PreparedStatement statement = connection.prepareStatement(ErrorLog.insertQuery)) { - for (Loggable log : this.errorLogs) { - log.log(statement); - } - statement.executeBatch(); - } - this.errorLogs.clear(); - } - } - - if (!this.commandLogs.isEmpty()) { - synchronized (this.commandLogs) { - try (PreparedStatement statement = connection.prepareStatement(CommandLog.insertQuery)) { - for (Loggable log : this.commandLogs) { - log.log(statement); - } - - statement.executeBatch(); - } - this.commandLogs.clear(); - } - } - - if (!this.chatLogs.isEmpty()) { - ConcurrentSet chatLogs = this.chatLogs; - this.chatLogs = new ConcurrentSet<>(); - - try (PreparedStatement statement = connection.prepareStatement(RoomChatMessage.insertQuery)) { - for (Loggable log : chatLogs) { - log.log(statement); - } - - statement.executeBatch(); - } - chatLogs.clear(); - } - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - } - } - } - } - /* - public static PrintWriter getErrorsPacketsWriter() - { - return errorsPacketsWriter; - } - - public static PrintWriter getErrorsSQLWriter() - { - return errorsSQLWriter; - } - - public static PrintWriter getErrorsRuntimeWriter() - { - return errorsRuntimeWriter; - } - - public static PrintWriter getDebugFileWriter() - { - return debugFileWriter; - } - */ -} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java index 13a0cf3d..cadf07ea 100644 --- a/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java @@ -2,11 +2,15 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class PixelScheduler extends Scheduler { + private static final Logger LOGGER = LoggerFactory.getLogger(PixelScheduler.class); + public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; @@ -46,7 +50,7 @@ public class PixelScheduler extends Scheduler { habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount()); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java index f5c8042d..d30abc6a 100644 --- a/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java @@ -2,11 +2,15 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class PointsScheduler extends Scheduler { + private static final Logger LOGGER = LoggerFactory.getLogger(PointsScheduler.class); + public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_IDLED; @@ -49,7 +53,7 @@ public class PointsScheduler extends Scheduler { habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount()); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/core/TextsManager.java b/src/main/java/com/eu/habbo/core/TextsManager.java index 7b28651c..90c6520a 100644 --- a/src/main/java/com/eu/habbo/core/TextsManager.java +++ b/src/main/java/com/eu/habbo/core/TextsManager.java @@ -1,12 +1,16 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.Properties; public class TextsManager { + private static final Logger LOGGER = LoggerFactory.getLogger(TextsManager.class); + private final Properties texts; public TextsManager() { @@ -15,16 +19,14 @@ public class TextsManager { this.texts = new Properties(); try { - this.reload(); - Emulator.getLogging().logStart("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } catch (Exception e) { e.printStackTrace(); } } - public void reload() throws Exception { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM emulator_texts")) { while (set.next()) { @@ -35,54 +37,47 @@ public class TextsManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } - public String getValue(String key) { return this.getValue(key, ""); } - public String getValue(String key, String defaultValue) { if (!this.texts.containsKey(key)) { - Emulator.getLogging().logErrorLine("[TEXTS] Text key not found: " + key); + LOGGER.error("Text key not found: {}", key); } return this.texts.getProperty(key, defaultValue); } - public boolean getBoolean(String key) { return this.getBoolean(key, false); } - public boolean getBoolean(String key, Boolean defaultValue) { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return defaultValue; } - public int getInt(String key) { return this.getInt(key, 0); } - public int getInt(String key, Integer defaultValue) { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return defaultValue; } - public void update(String key, String value) { this.texts.setProperty(key, value); } @@ -96,7 +91,7 @@ public class TextsManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } this.update(key, value); diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java index 25e523a9..43aa98d0 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java @@ -1,25 +1,22 @@ package com.eu.habbo.core.consolecommands; -import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleCommand.class); private static final THashMap commands = new THashMap<>(); - public final String key; - - public final String usage; - public ConsoleCommand(String key, String usage) { this.key = key; this.usage = usage; } - public static void load() { addCommand(new ConsoleShutdownCommand()); addCommand(new ConsoleInfoCommand()); @@ -48,7 +45,7 @@ public abstract class ConsoleCommand { command.handle(message); return true; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } else { System.out.println("Unknown Console Command " + message[0]); @@ -64,4 +61,5 @@ public abstract class ConsoleCommand { } public abstract void handle(String[] args) throws Exception; + } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java index bf5f0ccc..f9db196d 100644 --- a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java +++ b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java @@ -2,7 +2,7 @@ package com.eu.habbo.crypto; import com.eu.habbo.crypto.exceptions.HabboCryptoException; import com.eu.habbo.crypto.utils.BigIntegerUtils; -import com.eu.habbo.crypto.utils.HexUtils; +import com.eu.habbo.util.HexUtils; import java.math.BigInteger; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/com/eu/habbo/crypto/utils/HexUtils.java b/src/main/java/com/eu/habbo/crypto/utils/HexUtils.java deleted file mode 100644 index ae935ed0..00000000 --- a/src/main/java/com/eu/habbo/crypto/utils/HexUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.eu.habbo.crypto.utils; - -public class HexUtils { - - private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); - - public static String toHex(byte[] bytes) { - char[] hexChars = new char[bytes.length * 2]; - for (int j = 0; j < bytes.length; j++) { - int v = bytes[j] & 0xFF; - hexChars[j * 2] = HEX_ARRAY[v >>> 4]; - hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; - } - return new String(hexChars); - } - - public static byte[] toBytes(String hexString) { - int len = hexString.length(); - byte[] data = new byte[len / 2]; - for (int i = 0; i < len; i += 2) { - data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) - + Character.digit(hexString.charAt(i+1), 16)); - } - return data; - } - -} diff --git a/src/main/java/com/eu/habbo/database/Database.java b/src/main/java/com/eu/habbo/database/Database.java index 81f7c508..c37a524a 100644 --- a/src/main/java/com/eu/habbo/database/Database.java +++ b/src/main/java/com/eu/habbo/database/Database.java @@ -3,16 +3,17 @@ package com.eu.habbo.database; import com.eu.habbo.Emulator; import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariDataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class Database { + private static final Logger LOGGER = LoggerFactory.getLogger(Database.class); + private HikariDataSource dataSource; - - private DatabasePool databasePool; public Database(ConfigurationManager config) { - long millis = System.currentTimeMillis(); boolean SQLException = false; @@ -20,25 +21,23 @@ public class Database { try { this.databasePool = new DatabasePool(); if (!this.databasePool.getStoragePooling(config)) { - Emulator.getLogging().logStart("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down..."); + LOGGER.info("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down..."); SQLException = true; return; } this.dataSource = this.databasePool.getDatabase(); } catch (Exception e) { SQLException = true; - e.printStackTrace(); - Emulator.getLogging().logStart("Failed to connect to your database."); - Emulator.getLogging().logStart(e.getMessage()); + LOGGER.error("Failed to connect to your database.", e); } finally { - if (SQLException) + if (SQLException) { Emulator.prepareShutdown(); + } } - Emulator.getLogging().logStart("Database -> Connected! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis); } - public void dispose() { if (this.databasePool != null) { this.databasePool.getDatabase().close(); @@ -55,4 +54,3 @@ public class Database { return this.databasePool; } } - diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index 93312b2c..63a956bb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -1,10 +1,7 @@ package com.eu.habbo.habbohotel; import com.eu.habbo.Emulator; -import com.eu.habbo.core.CreditsScheduler; -import com.eu.habbo.core.GotwPointsScheduler; -import com.eu.habbo.core.PixelScheduler; -import com.eu.habbo.core.PointsScheduler; +import com.eu.habbo.core.*; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; @@ -23,8 +20,13 @@ import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.polls.PollManager; import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.HabboManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GameEnvironment { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameEnvironment.class); + public CreditsScheduler creditsScheduler; public PixelScheduler pixelScheduler; public PointsScheduler pointsScheduler; @@ -49,7 +51,7 @@ public class GameEnvironment { private PollManager pollManager; public void load() throws Exception { - Emulator.getLogging().logStart("GameEnvironment -> Loading..."); + LOGGER.info("GameEnvironment -> Loading..."); this.permissionsManager = new PermissionsManager(); this.habboManager = new HabboManager(); @@ -85,7 +87,7 @@ public class GameEnvironment { Emulator.getThreading().run(this.gotwPointsScheduler); - Emulator.getLogging().logStart("GameEnvironment -> Loaded!"); + LOGGER.info("GameEnvironment -> Loaded!"); } public void dispose() { @@ -101,7 +103,7 @@ public class GameEnvironment { this.roomManager.dispose(); this.itemManager.dispose(); this.hotelViewManager.dispose(); - Emulator.getLogging().logShutdownLine("GameEnvironment -> Disposed!"); + LOGGER.info("GameEnvironment -> Disposed!"); } public HabboManager getHabboManager() { diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java index c6a865e5..a00a79cf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -58,7 +58,7 @@ public class AchievementManager { statement.setInt(4, amount); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -140,7 +140,7 @@ public class AchievementManager { try { badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); return; } } @@ -203,7 +203,7 @@ public class AchievementManager { statement.setInt(3, 1); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -217,7 +217,7 @@ public class AchievementManager { } statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -231,7 +231,7 @@ public class AchievementManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return 0; @@ -254,9 +254,9 @@ public class AchievementManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } @@ -276,13 +276,13 @@ public class AchievementManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); Emulator.getLogging().logErrorLine("Achievement Manager -> Failed to load!"); return; } } - Emulator.getLogging().logStart("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public Achievement getAchievement(String name) { diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java index 31e5d861..e104c4fa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java @@ -57,7 +57,7 @@ public class TalentTrackLevel { if (item != null) { this.items.add(item); } else { - Emulator.getLogging().logStart("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); + logger.info("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index d10ed613..197ecd4c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -155,7 +155,7 @@ public class Bot implements Runnable { statement.execute(); this.needsUpdate = false; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 3afd12e0..3d5754dc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -38,7 +38,7 @@ public class BotManager { this.reload(); - Emulator.getLogging().logStart("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addBotDefinition(String type, Class botClazz) throws Exception { @@ -58,10 +58,10 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); + logger.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); return false; } catch (Exception e) { - Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + logger.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); return false; } } @@ -88,12 +88,12 @@ public class BotManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return bot; @@ -143,7 +143,7 @@ public class BotManager { try { topItem.onWalkOn(bot.getRoomUnit(), room, null); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } bot.cycle(false); @@ -195,9 +195,9 @@ public class BotManager { else Emulator.getLogging().logErrorLine("Unknown Bot Type: " + type); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; @@ -208,7 +208,7 @@ public class BotManager { statement.setInt(1, bot.getId()); return statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; @@ -221,9 +221,9 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - Emulator.getLogging().logStart("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); + logger.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); } catch (Exception e) { - Emulator.getLogging().logStart("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + logger.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index 3f169e7c..11c82cc3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -43,7 +43,7 @@ public class ButlerBot extends Bot { serveItems.put(ks, set.getInt("item")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java index 9abeae91..21e02620 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -211,7 +211,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0) { @@ -259,7 +259,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable> pageDefinitions = new THashMap>(CatalogPageLayouts.values().length) { { for (CatalogPageLayouts layout : CatalogPageLayouts.values()) { @@ -209,7 +214,7 @@ public class CatalogManager { this.ecotronItem = Emulator.getGameEnvironment().getItemManager().getItem("ecotron_box"); - Emulator.getLogging().logStart("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -249,7 +254,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } for (Map.Entry> set : limiteds.entrySet()) { @@ -269,7 +274,7 @@ public class CatalogManager { Class pageClazz = pageDefinitions.get(set.getString("page_layout")); if (pageClazz == null) { - Emulator.getLogging().logStart("Unknown Page Layout: " + set.getString("page_layout")); + LOGGER.info("Unknown Page Layout: " + set.getString("page_layout")); continue; } @@ -277,12 +282,12 @@ public class CatalogManager { CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set); pages.put(page.getId(), page); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to load layout: " + set.getString("page_layout")); + LOGGER.error("Failed to load layout: {}", set.getString("page_layout")); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } pages.forEachValue((object) -> { @@ -294,7 +299,7 @@ public class CatalogManager { } } else { if (object.parentId != -2) { - Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); + LOGGER.info("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")"); } } return true; @@ -302,7 +307,7 @@ public class CatalogManager { this.catalogPages.putAll(pages); - Emulator.getLogging().logStart("Loaded " + this.catalogPages.size() + " Catalog Pages!"); + LOGGER.info("Loaded " + this.catalogPages.size() + " Catalog Pages!"); } @@ -323,7 +328,7 @@ public class CatalogManager { )); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -367,7 +372,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } for (CatalogPage page : this.catalogPages.valueCollection()) { @@ -392,7 +397,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -408,7 +413,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -423,7 +428,7 @@ public class CatalogManager { this.vouchers.add(new Voucher(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -443,11 +448,11 @@ public class CatalogManager { this.prizes.get(set.getInt("rarity")).add(item); } else { - Emulator.getLogging().logErrorLine("Cannot load item with ID:" + set.getInt("item_id") + " as recycler reward!"); + LOGGER.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id")); } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -472,7 +477,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -489,7 +494,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -504,7 +509,7 @@ public class CatalogManager { this.clothing.put(set.getInt("id"), new ClothItem(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -594,7 +599,7 @@ public class CatalogManager { return statement.executeUpdate() >= 1; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -699,7 +704,7 @@ public class CatalogManager { if (this.prizes.containsKey(level) && !this.prizes.get(level).isEmpty()) { return (Item) this.prizes.get(level).toArray()[Emulator.getRandom().nextInt(this.prizes.get(level).size())]; } else { - Emulator.getLogging().logErrorLine("[Recycler] No rewards specified for rarity level " + level); + LOGGER.error("No rewards specified for rarity level {}", level); } return null; @@ -730,13 +735,11 @@ public class CatalogManager { if (pageClazz != null) { try { catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page); - } catch (InvocationTargetException e) { - Emulator.getLogging().logErrorLine(e.getCause()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } else { - Emulator.getLogging().logErrorLine("Unknown Page Layout: " + page.getString("page_layout")); + LOGGER.error("Unknown page layout: {}", page.getString("page_layout")); } } } @@ -744,7 +747,7 @@ public class CatalogManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } if (catalogPage != null) { @@ -803,7 +806,7 @@ public class CatalogManager { } } - Emulator.getLogging().logShutdownLine("Catalog Manager -> Disposed!"); + LOGGER.info("Catalog Manager -> Disposed!"); } @@ -872,7 +875,7 @@ public class CatalogManager { if (amount > 1 && !CatalogItem.haveOffer(item)) { String message = Emulator.getTexts().getValue("scripter.warning.catalog.amount").replace("%username%", habbo.getHabboInfo().getUsername()).replace("%itemname%", item.getName()).replace("%pagename%", page.getCaption()); ScripterManager.scripterDetected(habbo.getClient(), message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } @@ -957,7 +960,7 @@ public class CatalogManager { try { pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } @@ -1012,7 +1015,7 @@ public class CatalogManager { try { guildId = Integer.parseInt(extradata); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -1120,7 +1123,7 @@ public class CatalogManager { habbo.getClient().sendResponse(new InventoryRefreshComposer()); } catch (Exception e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("Exception caught", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } finally { @@ -1158,7 +1161,7 @@ public class CatalogManager { statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java index 4c7562ee..53fab1c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -70,7 +70,7 @@ public abstract class CatalogPage implements Comparable, ISerialize try { this.included.add(Integer.valueOf(id)); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); Emulator.getLogging().logErrorLine("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java index 7291e193..cf37a8e2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -41,7 +41,7 @@ public class Voucher { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -64,7 +64,7 @@ public class Voucher { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index e05ccb84..e2bb6ed4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -185,7 +185,7 @@ public class RoomBundleLayout extends SingleBundle { statement.setInt(3, this.room.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -219,7 +219,7 @@ public class RoomBundleLayout extends SingleBundle { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index 2e978403..ca7ba320 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -43,7 +43,7 @@ public class MarketPlace { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return offers; @@ -101,7 +101,7 @@ public class MarketPlace { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, false)); } } @@ -163,7 +163,7 @@ public class MarketPlace { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return offers; @@ -193,7 +193,7 @@ public class MarketPlace { message.appendInt(1); message.appendInt(itemId); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -208,7 +208,7 @@ public class MarketPlace { number = set.getInt("number"); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return number; @@ -226,7 +226,7 @@ public class MarketPlace { avg = set.getInt("avg"); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return calculateCommision(avg); @@ -294,7 +294,7 @@ public class MarketPlace { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -321,7 +321,7 @@ public class MarketPlace { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -388,7 +388,7 @@ public class MarketPlace { statement.setInt(2, offer.getOfferId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java index f8b68e5a..4bfb6307 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java @@ -66,7 +66,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -86,7 +86,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -160,7 +160,7 @@ public class MarketPlaceOffer implements Runnable { statement.setInt(3, this.offerId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java index 5318102b..28fe8339 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -49,7 +49,7 @@ public class AddYoutubePlaylistCommand extends Command { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java index eac670e7..31f54aac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -72,7 +72,7 @@ public class BadgeCommand extends Command { return true; } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index dbf2fa6a..a8e550a1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -15,6 +15,8 @@ import com.eu.habbo.plugin.events.users.UserCommandEvent; import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Comparator; @@ -22,6 +24,9 @@ import java.util.List; import java.util.NoSuchElementException; public class CommandHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(CommandHandler.class); + private final static THashMap commands = new THashMap<>(5); private static final Comparator ALPHABETICAL_ORDER = new Comparator() { public int compare(Command c1, Command c2) { @@ -33,7 +38,7 @@ public class CommandHandler { public CommandHandler() { long millis = System.currentTimeMillis(); this.reloadCommands(); - Emulator.getLogging().logStart("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addCommand(Command command) { @@ -48,9 +53,9 @@ public class CommandHandler { try { //command.getConstructor().setAccessible(true); addCommand(command.newInstance()); - Emulator.getLogging().logDebugLine("Added command: " + command.getName()); + LOGGER.debug("Added command: {}", command.getName()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } @@ -79,11 +84,11 @@ public class CommandHandler { succes = event.succes; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) { - Emulator.getLogging().addLog(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes)); + Emulator.getDatabaseLogger().store(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes)); } } @@ -305,7 +310,6 @@ public class CommandHandler { public void dispose() { commands.clear(); - - Emulator.getLogging().logShutdownLine("Command Handler -> Disposed!"); + LOGGER.info("Command Handler -> Disposed!"); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java index 3b459feb..b2a9cef6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java @@ -38,7 +38,7 @@ public class EnableCommand extends Command { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java index 148fa4c8..73cfb7e5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java @@ -35,7 +35,7 @@ public class FilterWordCommand extends Command { statement.setString(2, replacement); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.error")); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java index 8affbd20..2fd4031e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java @@ -62,7 +62,7 @@ public class RoomBundleCommand extends Command { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } ((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java index cdaded07..abdbf28e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java @@ -60,7 +60,7 @@ public class CraftingManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -114,7 +114,7 @@ public class CraftingManager { } statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.altars.clear(); 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 eb9e6a8f..b9b81e4d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -1,16 +1,14 @@ package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.crypto.HabboEncryption; import com.eu.habbo.habbohotel.users.Habbo; -import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.MessageComposer; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,6 +18,8 @@ import java.util.concurrent.ConcurrentHashMap; public class GameClient { + private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); + private final Channel channel; private final HabboEncryption encryption; @@ -81,7 +81,7 @@ public class GameClient { statement.setInt(2, this.habbo.getHabboInfo().getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -92,7 +92,7 @@ public class GameClient { this.channel.write(composer.compose().retain(), this.channel.voidPromise()); this.channel.flush(); } catch (Exception e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("Caught exception", e); } } } @@ -135,7 +135,7 @@ public class GameClient { this.habbo = null; } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index b64d8292..619423e3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -73,7 +73,7 @@ public abstract class Game implements Runnable { return true; } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index 074d494a..094ee146 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -149,7 +149,7 @@ public class BattleBanzaiGame extends Game { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index 24b0a64c..c44a7fa0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -261,7 +261,7 @@ public class FreezeGame extends Game { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java index 075b31a7..f43e52b0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java @@ -91,7 +91,7 @@ public class Guild implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -116,7 +116,7 @@ public class Guild implements Runnable { this.needsUpdate = false; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index 71a017aa..2f84660d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -13,6 +13,8 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; @@ -20,6 +22,8 @@ import java.util.stream.Collectors; public class GuildManager { + private static final Logger LOGGER = LoggerFactory.getLogger(GuildManager.class); + private final THashMap> guildParts; private final TIntObjectMap guilds; @@ -34,7 +38,7 @@ public class GuildManager { this.loadGuildParts(); this.loadGuildViews(); - Emulator.getLogging().logStart("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -52,7 +56,7 @@ public class GuildManager { this.guildParts.get(GuildPartType.valueOf(set.getString("type").toUpperCase())).put(set.getInt("id"), new GuildPart(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -66,7 +70,7 @@ public class GuildManager { this.views.add(new ForumView(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -107,7 +111,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } habbo.getHabboStats().addGuild(guild.getId()); @@ -155,7 +159,7 @@ public class GuildManager { room.setGuild(0); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -276,7 +280,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -288,7 +292,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -303,7 +307,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -325,7 +329,7 @@ public class GuildManager { statement.setInt(2, guild.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -352,7 +356,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return member; @@ -375,7 +379,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return guildMembers; @@ -397,7 +401,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return guildMembers; @@ -416,7 +420,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -434,7 +438,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return guildAdmins; @@ -466,7 +470,7 @@ public class GuildManager { if (g != null) g.loadMemberCount(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -494,7 +498,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return guilds; @@ -514,7 +518,7 @@ public class GuildManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return guilds; @@ -593,7 +597,7 @@ public class GuildManager { statement.setInt(2, furni.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -608,7 +612,7 @@ public class GuildManager { guildIterator.remove(); } - Emulator.getLogging().logShutdownLine("Guild Manager -> Disposed!"); + LOGGER.info("Guild Manager -> Disposed!"); } public boolean hasViewedForum(int userId, int guildId) { @@ -628,7 +632,7 @@ public class GuildManager { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java index 5d432c79..a1c7227a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java @@ -108,7 +108,7 @@ public class ForumThread implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return createdThread; @@ -156,7 +156,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return threads; @@ -195,7 +195,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return foundThread; @@ -337,7 +337,7 @@ public class ForumThread implements Runnable, ISerialize { addComment(comment); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -461,7 +461,7 @@ public class ForumThread implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java index 01f6792c..9ff93d55 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java @@ -64,7 +64,7 @@ public class ForumThreadComment implements Runnable, ISerialize { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return foundComment; @@ -103,7 +103,7 @@ public class ForumThreadComment implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return createdComment; @@ -200,7 +200,7 @@ public class ForumThreadComment implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java index 1593623b..ef7f1986 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java @@ -32,7 +32,7 @@ public class HallOfFame { this.winners.put(winner.getId(), winner); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java index b097edcd..81048f3b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java @@ -1,8 +1,12 @@ package com.eu.habbo.habbohotel.hotelview; -import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HotelViewManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewManager.class); + private final HallOfFame hallOfFame; private final NewsList newsList; @@ -11,7 +15,7 @@ public class HotelViewManager { this.hallOfFame = new HallOfFame(); this.newsList = new NewsList(); - Emulator.getLogging().logStart("Hotelview Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis); } public HallOfFame getHallOfFame() { @@ -23,6 +27,7 @@ public class HotelViewManager { } public void dispose() { - Emulator.getLogging().logShutdownLine("HotelView Manager -> Disposed!"); + LOGGER.info("HotelView Manager -> Disposed!"); } + } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java index 8be6fd7c..623cb2c5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java @@ -25,7 +25,7 @@ public class NewsList { this.newsWidgets.add(new NewsWidget(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java index 87e1caf6..727fb47a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -52,7 +52,7 @@ public class CrackableReward { this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance)); this.totalChance += chance; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 7eff22c4..7fdc0202 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -60,12 +60,17 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Constructor; import java.sql.*; import java.util.*; public class ItemManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(ItemManager.class); + //Configuration. Loaded from database & updated accordingly. public static boolean RECYCLER_ENABLED = true; @@ -100,7 +105,7 @@ public class ItemManager { this.highscoreManager.load(); this.loadNewUserGifts(); - Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } protected void loadItemInteractions() { @@ -354,7 +359,7 @@ public class ItemManager { return interaction; } - Emulator.getLogging().logDebugLine("Can't find interaction class:" + type.getName()); + LOGGER.debug("Can't find interaction class: {}", type.getName()); return this.getItemInteraction(InteractionDefault.class); } @@ -384,12 +389,12 @@ public class ItemManager { else this.items.get(id).update(set); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to load Item (" + set.getInt("id") + ")"); - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Failed to load Item ({})", set.getInt("id")); + LOGGER.error("Caught exception", e); } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -402,16 +407,16 @@ public class ItemManager { try { reward = new CrackableReward(set); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("item_id")); - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Failed to load items_crackable item_id = {}", set.getInt("item_id")); + LOGGER.error("Caught exception", e); continue; } this.crackableRewards.put(set.getInt("item_id"), reward); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } @@ -445,7 +450,7 @@ public class ItemManager { this.soundTracks.put(set.getString("code"), new SoundTrack(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -478,16 +483,16 @@ public class ItemManager { try { return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); } } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return null; } @@ -502,7 +507,7 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -527,7 +532,7 @@ public class ItemManager { statement.setInt(1, item.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -554,7 +559,7 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return item; @@ -594,9 +599,9 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return item; @@ -608,7 +613,7 @@ public class ItemManager { statement.setInt(2, itemTwoId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -618,7 +623,7 @@ public class ItemManager { statement.setInt(2, hopper.getBaseItem().getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -633,7 +638,7 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return a; @@ -649,9 +654,9 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return item; @@ -672,7 +677,7 @@ public class ItemManager { return (HabboItem) c.newInstance(set, baseItem); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } @@ -695,7 +700,7 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -703,7 +708,7 @@ public class ItemManager { return null; if (extraData.length() > 1000) { - Emulator.getLogging().logErrorLine("Extradata exceeds maximum length of 1000 characters:" + extraData); + LOGGER.error("Extradata exceeds maximum length of 1000 characters: {}", extraData); extraData = extraData.substring(0, 1000); } @@ -720,7 +725,7 @@ public class ItemManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } if (gift != null) { @@ -774,7 +779,7 @@ public class ItemManager { this.items.clear(); this.highscoreManager.dispose(); - Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!"); + LOGGER.info("Item Manager -> Disposed!"); } public List getInteractionList() { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index 4e9ce06d..e3b680cd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -80,7 +80,7 @@ public class YoutubeManager { Emulator.getThreading().run(() -> { ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); - Emulator.getLogging().logStart("YouTube Manager -> Loading..."); + logger.info("YouTube Manager -> Loading..."); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { try (ResultSet set = statement.executeQuery()) { @@ -103,7 +103,7 @@ public class YoutubeManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } youtubeDataLoaderPool.shutdown(); @@ -113,7 +113,7 @@ public class YoutubeManager { e.printStackTrace(); } - Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index a16115cb..cd089ec3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -41,7 +41,7 @@ public class InteractionColorPlate extends InteractionDefault { try { state = Integer.valueOf(this.getExtradata()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } state += amount; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java index 4635c63f..d1ee8065 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java @@ -50,7 +50,7 @@ public class InteractionRentableSpace extends HabboItem { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } else { @@ -180,7 +180,7 @@ public class InteractionRentableSpace extends HabboItem { statement.setInt(1, zero); statement.setInt(2, zero); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index cede4c8d..e3c9c702 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -71,7 +71,7 @@ public abstract class InteractionWired extends HabboItem { statement.setInt(2, this.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } super.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 054ce7d8..88a196ac 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -33,7 +33,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.reloadData(); @@ -51,7 +51,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.reloadData(); @@ -83,7 +83,7 @@ public class InteractionWiredHighscore extends HabboItem { this.setExtradata(Math.abs(state - 1) + ""); room.updateItem(this); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 6c0ff65e..3b064dfa 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -89,7 +89,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { } }).toArray(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -117,7 +117,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { room.addGame(game); game.initialise(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index ecaf88c1..079ac0e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -71,7 +71,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { try { this.handItem = Integer.valueOf(set.getString("wired_data")); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index b318a033..b379fe9c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -189,7 +189,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java index 0e3232ed..2605a4f8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java @@ -136,7 +136,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index c570f378..0caf0ef3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -120,7 +120,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); room.updateItem(item); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index a40dd95a..56b98ebd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -157,7 +157,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { if (item != null) this.items.add(item); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java index 8953c439..5949ae4b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java @@ -31,7 +31,7 @@ public class Message implements Runnable { statement.setInt(4, this.timestamp); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index 06d4e37d..250a7a52 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -41,7 +41,7 @@ public class Messenger { statement.setInt(4, userOne); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -55,7 +55,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return users; } @@ -85,7 +85,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; @@ -102,7 +102,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; @@ -114,7 +114,7 @@ public class Messenger { statement.setInt(2, userFrom); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -133,7 +133,7 @@ public class Messenger { count = set.getInt("count"); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return count; @@ -157,7 +157,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return map; } @@ -213,7 +213,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -237,7 +237,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return buddy; @@ -252,7 +252,7 @@ public class Messenger { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -311,7 +311,7 @@ public class Messenger { statement.setInt(1, userTo); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -323,7 +323,7 @@ public class Messenger { statement.setInt(3, userFrom); return statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return 0; @@ -345,7 +345,7 @@ public class Messenger { statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } Habbo habboTo = Emulator.getGameServer().getGameClientManager().getHabbo(userTo); diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 62d7a862..2ce143bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -44,7 +44,7 @@ public class MessengerBuddy implements Runnable, ISerialize { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -56,7 +56,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.relation = 0; this.userOne = 0; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -149,7 +149,7 @@ public class MessengerBuddy implements Runnable, ISerialize { statement.setInt(3, this.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java index 1fc72341..e79c9ad3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java @@ -63,7 +63,7 @@ public class ModToolBan implements Runnable { statement.setInt(9, this.cfhTopic); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 8a10edbb..de887280 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -41,7 +41,7 @@ public class ModToolManager { this.tickets = new THashMap<>(); this.cfhCategories = new TIntObjectHashMap<>(); this.loadModTool(); - Emulator.getLogging().logStart("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void requestUserInfo(GameClient client, ClientMessage packet) { @@ -58,9 +58,9 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -78,7 +78,7 @@ public class ModToolManager { this.loadTickets(connection); this.loadCfhCategories(connection); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -97,7 +97,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -108,7 +108,7 @@ public class ModToolManager { this.presets.get(set.getString("type")).add(set.getString("preset")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -120,7 +120,7 @@ public class ModToolManager { this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -146,7 +146,7 @@ public class ModToolManager { this.cfhCategories.get(set.getInt("support_cfh_category_id")).addTopic(new CfhTopic(set, this.getIssuePreset(set.getInt("default_sanction")))); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -198,7 +198,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return chatlogs; @@ -215,7 +215,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return chatlogs; @@ -235,7 +235,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return chatLogs; @@ -272,7 +272,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return chatlogs; @@ -290,7 +290,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return roomVisits; @@ -348,7 +348,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return roomVisits; @@ -378,7 +378,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return null; @@ -495,7 +495,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return ban; @@ -519,7 +519,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return banned; @@ -543,7 +543,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; @@ -557,7 +557,7 @@ public class ModToolManager { statement.execute(); return statement.getUpdateCount() > 0; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; @@ -662,7 +662,7 @@ public class ModToolManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return total; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index ea72d8bb..e909120a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -22,7 +22,7 @@ public class ModToolSanctions { this.sanctionHashmap = new THashMap<>(); this.sanctionLevelsHashmap = new THashMap<>(); this.loadModSanctions(); - Emulator.getLogging().logStart("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -41,7 +41,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -68,7 +68,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return this.sanctionHashmap; @@ -87,7 +87,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -98,7 +98,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -109,7 +109,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -120,7 +120,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } 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 123a47c4..f13e95fc 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -29,7 +29,7 @@ public class WordFilter { public WordFilter() { long start = System.currentTimeMillis(); this.reload(); - Emulator.getLogging().logStart("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); + logger.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); } private static String stripDiacritics(String str) { @@ -54,7 +54,7 @@ public class WordFilter { try { word = new WordFilterWord(set); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); continue; } @@ -67,7 +67,7 @@ public class WordFilter { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index e4fea5b7..929456b9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.sql.Connection; @@ -18,9 +20,9 @@ import java.util.concurrent.ConcurrentHashMap; public class NavigatorManager { + private static final Logger LOGGER = LoggerFactory.getLogger(NavigatorManager.class); + public static int MAXIMUM_RESULTS_PER_PAGE = 10; - - public static boolean CATEGORY_SORT_USING_ORDER_NUM = false; public final THashMap publicCategories = new THashMap<>(); @@ -36,7 +38,7 @@ public class NavigatorManager { this.filters.put(NavigatorUserFilter.name, new NavigatorUserFilter()); this.filters.put(NavigatorFavoriteFilter.name, new NavigatorFavoriteFilter()); - Emulator.getLogging().logStart("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadNavigator() { @@ -49,7 +51,7 @@ public class NavigatorManager { this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) { @@ -62,12 +64,12 @@ public class NavigatorManager { if (room != null) { category.addRoom(room); } else { - Emulator.getLogging().logErrorLine("Public room (ID: " + set.getInt("room_id") + " defined in navigator_publics does not exist!"); + LOGGER.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id")); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -83,7 +85,7 @@ public class NavigatorManager { field = clazz.getDeclaredMethod(s); clazz = field.getReturnType(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); break; } } @@ -91,7 +93,7 @@ public class NavigatorManager { try { field = clazz.getDeclaredMethod(set.getString("field")); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); continue; } } @@ -101,11 +103,11 @@ public class NavigatorManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } List staffPromotedRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsStaffPromoted(); diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index cfd1620e..7051d864 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -25,7 +25,7 @@ public class PermissionsManager { this.reload(); - Emulator.getLogging().logStart("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void reload() { @@ -58,7 +58,7 @@ public class PermissionsManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -71,7 +71,7 @@ public class PermissionsManager { this.enables.put(set.getInt("effect_id"), set.getInt("min_rank")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java index be2a9e63..de49ac85 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -47,7 +47,7 @@ public class GnomePet extends Pet implements IPetLook { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java index 46704168..c4cbc233 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -40,7 +40,7 @@ public class HorsePet extends RideablePet { statement.setInt(6, super.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } super.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index 88b98991..3f242328 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -138,7 +138,7 @@ public class MonsterplantPet extends Pet implements IPetLook { statement.setInt(13, this.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 965584c4..143f7962 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -205,7 +205,7 @@ public class Pet implements ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.needsUpdate = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index 981dfffd..dce3d5f4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -80,7 +80,7 @@ public class PetManager { reloadPetData(); - Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + logger.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static int getLevel(int experience) { @@ -151,7 +151,7 @@ public class PetManager { this.loadPetCommands(connection); this.loadPetBreeding(connection); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!"); } } @@ -167,7 +167,7 @@ public class PetManager { this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -177,7 +177,7 @@ public class PetManager { this.petData.put(set.getInt("pet_type"), new PetData(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.loadPetItems(connection); @@ -217,7 +217,7 @@ public class PetManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -244,7 +244,7 @@ public class PetManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -255,7 +255,7 @@ public class PetManager { commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) { @@ -267,7 +267,7 @@ public class PetManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -277,7 +277,7 @@ public class PetManager { this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) { @@ -294,7 +294,7 @@ public class PetManager { this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -308,7 +308,7 @@ public class PetManager { int petId = Integer.valueOf(petName.split("t")[1]); return this.petRaces.get(petId); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; @@ -364,7 +364,7 @@ public class PetManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -511,7 +511,7 @@ public class PetManager { statement.setInt(1, pet.getId()); return statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java index e7edc7ae..2841e741 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java @@ -23,7 +23,7 @@ public class PollManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; } @@ -63,7 +63,7 @@ public class PollManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java index 23db2026..4a30e521 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -30,7 +30,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable { statement.setInt(5, this.roomId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } 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 c8de883e..a5d3975c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -265,7 +265,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBans(connection); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.tradeMode = set.getInt("trade_mode"); @@ -313,49 +313,49 @@ public class Room implements Comparable, ISerialize, Runnable { try { this.loadLayout(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadRights(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadItems(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadHeightmap(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadBots(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadPets(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadWordFilter(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.loadWiredData(connection); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.idleCycles = 0; @@ -363,7 +363,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.traxManager = new TraxManager(this); @@ -416,7 +416,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } if (this.itemCount() > Room.MAXIMUM_FURNI) { @@ -438,14 +438,14 @@ public class Room implements Comparable, ISerialize, Runnable { ((InteractionWired) item).loadWiredData(set, this); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -481,7 +481,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -511,12 +511,12 @@ public class Room implements Comparable, ISerialize, Runnable { this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -531,7 +531,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -921,7 +921,7 @@ public class Room implements Comparable, ISerialize, Runnable { botIterator.value().needsUpdate(true); Emulator.getThreading().run(botIterator.value()); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } } @@ -929,7 +929,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.currentBots.clear(); this.currentPets.clear(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -941,7 +941,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.preLoaded = true; this.layout = null; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -1033,7 +1033,7 @@ public class Room implements Comparable, ISerialize, Runnable { Emulator.getThreading().run( Room.this::cycle); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } @@ -1096,7 +1096,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.executeUpdate(); this.needsUpdate = false; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -1107,7 +1107,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -1250,7 +1250,7 @@ public class Room implements Comparable, ISerialize, Runnable { } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } } @@ -1263,7 +1263,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -1458,7 +1458,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOn(unit, room, null); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); @@ -2010,7 +2010,7 @@ public class Room implements Comparable, ISerialize, Runnable { pet.needsUpdate = true; pet.run(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } } @@ -2123,7 +2123,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(10, this.promotion.getCategory()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.needsUpdate = true; @@ -2215,7 +2215,7 @@ public class Room implements Comparable, ISerialize, Runnable { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return true; @@ -2613,7 +2613,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } @@ -2674,7 +2674,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -2694,7 +2694,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -2716,7 +2716,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -2759,7 +2759,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -2838,7 +2838,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } @@ -2993,7 +2993,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } @@ -3180,7 +3180,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.onUserSay(roomChatMessage); } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } } @@ -3204,7 +3204,7 @@ public class Room implements Comparable, ISerialize, Runnable { item.onClick(habbo.getClient(), this, new Object[0]); break; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } @@ -3757,7 +3757,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -3776,7 +3776,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -3820,7 +3820,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -3857,7 +3857,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -3875,7 +3875,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(1, this.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.refreshRightsInRoom(); @@ -3942,7 +3942,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -4246,7 +4246,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return; } @@ -4263,7 +4263,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java index 806b5c23..d22adb0d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java @@ -42,7 +42,7 @@ public class RoomBan { statement.setInt(3, this.endTimestamp); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -53,7 +53,7 @@ public class RoomBan { statement.setInt(2, this.userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index 8322d624..0063a0d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -1,21 +1,26 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Loggable; +import com.eu.habbo.core.DatabaseLoggable; import com.eu.habbo.habbohotel.users.Habbo; 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, Loggable { +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 String insertQuery = "INSERT INTO chatlogs_room (user_from_id, user_to_id, message, timestamp, room_id) VALUES (?, ?, ?, ?, ?)"; public static int MAXIMUM_LENGTH = 100; //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_ROOM_CHATS = false; @@ -130,10 +135,11 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable { try { this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH - 1); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } - Emulator.getLogging().addChatLog(this); + + Emulator.getDatabaseLogger().store(this); } public String getMessage() { @@ -191,7 +197,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable { message.appendInt(0); message.appendInt(this.getMessage().length()); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } @@ -218,6 +224,11 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable { } } + @Override + public String getQuery() { + return QUERY; + } + @Override public void log(PreparedStatement statement) throws SQLException { statement.setInt(1, this.habbo.getHabboInfo().getId()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 2ffe4bbd..7eb6dbb0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -42,7 +42,7 @@ public class RoomLayout { this.parse(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 2faa824c..75249798 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -41,7 +41,6 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; -import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; @@ -53,13 +52,17 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; public class RoomManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(RoomManager.class); + private static final int page = 0; //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ROOMS_USER = 25; @@ -89,7 +92,7 @@ public class RoomManager { registerGameType(IceTagGame.class); registerGameType(RollerskateGame.class); - Emulator.getLogging().logStart("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadRoomModels() { @@ -99,7 +102,7 @@ public class RoomManager { this.mapNames.add(set.getString("name")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -113,7 +116,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return layout; @@ -127,7 +130,7 @@ public class RoomManager { this.roomCategories.put(set.getInt("id"), new RoomCategory(set)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -143,7 +146,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -169,7 +172,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -276,7 +279,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -317,7 +320,7 @@ public class RoomManager { this.activeRooms.put(room.getId(), room); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return room; @@ -341,7 +344,7 @@ public class RoomManager { room = this.loadRoom(set.getInt(1)); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return room; @@ -366,7 +369,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -416,7 +419,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return layout; @@ -450,7 +453,7 @@ public class RoomManager { statement.setInt(2, room.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -910,7 +913,7 @@ public class RoomManager { statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp)); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -961,7 +964,7 @@ public class RoomManager { statement.setInt(3, room.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } @@ -1090,7 +1093,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1150,7 +1153,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1217,7 +1220,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1263,7 +1266,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1286,7 +1289,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1328,7 +1331,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1350,7 +1353,7 @@ public class RoomManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1454,7 +1457,7 @@ public class RoomManager { this.activeRooms.clear(); - Emulator.getLogging().logShutdownLine("Room Manager -> Disposed!"); + LOGGER.info("Room Manager -> Disposed!"); } public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) { @@ -1471,7 +1474,7 @@ public class RoomManager { statement.setString(10, map); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return this.loadCustomLayout(room); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index fa43278b..853a452d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -43,7 +43,7 @@ public class RoomPromotion { statement.setInt(4, this.room.getId()); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.needsUpdate = false; 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 eb6ac5cd..86fd5922 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -206,7 +206,7 @@ public class RoomTrade { statement.executeBatch(); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } THashSet itemsUserOne = new THashSet<>(userOne.getItems()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 0c5582ee..07c2a093 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -361,7 +361,7 @@ public class RoomUnit { return false; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 3f478feb..a4656a57 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -51,7 +51,7 @@ public class TraxManager implements Disposable { stmt.setInt(2, musicDisc.getId()); stmt.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return; } } else { @@ -67,7 +67,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -157,7 +157,7 @@ public class TraxManager implements Disposable { statement.setInt(2, musicDisc.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return; } @@ -184,7 +184,7 @@ public class TraxManager implements Disposable { statement.setInt(2, itemId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return; } @@ -277,7 +277,7 @@ public class TraxManager implements Disposable { statement.setInt(1, this.room.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index b3fb1399..120d59bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -148,7 +148,7 @@ public class Habbo implements Runnable { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { @@ -164,7 +164,7 @@ public class Habbo implements Runnable { this.habboStats.dispose(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); return; } finally { Emulator.getGameEnvironment().getRoomManager().unloadRoomsForHabbo(this); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 197f535e..59afdfc3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -77,7 +77,7 @@ public class HabboBadge implements Runnable { this.needsUpdate = false; } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index 0632c0b8..a5a0768f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -79,7 +79,7 @@ public class HabboInfo implements Runnable { this.online = false; this.currentRoom = null; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.loadCurrencies(); @@ -97,7 +97,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -113,14 +113,14 @@ public class HabboInfo implements Runnable { statement.setInt(4, b); statement.addBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return true; } }); statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -135,7 +135,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -160,7 +160,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -171,7 +171,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, search.getId()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -494,7 +494,7 @@ public class HabboInfo implements Runnable { statement.setInt(13, this.id); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java index 52db8cf6..340819e5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -24,37 +24,37 @@ public class HabboInventory { try { this.badgesComponent = new BadgesComponent(this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.botsComponent = new BotsComponent(this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.effectsComponent = new EffectsComponent(this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.itemsComponent = new ItemsComponent(this, this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.petsComponent = new PetsComponent(this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } try { this.wardrobeComponent = new WardrobeComponent(this.habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.items = MarketPlace.getOwnOffers(this.habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index f689c504..e5e05f68 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -107,7 +107,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { //serverMessage.appendString( ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) : "")); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } @@ -264,7 +264,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setInt(10, this.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); Emulator.getLogging().logErrorLine("SQLException trying to save HabboItem: " + this.toString()); } @@ -272,7 +272,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } 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 27adcc59..8975b888 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Rank; -import com.eu.habbo.habbohotel.users.inventory.EffectsComponent; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; @@ -14,6 +13,8 @@ import com.eu.habbo.messages.outgoing.users.UserPerksComposer; import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer; import com.eu.habbo.plugin.events.users.UserRankChangedEvent; import com.eu.habbo.plugin.events.users.UserRegisteredEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -26,6 +27,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class HabboManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboManager.class); + //Configuration. Loaded from database & updated accordingly. public static String WELCOME_MESSAGE = ""; public static boolean NAMECHANGE_ENABLED = false; @@ -37,7 +41,7 @@ public class HabboManager { this.onlineHabbos = new ConcurrentHashMap<>(); - Emulator.getLogging().logStart("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static HabboInfo getOfflineHabboInfo(int id) { @@ -50,7 +54,7 @@ public class HabboManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return info; @@ -68,7 +72,7 @@ public class HabboManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return info; @@ -111,7 +115,7 @@ public class HabboManager { } statement.close(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } habbo = this.cloneCheck(userId); @@ -144,15 +148,15 @@ public class HabboManager { stmt.setInt(2, habbo.getHabboInfo().getId()); stmt.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } catch (Exception ex) { - Emulator.getLogging().logErrorLine(ex); + LOGGER.error("Caught exception", ex); } return habbo; @@ -193,7 +197,7 @@ public class HabboManager { // - Emulator.getLogging().logShutdownLine("Habbo Manager -> Disposed!"); + LOGGER.info("Habbo Manager -> Disposed!"); } public ArrayList getCloneAccounts(Habbo habbo, int limit) { @@ -211,7 +215,7 @@ public class HabboManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return habboInfo; @@ -229,7 +233,7 @@ public class HabboManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } return nameChanges; @@ -283,7 +287,7 @@ public class HabboManager { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } @@ -300,7 +304,7 @@ public class HabboManager { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java index caaaf4b8..0b2051f3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java @@ -53,7 +53,7 @@ public class HabboNavigatorWindowSettings { statement.setString(4, displayMode.name().toLowerCase()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.displayModes.put(category, new HabboNavigatorPersonalDisplayMode(listMode, displayMode)); @@ -114,7 +114,7 @@ public class HabboNavigatorWindowSettings { statement.execute(); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 5e84e5cb..0069d965 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -228,7 +228,7 @@ public class HabboStats implements Runnable { statement.setInt(1, habboInfo.getId()); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return load(habboInfo); @@ -287,7 +287,7 @@ public class HabboStats implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return stats; @@ -365,7 +365,7 @@ public class HabboStats implements Runnable { this.navigatorWindowSettings.save(connection); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -479,7 +479,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.favoriteRooms.add(roomId); @@ -493,7 +493,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -519,7 +519,7 @@ public class HabboStats implements Runnable { statement.setInt(2, id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.secretRecipes.add(id); @@ -605,7 +605,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } @@ -620,7 +620,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java index 93b8e309..01307acf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java @@ -38,7 +38,7 @@ public class HabboOfferPurchase { statement.setInt(2, offerId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index 748ff259..1340f8d2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -51,7 +51,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return badgesList; @@ -78,7 +78,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return badgesList; } @@ -102,7 +102,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -112,7 +112,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index c919d56e..3db630c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java @@ -32,7 +32,7 @@ public class BotsComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 591ab435..e80f876e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -28,7 +28,7 @@ public class EffectsComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } if(habbo.getHabboInfo().getRank().getRoomEffect() > 0) this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect()); @@ -89,7 +89,7 @@ public class EffectsComponent { statement.setInt(5, effect.effect); statement.addBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } return true; @@ -97,7 +97,7 @@ public class EffectsComponent { statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.effects.clear(); @@ -205,7 +205,7 @@ public class EffectsComponent { statement.setInt(4, this.duration); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -215,7 +215,7 @@ public class EffectsComponent { statement.setInt(2, this.effect); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index 46f14581..e751ad66 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -49,12 +49,12 @@ public class ItemsComponent { Emulator.getLogging().logErrorLine("Failed to load HabboItem: " + set.getInt("id")); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return itemsList; diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java index a402f786..4d2e20a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java @@ -34,7 +34,7 @@ public class PetsComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java index 19bfdf4c..1e68dacf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java @@ -42,7 +42,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -149,7 +149,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index ce4b7361..935b740f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -199,7 +199,7 @@ public class WiredHandler { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } effect.activateBox(room); @@ -235,7 +235,7 @@ public class WiredHandler { statement.setInt(1, wiredId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -250,7 +250,7 @@ public class WiredHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } if (reward.badge) { @@ -404,7 +404,7 @@ public class WiredHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 5e797bec..42a6b353 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -31,7 +31,7 @@ public class WiredHighscoreManager { this.data.clear(); this.loadHighscoreData(); - Emulator.getLogging().logStart("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + logger.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); } @EventHandler @@ -65,7 +65,7 @@ public class WiredHighscoreManager { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } @@ -85,7 +85,7 @@ public class WiredHighscoreManager { statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 37635461..d7657c25 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -1,7 +1,7 @@ package com.eu.habbo.messages; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; +import com.eu.habbo.core.CreditsScheduler; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; @@ -71,18 +71,22 @@ import com.eu.habbo.messages.incoming.wired.WiredTriggerSaveDataEvent; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; public class PacketManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(PacketManager.class); + private static final List logList = new ArrayList<>(); public static boolean DEBUG_SHOW_PACKETS = false; public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; - public PacketManager() throws Exception { this.incoming = new THashMap<>(); this.callables = new THashMap<>(); @@ -165,7 +169,7 @@ public class PacketManager { if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { if (DEBUG_SHOW_PACKETS) { - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "NOT LOGGED IN" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + LOGGER.debug("[CLIENT][NOT LOGGED IN][{}] => {}", packet.getMessageId(), packet.getMessageBody()); } return; @@ -176,7 +180,7 @@ public class PacketManager { if (handler.getRatelimit() > 0) { if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) { if (PacketManager.DEBUG_SHOW_PACKETS) { - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "][" + Logging.ANSI_RED + "RATELIMITED" + Logging.ANSI_RESET + "] => " + packet.getMessageBody()); + LOGGER.debug("[CLIENT][{}][RATELIMITED] => {}", packet.getMessageId(), packet.getMessageBody()); } return; @@ -185,11 +189,12 @@ public class PacketManager { } } - if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + if (PacketManager.DEBUG_SHOW_PACKETS) { + LOGGER.debug("[CLIENT][{}] => {}", packet.getMessageId(), packet.getMessageBody()); + } if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) { - System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody())); + LOGGER.debug("[CLIENT][{}][{}] => {}", client.getHabbo().getHabboInfo().getUsername(), packet.getMessageId(), packet.getMessageBody()); } handler.client = client; @@ -205,11 +210,12 @@ public class PacketManager { handler.handle(); } } else { - if (PacketManager.DEBUG_SHOW_PACKETS) - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_YELLOW + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); + if (PacketManager.DEBUG_SHOW_PACKETS) { + LOGGER.debug("[CLIENT][UNDEFINED][{}] => {}", packet.getMessageId(), packet.getMessageBody()); + } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/ServerMessage.java b/src/main/java/com/eu/habbo/messages/ServerMessage.java index ee84e2f9..e5cf3204 100644 --- a/src/main/java/com/eu/habbo/messages/ServerMessage.java +++ b/src/main/java/com/eu/habbo/messages/ServerMessage.java @@ -1,17 +1,20 @@ package com.eu.habbo.messages; -import com.eu.habbo.Emulator; +import com.eu.habbo.util.HexUtils; 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.nio.charset.Charset; public class ServerMessage implements ReferenceCounted { + private static final Logger LOGGER = LoggerFactory.getLogger(ServerMessage.class); + private int header; private ByteBufOutputStream stream; private ByteBuf channelBuffer; @@ -29,7 +32,7 @@ public class ServerMessage implements ReferenceCounted { this.stream.writeInt(0); this.stream.writeShort(header); } catch (Exception e) { - Emulator.getLogging().handleException(e); + LOGGER.error("ServerMessage exception", e); } } @@ -42,7 +45,7 @@ public class ServerMessage implements ReferenceCounted { this.stream.writeInt(0); this.stream.writeShort(id); } catch (Exception e) { - Emulator.getLogging().handleException(e); + LOGGER.error("ServerMessage exception", e); } return this; } @@ -51,7 +54,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.write(bytes); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -66,7 +69,7 @@ public class ServerMessage implements ReferenceCounted { this.stream.writeShort(data.length); this.stream.write(data); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -74,7 +77,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeChar(obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -82,7 +85,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeChars(obj.toString()); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -90,7 +93,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeInt(obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -103,7 +106,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeInt((int) obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -111,7 +114,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeInt(obj ? 1 : 0); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -119,7 +122,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeShort((short) obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -127,7 +130,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeByte(b); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -135,7 +138,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeBoolean(obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -143,7 +146,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeDouble(d); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -151,7 +154,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.writeDouble(obj); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } } @@ -159,7 +162,7 @@ public class ServerMessage implements ReferenceCounted { try { this.stream.write(obj.get().array()); } catch (IOException e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("ServerMessage exception", e); } return this; @@ -170,19 +173,13 @@ public class ServerMessage implements ReferenceCounted { } public String getBodyString() { - ByteBuf buffer = this.stream.buffer().duplicate(); + byte[] data = this.get().array(); - buffer.setInt(0, buffer.writerIndex() - 4); - - String consoleText = buffer.toString(Charset.forName("UTF-8")); - - for (int i = 0; i < 14; i++) { - consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); + if (data.length == 0) { + return ""; } - buffer.discardSomeReadBytes(); - - return consoleText; + return HexUtils.pretty(data); } public int getHeader() { diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java index 5b16fead..30eef4b9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java @@ -50,7 +50,7 @@ public class CameraPublishToWebEvent extends MessageHandler { isOk = true; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index 5703549d..e7077d1c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -104,7 +104,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } else { userId = habbo.getHabboInfo().getId(); @@ -287,7 +287,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { try { guildId = Integer.parseInt(extraData); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java index a13616ee..5d618d19 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java @@ -50,7 +50,7 @@ public class FriendRequestEvent extends MessageHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); return; } } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java index 9dc377e3..cd1307a2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java @@ -60,7 +60,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } @@ -84,7 +84,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 13d1ee87..0923ac86 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -97,7 +97,7 @@ public class SecureLoginEvent extends MessageHandler { Emulator.getThreading().run(habbo); Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java index f6db73b1..e554ceab 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java @@ -30,7 +30,7 @@ public class HotelViewDataEvent extends MessageHandler { this.client.sendResponse(new HotelViewDataComposer(data, data.split(",")[data.split(",").length - 1])); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java index 11b6f3f3..ad9a7140 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java @@ -35,7 +35,7 @@ public class RequestInventoryItemsEvent extends MessageHandler { items.put(iterator.key(), iterator.value()); count++; } catch (NoSuchElementException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); break; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java index ffd2565a..75a7909d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java @@ -69,7 +69,7 @@ public class RequestDeleteRoomEvent extends MessageHandler { filter.execute(); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } else { String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getName()).replace("%roomowner%", room.getOwnerName()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 872db874..c5f71d4e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -89,7 +89,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { resultLists = toQueryResults(resultLists); this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists)); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } /* @@ -104,7 +104,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } */ } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index c9f0168c..3abc1a7a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -40,7 +40,7 @@ public class AnswerPollEvent extends MessageHandler { statement.setString(4, answer.toString()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } if (poll.lastQuestionId == questionId) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java index ef0c8ae5..02284cbe 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java @@ -24,7 +24,7 @@ public class CancelPollEvent extends MessageHandler { statement.setString(4, ""); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index 28fe03b3..048a772e 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -45,7 +45,7 @@ public class RedeemClothingEvent extends MessageHandler { statement.setInt(2, clothing.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().add(clothing.id); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index 0ad6804a..2bc02132 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -120,7 +120,7 @@ public class ToggleFloorItemEvent extends MessageHandler { this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java index 0b2e6ba9..f8fbcba2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java @@ -23,7 +23,7 @@ public class UseRandomStateItemEvent extends MessageHandler { InteractionRandomState randomStateItem = (InteractionRandomState)item; randomStateItem.onRandomStateClick(this.client, room); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java index 7a285f5d..333e86bc 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java @@ -42,7 +42,7 @@ public class CompostMonsterplantEvent extends MessageHandler { statement.setInt(1, pet.getId()); statement.executeUpdate(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java index 5f89d1fd..3b73995d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java @@ -41,7 +41,7 @@ public class HorseRemoveSaddleEvent extends MessageHandler { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 22c0d5cc..1cd43572 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -154,7 +154,7 @@ public class RoomUserWalkEvent extends MessageHandler { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java index dc75d455..8d8004b6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java @@ -80,7 +80,7 @@ public class ConfirmChangeNameEvent extends MessageHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } else { this.client.sendResponse(new ChangeNameCheckResultComposer(ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS, name, new ArrayList<>())); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java index 026b0261..580ab0da 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java @@ -49,7 +49,7 @@ public class AchievementListComposer extends MessageComposer { this.response.appendString(""); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java index 36c84966..d7c340be 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java @@ -44,7 +44,7 @@ public class CatalogPagesListComposer extends MessageComposer { return this.response; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java index 04a0f26f..8507f9a6 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java @@ -54,7 +54,7 @@ public class MarketplaceOwnItemsComposer extends MessageComposer { this.response.appendInt(0); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 46caa6b9..4d829ac5 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -67,7 +67,7 @@ public class FriendsComposer extends MessageComposer { return this.response; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java index 19f05af4..588a974a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java @@ -73,7 +73,7 @@ public class GuildForumDataComposer extends MessageComposer { newComments = set.getInt(1); } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } response.appendInt(guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index 6115ef3b..3a7dae3f 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -32,7 +32,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.items.forEachEntry(this); return this.response; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index 59723fdb..da10c277 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -61,7 +61,7 @@ public class ModToolUserInfoComposer extends MessageComposer { return this.response; } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java index e811962b..8628a1d2 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java @@ -42,7 +42,7 @@ public class PrivateRoomsComposer extends MessageComposer { this.response.appendString("E"); return this.response; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java index cd4dab5a..4bf9a48e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java @@ -47,7 +47,7 @@ public class ProfileFriendsComposer extends MessageComposer { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } this.userId = habbo.getHabboInfo().getId(); @@ -101,7 +101,7 @@ public class ProfileFriendsComposer extends MessageComposer { this.response.appendString(this.haters.get(hatersIndex).getLook()); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java index c91a83fe..d4e4df03 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java @@ -23,7 +23,7 @@ public class UserCurrencyComposer extends MessageComposer { try { type = Integer.valueOf(s); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java index eecb7858..75895e72 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java @@ -60,7 +60,7 @@ public class UserProfileComposer extends MessageComposer { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } this.response.appendInt(achievementScore); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java index 4ac524fc..ca772404 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java @@ -25,7 +25,7 @@ public class ExecuteCommand extends RCONMessage { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); this.status = RCONMessage.STATUS_ERROR; this.message = e.getMessage(); } diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java index 2bebfc21..6c566e1d 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java @@ -27,7 +27,7 @@ public class GiveCredits extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java index 9c291db1..82b492c1 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java @@ -27,7 +27,7 @@ public class GivePixels extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java index 870f5677..072389b6 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java @@ -29,7 +29,7 @@ public class GivePoints extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java index d10fc328..ee01e139 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -31,7 +31,7 @@ public class GiveRespect extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java index e601268a..94c27399 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java @@ -26,7 +26,7 @@ public class GiveUserClothing extends RCONMessage { statement.setInt(2, object.target_id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java index b86893d1..abacad3e 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java @@ -31,7 +31,7 @@ public class MuteUser extends RCONMessage { this.status = HABBO_NOT_FOUND; } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java index 0af46298..33a2cf46 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -56,7 +56,7 @@ public class SendGift extends RCONMessage { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } else { username = habbo.getHabboInfo().getUsername(); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java index ae8f4d66..fc3546d5 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -29,7 +29,7 @@ public class SetMotto extends RCONMessage { statement.execute(); } } catch (SQLException e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java index 0a8859fe..1e1a6bf2 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -105,7 +105,7 @@ public class UpdateUser extends RCONMessage { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/networking/Server.java b/src/main/java/com/eu/habbo/networking/Server.java index 76b45b61..f59a6d5a 100644 --- a/src/main/java/com/eu/habbo/networking/Server.java +++ b/src/main/java/com/eu/habbo/networking/Server.java @@ -1,6 +1,5 @@ package com.eu.habbo.networking; -import com.eu.habbo.Emulator; import io.netty.bootstrap.ServerBootstrap; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.channel.ChannelFuture; @@ -9,10 +8,15 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.FixedRecvByteBufAllocator; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; public abstract class Server { + + private static final Logger LOGGER = LoggerFactory.getLogger(Server.class); + protected final ServerBootstrap serverBootstrap; protected final EventLoopGroup bossGroup; protected final EventLoopGroup workerGroup; @@ -48,22 +52,22 @@ public abstract class Server { } if (!channelFuture.isSuccess()) { - Emulator.getLogging().logShutdownLine("Failed to connect to the host (" + this.host + ":" + this.port + ")@" + this.name); + LOGGER.info("Failed to connect to the host (" + this.host + ":" + this.port + ")@" + this.name); System.exit(0); } else { - Emulator.getLogging().logStart("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); + LOGGER.info("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); } } public void stop() { - Emulator.getLogging().logShutdownLine("Stopping " + this.name); + LOGGER.info("Stopping " + this.name); try { this.workerGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); this.bossGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync(); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Exception during " + this.name + " shutdown... HARD STOP"); + LOGGER.error("Exception during {} shutdown... HARD STOP", this.name, e); } - Emulator.getLogging().logShutdownLine("GameServer Stopped!"); + LOGGER.info("GameServer Stopped!"); } public ServerBootstrap getServerBootstrap() { diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java index 7bcba9ba..5635d9c9 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraClient.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraClient.java @@ -1,6 +1,5 @@ package com.eu.habbo.networking.camera; -import com.eu.habbo.core.Logging; import com.eu.habbo.networking.camera.messages.outgoing.CameraLoginComposer; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.UnpooledByteBufAllocator; @@ -8,8 +7,13 @@ import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CameraClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(CameraClient.class); + private static final String host = "google.com"; private static final int port = 1232; public static ChannelFuture channelFuture; @@ -47,10 +51,10 @@ public class CameraClient { if (CameraClient.channelFuture.isSuccess()) { CameraClient.attemptReconnect = false; CameraClient.channel = channelFuture.channel(); - System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Connected to the Camera Server. Attempting to login..."); + LOGGER.info("Connected to the Camera Server. Attempting to login."); this.sendMessage(new CameraLoginComposer()); } else { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to connect to the Camera Server. Server unreachable."); + LOGGER.error("Failed to connect to the Camera Server. Server unreachable."); CameraClient.channel = null; CameraClient.channelFuture.channel().close(); CameraClient.channelFuture = null; @@ -71,7 +75,7 @@ public class CameraClient { channel = null; isLoggedIn = false; - System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Disconnected from the camera server."); + LOGGER.info("Disconnected from the camera server."); } public void sendMessage(CameraOutgoingMessage outgoingMessage) { diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java index 72dc7c1a..8d52ee08 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java @@ -38,7 +38,7 @@ public class CameraPacketHandler { message.handle(channel); message.buffer.release(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java index 467e9014..a13a5092 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java @@ -1,12 +1,16 @@ package com.eu.habbo.networking.camera.messages.incoming; -import com.eu.habbo.core.Logging; import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CameraLoginStatusEvent extends CameraIncomingMessage { + + private static final Logger LOGGER = LoggerFactory.getLogger(CameraLoginStatusEvent.class); + public final static int LOGIN_OK = 0; public final static int LOGIN_ERROR = 1; public final static int NO_ACCOUNT = 2; @@ -24,28 +28,27 @@ public class CameraLoginStatusEvent extends CameraIncomingMessage { int status = this.readInt(); if (status == LOGIN_ERROR) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to login to Camera Server: Incorrect Details"); + LOGGER.error("Failed to login to Camera Server: Incorrect Details"); } else if (status == NO_ACCOUNT) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to login to Camera Server: No Account Found. Register for free on the Arcturus Forums! Visit http://arcturus.pw/"); + LOGGER.error("Failed to login to Camera Server: No Account Found. Register for free on the Arcturus Forums! Visit http://arcturus.pw/"); } else if (status == BANNED) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Sorry but you seem to be banned from the Arcturus forums and therefor cant use the Camera Server :'("); + LOGGER.error("Sorry but you seem to be banned from the Arcturus forums and therefor cant use the Camera Server :'("); } else if (status == ALREADY_LOGGED_IN) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] You seem to be already connected to the Camera Server"); + LOGGER.error("You seem to be already connected to the Camera Server"); } else if (status == OLD_BUILD) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] This version of Arcturus Emulator is no longer supported by the Camera Server. Upgrade your emulator."); + LOGGER.error("This version of Arcturus Emulator is no longer supported by the Camera Server. Upgrade your emulator."); } else if (status == NO_CAMERA_SUBSCRIPTION) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] You don't have a Camera Subscription and therefor cannot use the camera!"); - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Please consider making a donation to keep this project going. The emulator can be used free of charge!"); - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] By donating this subscription you support the development of the emulator you are using :)"); - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Visit http://arcturus.pw/mysubscriptions.php to buy your subscription!"); - System.out.println(""); - System.out.println("\t\t\t\t Please Consider getting a subscription. Regards: The General"); + LOGGER.error("You don't have a Camera Subscription and therefor cannot use the camera!"); + LOGGER.error("Please consider making a donation to keep this project going. The emulator can be used free of charge!"); + LOGGER.error("A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); + LOGGER.error("By donating this subscription you support the development of the emulator you are using :)"); + LOGGER.error("Visit http://arcturus.pw/mysubscriptions.php to buy your subscription!"); + LOGGER.error("Please Consider getting a subscription. Regards: The General"); } if (status == LOGIN_OK) { CameraClient.isLoggedIn = true; - System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] Succesfully connected to the Arcturus Camera Server!"); + LOGGER.info("Succesfully connected to the Arcturus Camera Server!"); } else { CameraClient.attemptReconnect = false; } diff --git a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java index d0d0504c..358e8e1c 100644 --- a/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java +++ b/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java @@ -1,13 +1,17 @@ package com.eu.habbo.networking.camera.messages.incoming; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.networking.camera.CameraIncomingMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CameraUpdateNotification extends CameraIncomingMessage { + + private static final Logger LOGGER = LoggerFactory.getLogger(CameraUpdateNotification.class); + public CameraUpdateNotification(Short header, ByteBuf body) { super(header, body); } @@ -19,11 +23,11 @@ public class CameraUpdateNotification extends CameraIncomingMessage { int type = this.readInt(); if (type == 0) { - System.out.println("[" + Logging.ANSI_GREEN + "CAMERA" + Logging.ANSI_RESET + "] " + message); + LOGGER.info("Camera update: {}", message); } else if (type == 1) { - System.out.println("[" + Logging.ANSI_YELLOW + "CAMERA" + Logging.ANSI_RESET + "] " + message); + LOGGER.warn("Camera update: {}", message); } else if (type == 2) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] " + message); + LOGGER.error("Camera update: {}", message); } if (alert) { 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 9674c707..022d5f16 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 @@ -40,7 +40,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { handler.run(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } 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 264a7837..b6ac3cf3 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 @@ -1,18 +1,25 @@ package com.eu.habbo.networking.gameserver.encoders; -import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.messages.ServerMessage; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageEncoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; public class GameServerMessageLogger extends MessageToMessageEncoder { + private static final Logger LOGGER = LoggerFactory.getLogger(GameServerMessageLogger.class); + @Override protected void encode(ChannelHandlerContext ctx, ServerMessage message, List out) throws Exception { - Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + message.getHeader() + "] -> " + message.getBodyString()); + LOGGER.debug("[SERVER][{}]", message.getHeader()); + + String body = message.getBodyString(); + if (body == null || body.length() == 0) { + LOGGER.debug("\n" + message.getBodyString()); + } out.add(message.retain()); } diff --git a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java index ea65161a..ebc225f5 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java @@ -1,7 +1,6 @@ package com.eu.habbo.networking.rconserver; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.messages.rcon.*; import com.eu.habbo.networking.Server; import com.google.gson.Gson; @@ -10,12 +9,17 @@ import gnu.trove.map.hash.THashMap; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class RCONServer extends Server { + + private static final Logger LOGGER = LoggerFactory.getLogger(RCONServer.class); + private final THashMap> messages; private final GsonBuilder gsonBuilder; List allowedAdresses = new ArrayList<>(); @@ -87,21 +91,19 @@ public class RCONServer extends Server { RCONMessage rcon = message.getDeclaredConstructor().newInstance(); Gson gson = this.gsonBuilder.create(); rcon.handle(gson, gson.fromJson(body, rcon.type)); - System.out.print("[" + Logging.ANSI_BLUE + "RCON" + Logging.ANSI_RESET + "] Handled RCON Message: " + message.getSimpleName()); + LOGGER.info("Handled RCON Message: {}", message.getSimpleName()); result = gson.toJson(rcon, RCONMessage.class); if (Emulator.debugging) { - System.out.print(" [" + Logging.ANSI_BLUE + "DATA" + Logging.ANSI_RESET + "]" + body + "[" + Logging.ANSI_BLUE + "RESULT" + Logging.ANSI_RESET + "]" + result); + LOGGER.debug("RCON Data {} RCON Result {}", body, result); } - System.out.println(""); return result; } catch (Exception ex) { - Emulator.getLogging().logErrorLine(ex); - Emulator.getLogging().logPacketError("[RCON] Failed to handle RCONMessage: " + message.getName() + ex.getMessage() + " by: " + ctx.channel().remoteAddress()); + LOGGER.error("Failed to handle RCONMessage", ex); } } else { - Emulator.getLogging().logPacketError("[RCON] Couldn't find: " + key); + LOGGER.error("Couldn't find: {}", key); } throw new ArrayIndexOutOfBoundsException("Unhandled RCON Message"); diff --git a/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java b/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java index f790cc7a..0563fe0e 100644 --- a/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java +++ b/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java @@ -2,7 +2,6 @@ package com.eu.habbo.networking.rconserver; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.google.gson.Gson; import com.google.gson.JsonObject; import io.netty.buffer.ByteBuf; @@ -10,8 +9,13 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RCONServerHandler extends ChannelInboundHandlerAdapter { + + private static final Logger LOGGER = LoggerFactory.getLogger(RCONServerHandler.class); + @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { String adress = ctx.channel().remoteAddress().toString().split(":")[0].replace("/", ""); @@ -23,7 +27,8 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter { } ctx.channel().close(); - Emulator.getLogging().logDebugLine("Remote connection closed: " + adress + ". IP not allowed!"); + + LOGGER.warn("RCON Remote connection closed: {}. IP not allowed!", adress); } @Override @@ -41,9 +46,9 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter { key = object.get("key").getAsString(); response = Emulator.getRconServer().handle(ctx, key, object.get("data").toString()); } catch (ArrayIndexOutOfBoundsException e) { - System.out.println("[" + Logging.ANSI_RED + "RCON" + Logging.ANSI_RESET + "] Unknown RCON Message: " + key); + LOGGER.error("Unknown RCON Message: {}", key); } catch (Exception e) { - Emulator.getLogging().logDebugLine("[RCON] Not JSON: " + message); + LOGGER.error("Invalid RCON Message: {}", message); e.printStackTrace(); } diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index de5d991b..d2d7c730 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.catalog.TargetOffer; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; +import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.games.tag.TagGame; import com.eu.habbo.habbohotel.items.ItemManager; @@ -43,6 +44,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -56,6 +59,9 @@ import java.util.NoSuchElementException; import java.util.Objects; public class PluginManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); + private final THashSet plugins = new THashSet<>(); private final THashSet methods = new THashSet<>(); @@ -169,7 +175,7 @@ public class PluginManager { if (!loc.exists()) { if (loc.mkdirs()) { - Emulator.getLogging().logStart("Created plugins directory!"); + LOGGER.info("Created plugins directory!"); } } @@ -203,12 +209,12 @@ public class PluginManager { this.plugins.add(plugin); plugin.onEnable(); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Could not load plugin " + pluginConfigurtion.name + "!"); - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Could not load plugin {}!", pluginConfigurtion.name); + LOGGER.error("Caught exception", e); } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } } } @@ -241,8 +247,8 @@ public class PluginManager { try { method.invoke(null, event); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Could not pass default event " + event.getClass().getName() + " to " + method.getClass().getName() + ":" + method.getName()); - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Could not pass default event {} to {}: {}!", event.getClass().getName(), method.getClass().getName(), method.getName()); + LOGGER.error("Caught exception", e); } } } @@ -260,8 +266,8 @@ public class PluginManager { try { method.invoke(plugin, event); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Could not pass event " + event.getClass().getName() + " to " + plugin.configuration.name); - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Could not pass event {} to {}", event.getClass().getName(), plugin.configuration.name); + LOGGER.error("Caught exception", e); } } } @@ -300,7 +306,7 @@ public class PluginManager { public void dispose() { this.disposePlugins(); - Emulator.getLogging().logShutdownLine("Disposed Plugin Manager!"); + LOGGER.info("Disposed Plugin Manager!"); } private void disposePlugins() { @@ -316,10 +322,9 @@ public class PluginManager { p.stream.close(); p.classLoader.close(); } catch (IOException e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } catch (Exception ex) { - Emulator.getLogging().logErrorLine("[CRITICAL][PLUGIN] Failed to disable " + p.configuration.name + " caused by: " + ex.getLocalizedMessage()); - Emulator.getLogging().logErrorLine(ex); + LOGGER.error("Failed to disable {} because of an exception.", p.configuration.name, ex); } } } catch (NoSuchElementException e) { @@ -336,7 +341,7 @@ public class PluginManager { this.loadPlugins(); - Emulator.getLogging().logStart("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Plugin Manager -> Loaded! " + this.plugins.size() + " plugins! (" + (System.currentTimeMillis() - millis) + " MS)"); this.registerDefaultEvents(); } @@ -355,8 +360,8 @@ public class PluginManager { this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); this.methods.add(WiredHighscoreManager.class.getMethod("onEmulatorLoaded", EmulatorLoadedEvent.class)); } catch (NoSuchMethodException e) { - Emulator.getLogging().logStart("Failed to define default events!"); - Emulator.getLogging().logErrorLine(e); + LOGGER.info("Failed to define default events!"); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/threading/ThreadPooling.java b/src/main/java/com/eu/habbo/threading/ThreadPooling.java index 62178767..160ca121 100644 --- a/src/main/java/com/eu/habbo/threading/ThreadPooling.java +++ b/src/main/java/com/eu/habbo/threading/ThreadPooling.java @@ -1,13 +1,19 @@ package com.eu.habbo.threading; import com.eu.habbo.Emulator; +import com.eu.habbo.util.imager.badges.BadgeImager; import io.netty.util.concurrent.DefaultThreadFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; public class ThreadPooling { + + private static final Logger LOGGER = LoggerFactory.getLogger(ThreadPooling.class); + public final int threads; private final ScheduledExecutorService scheduledPool; private volatile boolean canAdd; @@ -16,7 +22,7 @@ public class ThreadPooling { this.threads = threads; this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("ArcturusThreadFactory")); this.canAdd = true; - Emulator.getLogging().logStart("Thread Pool -> Loaded!"); + LOGGER.info("Thread Pool -> Loaded!"); } public ScheduledFuture run(Runnable run) { @@ -29,7 +35,7 @@ public class ThreadPooling { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return null; @@ -42,12 +48,12 @@ public class ThreadPooling { try { run.run(); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } }, delay, TimeUnit.MILLISECONDS); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); } return null; @@ -57,7 +63,7 @@ public class ThreadPooling { this.canAdd = false; this.scheduledPool.shutdownNow(); - Emulator.getLogging().logShutdownLine("Threading -> Disposed!"); + LOGGER.info("Threading -> Disposed!"); } public void setCanAdd(boolean canAdd) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java b/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java index 507330f1..a3b31144 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java +++ b/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java @@ -1,15 +1,19 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; -import com.eu.habbo.core.Logging; import com.eu.habbo.networking.camera.CameraClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CameraClientAutoReconnect implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(CameraClientAutoReconnect.class); + @Override public void run() { if (CameraClient.attemptReconnect && !Emulator.isShuttingDown) { if (!(CameraClient.channelFuture != null && CameraClient.channelFuture.channel().isRegistered())) { - System.out.println("[" + Logging.ANSI_YELLOW + "CAMERA" + Logging.ANSI_RESET + "] Attempting to connect to the Camera server."); + LOGGER.info("Attempting to connect to the Camera server."); if (Emulator.getCameraClient() != null) { Emulator.getCameraClient().disconnect(); } else { @@ -19,11 +23,11 @@ public class CameraClientAutoReconnect implements Runnable { try { Emulator.getCameraClient().connect(); } catch (Exception e) { - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Failed to start the camera client."); + LOGGER.error("Failed to start the camera client.", e); } } else { CameraClient.attemptReconnect = false; - System.out.println("[" + Logging.ANSI_RED + "CAMERA" + Logging.ANSI_RESET + "] Already connected to the camera. Reconnecting not needed!"); + LOGGER.info("Already connected to the camera. Reconnecting not needed!"); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java index b1af7db2..9c7e8624 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -2,10 +2,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class InsertModToolIssue implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(InsertModToolIssue.class); + private final ModToolIssue issue; public InsertModToolIssue(ModToolIssue issue) { @@ -36,7 +41,7 @@ public class InsertModToolIssue implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 07d84aae..23f72bba 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -100,7 +100,7 @@ public class OpenGift implements Runnable { this.habbo.getClient().sendResponse(new PresentItemOpenedComposer(inside, "", false)); } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java index 7cef3cff..b13decab 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java @@ -23,7 +23,7 @@ class QueryDeleteHabboBadge implements Runnable { statement.setString(2, this.name); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java index b8fb5746..d12d16de 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -24,7 +24,7 @@ public class QueryDeleteHabboItem implements Runnable { statement.setInt(1, this.itemId); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java index 0b6b0647..20340ee1 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -28,7 +28,7 @@ public class QueryDeleteHabboItems implements Runnable { statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } this.items.clear(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 18489aec..399e683f 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -42,7 +42,7 @@ public class RoomUnitTeleport implements Runnable { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } this.roomUnit.setPath(new LinkedList<>()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 4403235a..f3ab7254 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -29,7 +29,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } else { if (tile.isWalkable()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 10e13ce8..fde3f333 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -28,7 +28,7 @@ public class RoomUnitVendingMachineAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } else { if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java index 6007f83a..d046b669 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -34,7 +34,7 @@ public class SaveScoreForTeam implements Runnable { statement.executeBatch(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index b1a73ad7..3513b8f6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -112,7 +112,7 @@ class TeleportInteraction extends Thread { } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java index 03df0f4d..b79c87ec 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java @@ -24,7 +24,7 @@ public class UpdateModToolIssue implements Runnable { statement.setInt(5, this.issue.id); statement.execute(); } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index 6826af2e..c7b923a6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -100,7 +100,7 @@ class FreezeHandleSnowballExplosion implements Runnable { Emulator.getThreading().run(new FreezeResetExplosionTiles(freezeTiles, this.thrownData.room), 1000); } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + logger.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index 5be506d3..cdefe057 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -39,7 +39,7 @@ class HopperActionTwo implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } if (targetRoomId != 0 && targetItemId != 0) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index 5509f726..3e362919 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -72,7 +72,7 @@ class TeleportActionTwo implements Runnable { } } } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); + logger.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/util/HexUtils.java b/src/main/java/com/eu/habbo/util/HexUtils.java new file mode 100644 index 00000000..63846653 --- /dev/null +++ b/src/main/java/com/eu/habbo/util/HexUtils.java @@ -0,0 +1,57 @@ +package com.eu.habbo.util; + +import java.nio.charset.StandardCharsets; + +public class HexUtils { + + private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + + public static String toHex(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = HEX_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; + } + return new String(hexChars); + } + + public static byte[] toBytes(String hexString) { + int len = hexString.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + + Character.digit(hexString.charAt(i+1), 16)); + } + return data; + } + + public static String pretty(byte[] array) { + final int width = 32; + + StringBuilder builder = new StringBuilder(); + + for (int rowOffset = 0; rowOffset < array.length; rowOffset += width) { + builder.append(String.format("%06d: ", rowOffset)); + + for (int index = 0; index < width; index++) { + if (rowOffset + index < array.length) { + builder.append(String.format("%02x ", array[rowOffset + index])); + } else { + builder.append(" "); + } + } + + int asciiWidth = Math.min(width, array.length - rowOffset); + builder.append(" | "); + builder.append(new String(array, rowOffset, asciiWidth, StandardCharsets.UTF_8).replaceAll("\r\n", " ").replaceAll("\n", " ")); + + if (rowOffset + width < array.length) { + builder.append(String.format("%n")); + } + } + + return builder.toString(); + } + +} diff --git a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java b/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java index 01fac236..8ac8ef34 100644 --- a/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java +++ b/src/main/java/com/eu/habbo/util/callback/HTTPVersionCheck.java @@ -38,7 +38,7 @@ package com.eu.habbo.util.callback; buff.close(); in.close(); - Emulator.getLogging().logStart(text.toString()); + logger.info(text.toString()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new GenericAlertComposer(text.toString())); } wr.close(); diff --git a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java index 2872cad8..616f6978 100644 --- a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java +++ b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java @@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.GuildPart; import com.eu.habbo.habbohotel.guilds.GuildPartType; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.imageio.ImageIO; import java.awt.*; @@ -16,15 +18,17 @@ import java.io.File; import java.util.Map; public class BadgeImager { + + private static final Logger LOGGER = LoggerFactory.getLogger(BadgeImager.class); + final THashMap cachedImages = new THashMap<>(); public BadgeImager() { if (Emulator.getConfig().getBoolean("imager.internal.enabled")) { if (this.reload()) { - Emulator.getLogging().logStart("Badge Imager -> Loaded!"); - + LOGGER.info("Badge Imager -> Loaded!"); } else { - Emulator.getLogging().logStart("Badge Imager -> Disabled! Please check your configuration!"); + LOGGER.warn("Badge Imager -> Disabled! Please check your configuration!"); } } } @@ -113,7 +117,7 @@ public class BadgeImager { public synchronized boolean reload() { File file = new File(Emulator.getConfig().getValue("imager.location.badgeparts")); if (!file.exists()) { - Emulator.getLogging().logErrorLine("[BadgeImager] Output folder: " + Emulator.getConfig().getValue("imager.location.badgeparts") + " does not exist!"); + LOGGER.error("BadgeImager output folder: {} does not exist!", Emulator.getConfig().getValue("imager.location.badgeparts")); return false; } @@ -126,7 +130,7 @@ public class BadgeImager { try { this.cachedImages.put(map.getValue().valueA, ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().valueA.replace(".gif", ".png")))); } catch (Exception e) { - Emulator.getLogging().logStart(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueA.replace(".gif", ".png"))); + LOGGER.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueA.replace(".gif", ".png"))); } } @@ -134,14 +138,14 @@ public class BadgeImager { try { this.cachedImages.put(map.getValue().valueB, ImageIO.read(new File(Emulator.getConfig().getValue("imager.location.badgeparts"), "badgepart_" + map.getValue().valueB.replace(".gif", ".png")))); } catch (Exception e) { - Emulator.getLogging().logStart(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueB.replace(".gif", ".png"))); + LOGGER.info(("[Badge Imager] Missing Badge Part: " + Emulator.getConfig().getValue("imager.location.badgeparts") + "/badgepart_" + map.getValue().valueB.replace(".gif", ".png"))); } } } } } } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); return false; } @@ -157,7 +161,7 @@ public class BadgeImager { if (outputFile.exists()) return; } catch (Exception e) { - Emulator.getLogging().logErrorLine(e); + LOGGER.error("Caught exception", e); return; } @@ -235,7 +239,7 @@ public class BadgeImager { try { ImageIO.write(image, "PNG", outputFile); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to generate guild badge: " + outputFile + ".png Make sure the output folder exists and is writable!"); + LOGGER.error("Failed to generate guild badge: {}.png Make sure the output folder exists and is writable!", outputFile); } graphics.dispose(); From 89ff26f21b45154a8d562b608dcbf905717c795e Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Mon, 4 May 2020 22:24:09 +0200 Subject: [PATCH 02/12] More logging progress --- .../achievements/AchievementManager.java | 27 ++--- .../achievements/TalentTrackLevel.java | 17 +-- .../com/eu/habbo/habbohotel/bots/Bot.java | 6 +- .../eu/habbo/habbohotel/bots/BotManager.java | 28 +++-- .../eu/habbo/habbohotel/bots/ButlerBot.java | 5 +- .../habbo/habbohotel/catalog/CatalogItem.java | 13 ++- .../catalog/CatalogLimitedConfiguration.java | 10 +- .../habbo/habbohotel/catalog/CatalogPage.java | 9 +- .../eu/habbo/habbohotel/catalog/Voucher.java | 8 +- .../catalog/layouts/RoomBundleLayout.java | 10 +- .../catalog/marketplace/MarketPlace.java | 22 ++-- .../catalog/marketplace/MarketPlaceOffer.java | 10 +- .../commands/AddYoutubePlaylistCommand.java | 6 +- .../habbohotel/commands/BadgeCommand.java | 6 +- .../habbohotel/commands/EnableCommand.java | 6 +- .../commands/FilterWordCommand.java | 6 +- .../commands/RoomBundleCommand.java | 6 +- .../habbohotel/crafting/CraftingManager.java | 9 +- .../com/eu/habbo/habbohotel/games/Game.java | 6 +- .../games/battlebanzai/BattleBanzaiGame.java | 6 +- .../habbohotel/games/freeze/FreezeGame.java | 6 +- .../com/eu/habbo/habbohotel/guilds/Guild.java | 7 +- .../habbohotel/guilds/forums/ForumThread.java | 14 ++- .../guilds/forums/ForumThreadComment.java | 9 +- .../habbohotel/hotelview/HallOfFame.java | 5 +- .../habbo/habbohotel/hotelview/NewsList.java | 6 +- .../habbohotel/items/CrackableReward.java | 8 +- .../habbohotel/items/RandomStateParams.java | 7 +- .../habbohotel/items/YoutubeManager.java | 13 ++- .../interactions/InteractionColorPlate.java | 7 +- .../interactions/InteractionDefault.java | 7 +- .../items/interactions/InteractionGift.java | 8 +- .../interactions/InteractionMusicDisc.java | 10 +- .../InteractionRentableSpace.java | 8 +- .../items/interactions/InteractionWired.java | 5 +- .../InteractionWiredHighscore.java | 12 +- .../games/InteractionGameTimer.java | 8 +- .../WiredConditionHabboHasHandItem.java | 7 +- .../wired/effects/WiredEffectMatchFurni.java | 6 +- .../wired/effects/WiredEffectToggleFurni.java | 6 +- .../effects/WiredEffectToggleRandom.java | 6 +- .../interactions/wired/extra/WiredBlob.java | 10 +- .../triggers/WiredTriggerBotReachedFurni.java | 6 +- .../habbo/habbohotel/messenger/Message.java | 6 +- .../habbo/habbohotel/messenger/Messenger.java | 31 +++--- .../habbohotel/messenger/MessengerBuddy.java | 9 +- .../habbo/habbohotel/modtool/ModToolBan.java | 6 +- .../habbohotel/modtool/ModToolManager.java | 45 ++++---- .../habbohotel/modtool/ModToolSanctions.java | 17 +-- .../habbo/habbohotel/modtool/WordFilter.java | 10 +- .../permissions/PermissionsManager.java | 10 +- .../eu/habbo/habbohotel/pets/GnomePet.java | 6 +- .../eu/habbo/habbohotel/pets/HorsePet.java | 6 +- .../habbohotel/pets/MonsterplantPet.java | 6 +- .../com/eu/habbo/habbohotel/pets/Pet.java | 9 +- .../eu/habbo/habbohotel/pets/PetManager.java | 42 +++---- .../habbo/habbohotel/polls/PollManager.java | 8 +- .../habbohotel/rooms/CustomRoomLayout.java | 6 +- .../com/eu/habbo/habbohotel/rooms/Room.java | 105 +++++++++--------- .../eu/habbo/habbohotel/rooms/RoomBan.java | 14 +-- .../eu/habbo/habbohotel/rooms/RoomLayout.java | 5 +- .../habbo/habbohotel/rooms/RoomPromotion.java | 5 +- .../eu/habbo/habbohotel/rooms/RoomTrade.java | 5 +- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 7 +- .../habbo/habbohotel/rooms/TraxManager.java | 13 ++- .../com/eu/habbo/habbohotel/users/Habbo.java | 13 ++- .../eu/habbo/habbohotel/users/HabboBadge.java | 5 +- .../eu/habbo/habbohotel/users/HabboInfo.java | 26 +++-- .../habbohotel/users/HabboInventory.java | 18 +-- .../eu/habbo/habbohotel/users/HabboItem.java | 14 ++- .../users/HabboNavigatorWindowSettings.java | 7 +- .../eu/habbo/habbohotel/users/HabboStats.java | 21 ++-- .../users/cache/HabboOfferPurchase.java | 5 +- .../users/inventory/BadgesComponent.java | 12 +- .../users/inventory/BotsComponent.java | 5 +- .../users/inventory/EffectsComponent.java | 15 ++- .../users/inventory/ItemsComponent.java | 12 +- .../users/inventory/PetsComponent.java | 5 +- .../users/inventory/WardrobeComponent.java | 7 +- .../habbo/habbohotel/wired/WiredHandler.java | 12 +- .../highscores/WiredHighscoreManager.java | 10 +- .../camera/CameraPublishToWebEvent.java | 6 +- .../catalog/CatalogBuyItemAsGiftEvent.java | 10 +- .../catalog/marketplace/SellItemEvent.java | 8 +- .../incoming/friends/FriendRequestEvent.java | 6 +- .../incoming/guardians/GuardianVoteEvent.java | 6 +- .../incoming/guilds/RequestGuildBuyEvent.java | 6 +- .../guilds/forums/GuildForumListEvent.java | 8 +- .../incoming/handshake/SecureLoginEvent.java | 6 +- .../hotelview/HotelViewDataEvent.java | 7 +- .../inventory/RequestInventoryItemsEvent.java | 7 +- .../navigator/RequestCreateRoomEvent.java | 8 +- .../navigator/RequestDeleteRoomEvent.java | 8 +- .../RequestNewNavigatorRoomsEvent.java | 8 +- .../incoming/polls/AnswerPollEvent.java | 6 +- .../incoming/polls/CancelPollEvent.java | 6 +- .../incoming/rooms/RoomSettingsSaveEvent.java | 6 +- .../rooms/items/RedeemClothingEvent.java | 8 +- .../incoming/rooms/items/RedeemItemEvent.java | 14 ++- .../items/SavePostItStickyPoleEvent.java | 6 +- .../rooms/items/ToggleFloorItemEvent.java | 8 +- .../rooms/items/UseRandomStateItemEvent.java | 7 +- .../youtube/YoutubeRequestPlaylists.java | 6 +- .../rooms/pets/CompostMonsterplantEvent.java | 6 +- .../rooms/pets/HorseRemoveSaddleEvent.java | 8 +- .../rooms/users/RoomUserShoutEvent.java | 6 +- .../rooms/users/RoomUserTalkEvent.java | 6 +- .../rooms/users/RoomUserWalkEvent.java | 6 +- .../rooms/users/RoomUserWhisperEvent.java | 6 +- .../users/ConfirmChangeNameEvent.java | 6 +- .../incoming/users/RequestUserDataEvent.java | 6 +- .../incoming/users/UserSaveLookEvent.java | 6 +- .../achievements/AchievementListComposer.java | 6 +- .../catalog/CatalogPagesListComposer.java | 6 +- .../MarketplaceOwnItemsComposer.java | 6 +- .../outgoing/friends/FriendsComposer.java | 7 +- .../guilds/forums/GuildForumDataComposer.java | 6 +- .../inventory/InventoryItemsComposer.java | 7 +- .../modtool/ModToolUserInfoComposer.java | 6 +- .../navigator/PrivateRoomsComposer.java | 7 +- .../users/ProfileFriendsComposer.java | 9 +- .../outgoing/users/UserCurrencyComposer.java | 6 +- .../outgoing/users/UserProfileComposer.java | 6 +- .../habbo/messages/rcon/ExecuteCommand.java | 6 +- .../com/eu/habbo/messages/rcon/GiveBadge.java | 6 +- .../eu/habbo/messages/rcon/GiveCredits.java | 6 +- .../eu/habbo/messages/rcon/GivePixels.java | 6 +- .../eu/habbo/messages/rcon/GivePoints.java | 6 +- .../eu/habbo/messages/rcon/GiveRespect.java | 6 +- .../habbo/messages/rcon/GiveUserClothing.java | 6 +- .../eu/habbo/messages/rcon/IgnoreUser.java | 6 +- .../com/eu/habbo/messages/rcon/MuteUser.java | 6 +- .../com/eu/habbo/messages/rcon/SendGift.java | 5 +- .../com/eu/habbo/messages/rcon/SetMotto.java | 6 +- .../eu/habbo/messages/rcon/UpdateUser.java | 5 +- .../camera/CameraPacketHandler.java | 7 +- .../decoders/GameMessageHandler.java | 16 +-- .../habbo/threading/HabboExecutorService.java | 10 +- .../RejectedExecutionHandlerImpl.java | 6 +- .../com/eu/habbo/threading/ThreadPooling.java | 3 +- .../habbo/threading/runnables/OpenGift.java | 6 +- .../runnables/QueryDeleteHabboBadge.java | 6 +- .../runnables/QueryDeleteHabboItem.java | 6 +- .../runnables/QueryDeleteHabboItems.java | 6 +- .../threading/runnables/RoomUnitTeleport.java | 7 +- .../RoomUnitTeleportWalkToAction.java | 6 +- .../RoomUnitVendingMachineAction.java | 6 +- .../threading/runnables/SaveScoreForTeam.java | 6 +- .../runnables/TeleportInteraction.java | 6 +- .../runnables/UpdateModToolIssue.java | 6 +- .../freeze/FreezeHandleSnowballExplosion.java | 6 +- .../runnables/hopper/HopperActionTwo.java | 6 +- .../runnables/teleport/TeleportActionTwo.java | 6 +- 153 files changed, 987 insertions(+), 448 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java index a00a79cf..9de60de5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -18,20 +18,21 @@ import com.eu.habbo.plugin.events.users.achievements.UserAchievementLeveledEvent import com.eu.habbo.plugin.events.users.achievements.UserAchievementProgressEvent; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectIntProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.LinkedHashMap; import java.util.Map; public class AchievementManager { + private static final Logger LOGGER = LoggerFactory.getLogger(AchievementManager.class); + public static boolean TALENTTRACK_ENABLED = false; - private final THashMap achievements; - private final THashMap> talentTrackLevels; - public AchievementManager() { this.achievements = new THashMap<>(); this.talentTrackLevels = new THashMap<>(); @@ -58,7 +59,7 @@ public class AchievementManager { statement.setInt(4, amount); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -140,7 +141,7 @@ public class AchievementManager { try { badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase()); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); return; } } @@ -203,7 +204,7 @@ public class AchievementManager { statement.setInt(3, 1); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -217,7 +218,7 @@ public class AchievementManager { } statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -231,7 +232,7 @@ public class AchievementManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -254,9 +255,9 @@ public class AchievementManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } @@ -276,13 +277,13 @@ public class AchievementManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); - Emulator.getLogging().logErrorLine("Achievement Manager -> Failed to load!"); + LOGGER.error("Caught SQL exception", e); + LOGGER.error("Achievement Manager -> Failed to load!"); return; } } - logger.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public Achievement getAchievement(String name) { diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java index e104c4fa..e491523f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java +++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java @@ -5,27 +5,20 @@ import com.eu.habbo.habbohotel.items.Item; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class TalentTrackLevel { + private static final Logger LOGGER = LoggerFactory.getLogger(TalentTrackLevel.class); public TalentTrackType type; - - public int level; - - public TObjectIntMap achievements; - - public THashSet items; - - public String[] perks; - - public String[] badges; public TalentTrackLevel(ResultSet set) throws SQLException { @@ -46,7 +39,7 @@ public class TalentTrackLevel { if (achievement != null) { this.achievements.put(achievement, Integer.valueOf(achievementLevels[i])); } else { - Emulator.getLogging().logErrorLine("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type); + LOGGER.error("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type); } } } @@ -57,7 +50,7 @@ public class TalentTrackLevel { if (item != null) { this.items.add(item); } else { - logger.info("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); + LOGGER.error("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 197ecd4c..8cedc5ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -12,6 +12,8 @@ import com.eu.habbo.plugin.events.bots.BotShoutEvent; import com.eu.habbo.plugin.events.bots.BotTalkEvent; import com.eu.habbo.plugin.events.bots.BotWhisperEvent; import com.eu.habbo.threading.runnables.BotFollowHabbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -21,6 +23,8 @@ import java.util.ArrayList; import java.util.Arrays; public class Bot implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class); + public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";"); @@ -155,7 +159,7 @@ public class Bot implements Runnable { statement.execute(); this.needsUpdate = false; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 3d5754dc..e1b88271 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import com.eu.habbo.habbohotel.users.cache.HabboOfferPurchase; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; @@ -15,12 +16,15 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.plugin.events.bots.BotPickUpEvent; import com.eu.habbo.plugin.events.bots.BotPlacedEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.sql.*; import java.util.Map; public class BotManager { + private static final Logger LOGGER = LoggerFactory.getLogger(BotManager.class); final private static THashMap> botDefenitions = new THashMap<>(); public static int MINIMUM_CHAT_SPEED = 7; @@ -38,7 +42,7 @@ public class BotManager { this.reload(); - logger.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addBotDefinition(String type, Class botClazz) throws Exception { @@ -58,10 +62,10 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - logger.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); + LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!"); return false; } catch (Exception e) { - logger.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); return false; } } @@ -88,12 +92,12 @@ public class BotManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return bot; @@ -143,7 +147,7 @@ public class BotManager { try { topItem.onWalkOn(bot.getRoomUnit(), room, null); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } bot.cycle(false); @@ -193,11 +197,11 @@ public class BotManager { if (botClazz != null) return botClazz.getDeclaredConstructor(ResultSet.class).newInstance(set); else - Emulator.getLogging().logErrorLine("Unknown Bot Type: " + type); + LOGGER.error("Unknown Bot Type: " + type); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -208,7 +212,7 @@ public class BotManager { statement.setInt(1, bot.getId()); return statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -221,9 +225,9 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - logger.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); + LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!"); } catch (Exception e) { - logger.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); + LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage()); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index 11c82cc3..d776bee9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -8,6 +8,8 @@ import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -19,6 +21,7 @@ import java.util.List; import java.util.Map; public class ButlerBot extends Bot { + private static final Logger LOGGER = LoggerFactory.getLogger(ButlerBot.class); public static THashMap, Integer> serveItems = new THashMap<>(); public ButlerBot(ResultSet set) throws SQLException { @@ -43,7 +46,7 @@ public class ButlerBot extends Bot { serveItems.put(ks, set.getInt("item")); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java index 21e02620..c8d015e6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -3,9 +3,12 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,7 +17,7 @@ import java.sql.SQLException; import java.util.HashMap; public class CatalogItem implements ISerialize, Runnable, Comparable { - + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogItem.class); int id; int limitedStack; private int pageId; @@ -211,7 +214,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0) { @@ -258,8 +261,8 @@ public class CatalogItem implements ISerialize, Runnable, Comparable limitedNumbers; private int totalSet; @@ -47,7 +51,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(5, item.getLimitedSells()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -65,7 +69,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.totalSet += amount; @@ -98,7 +102,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(3, this.itemId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java index 53fab1c3..b161c201 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.catalog; -import com.eu.habbo.Emulator; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import gnu.trove.TCollections; @@ -8,12 +7,16 @@ import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; public abstract class CatalogPage implements Comparable, ISerialize { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPage.class); + protected final TIntArrayList offerIds = new TIntArrayList(); protected final THashMap childPages = new THashMap<>(); private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); @@ -70,8 +73,8 @@ public abstract class CatalogPage implements Comparable, ISerialize try { this.included.add(Integer.valueOf(id)); } catch (Exception e) { - logger.error("Caught exception", e); - Emulator.getLogging().logErrorLine("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); + LOGGER.error("Caught exception", e); + LOGGER.error("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")"); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java index cf37a8e2..b5e93b13 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -10,6 +12,8 @@ import java.util.ArrayList; import java.util.List; public class Voucher { + private static final Logger LOGGER = LoggerFactory.getLogger(Voucher.class); + public final int id; public final String code; public final int credits; @@ -41,7 +45,7 @@ public class Voucher { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -64,7 +68,7 @@ public class Voucher { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index e2bb6ed4..680d3e9b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -13,11 +13,15 @@ import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.Map; public class RoomBundleLayout extends SingleBundle { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleLayout.class); + public int roomId; public Room room; private int lastUpdate = 0; @@ -43,7 +47,7 @@ public class RoomBundleLayout extends SingleBundle { if (this.room != null) this.room.preventUnloading = true; } else { - Emulator.getLogging().logErrorLine("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); + LOGGER.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); } } @@ -185,7 +189,7 @@ public class RoomBundleLayout extends SingleBundle { statement.setInt(3, this.room.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -219,7 +223,7 @@ public class RoomBundleLayout extends SingleBundle { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId); diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index ca7ba320..f18ad446 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -16,6 +16,8 @@ import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemCancelledEvent; import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemOfferedEvent; import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemSoldEvent; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -26,6 +28,8 @@ import java.util.List; public class MarketPlace { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlace.class); + //Configuration. Loaded from database & updated accordingly. public static boolean MARKETPLACE_ENABLED = true; @@ -43,7 +47,7 @@ public class MarketPlace { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return offers; @@ -101,7 +105,7 @@ public class MarketPlace { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, false)); } } @@ -163,7 +167,7 @@ public class MarketPlace { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return offers; @@ -193,7 +197,7 @@ public class MarketPlace { message.appendInt(1); message.appendInt(itemId); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -208,7 +212,7 @@ public class MarketPlace { number = set.getInt("number"); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return number; @@ -226,7 +230,7 @@ public class MarketPlace { avg = set.getInt("avg"); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return calculateCommision(avg); @@ -294,7 +298,7 @@ public class MarketPlace { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -321,7 +325,7 @@ public class MarketPlace { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -388,7 +392,7 @@ public class MarketPlace { statement.setInt(2, offer.getOfferId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java index 4bfb6307..196544e7 100644 --- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java +++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java @@ -5,10 +5,14 @@ import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class MarketPlaceOffer implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlaceOffer.class); + public int avarage; public int count; private int offerId; @@ -66,7 +70,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -86,7 +90,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -160,7 +164,7 @@ public class MarketPlaceOffer implements Runnable { statement.setInt(3, this.offerId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java index 28fe8339..d590bb0e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -3,12 +3,16 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.YoutubeManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class AddYoutubePlaylistCommand extends Command { + private static final Logger LOGGER = LoggerFactory.getLogger(AddYoutubePlaylistCommand.class); + public AddYoutubePlaylistCommand() { super("cmd_add_youtube_playlist", Emulator.getTexts().getValue("commands.keys.cmd_add_youtube_playlist").split(";")); } @@ -49,7 +53,7 @@ public class AddYoutubePlaylistCommand extends Command { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist")); diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java index 31f54aac..1328ed19 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,6 +15,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class BadgeCommand extends Command { + private static final Logger LOGGER = LoggerFactory.getLogger(BadgeCommand.class); + public BadgeCommand() { super("cmd_badge", Emulator.getTexts().getValue("commands.keys.cmd_badge").split(";")); } @@ -72,7 +76,7 @@ public class BadgeCommand extends Command { return true; } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java index b2a9cef6..c56842b6 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java @@ -4,8 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EnableCommand extends Command { + private static final Logger LOGGER = LoggerFactory.getLogger(EnableCommand.class); + public EnableCommand() { super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";")); } @@ -38,7 +42,7 @@ public class EnableCommand extends Command { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java index 73cfb7e5..9e208a0a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java @@ -4,12 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.modtool.WordFilter; import com.eu.habbo.habbohotel.modtool.WordFilterWord; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class FilterWordCommand extends Command { + private static final Logger LOGGER = LoggerFactory.getLogger(FilterWordCommand.class); + public FilterWordCommand() { super("cmd_filterword", Emulator.getTexts().getValue("commands.keys.cmd_filterword").split(";")); } @@ -35,7 +39,7 @@ public class FilterWordCommand extends Command { statement.setString(2, replacement); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.error")); return true; } diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java index 2fd4031e..3b3f5161 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java @@ -7,10 +7,14 @@ import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts; import com.eu.habbo.habbohotel.catalog.layouts.RoomBundleLayout; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class RoomBundleCommand extends Command { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleCommand.class); + public RoomBundleCommand() { super("cmd_bundle", Emulator.getTexts().getValue("commands.keys.cmd_bundle").split(";")); } @@ -62,7 +66,7 @@ public class RoomBundleCommand extends Command { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } ((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java index abdbf28e..9fe611a4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -11,6 +13,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class CraftingManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CraftingManager.class); private final THashMap altars; @@ -53,14 +56,14 @@ public class CraftingManager { recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount")); altar.addIngredient(ingredientItem); } else { - Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); + LOGGER.error("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id")); } } } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -114,7 +117,7 @@ public class CraftingManager { } statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.altars.clear(); diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java index 619423e3..f8aa6c37 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -20,12 +20,14 @@ import com.eu.habbo.plugin.events.games.GameStartedEvent; import com.eu.habbo.plugin.events.games.GameStoppedEvent; import com.eu.habbo.threading.runnables.SaveScoreForTeam; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; import java.util.stream.Collectors; public abstract class Game implements Runnable { - + private static final Logger LOGGER = LoggerFactory.getLogger(Game.class); protected final THashMap teams = new THashMap<>(); protected final Room room; private final Class gameTeamClazz; @@ -73,7 +75,7 @@ public abstract class Game implements Runnable { return true; } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index 094ee146..31a561b5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -17,12 +17,16 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; public class BattleBanzaiGame extends Game { + private static final Logger LOGGER = LoggerFactory.getLogger(BattleBanzaiGame.class); + public static final int effectId = 32; @@ -149,7 +153,7 @@ public class BattleBanzaiGame extends Game { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index c44a7fa0..eb625350 100644 --- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -23,11 +23,15 @@ import com.eu.habbo.threading.runnables.freeze.FreezeThrowSnowball; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.Map; public class FreezeGame extends Game { + private static final Logger LOGGER = LoggerFactory.getLogger(FreezeGame.class); + public static final int effectId = 39; public static int POWER_UP_POINTS; @@ -261,7 +265,7 @@ public class FreezeGame extends Game { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java index f43e52b0..d77f6773 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.guilds; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -8,6 +10,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class Guild implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(Guild.class); public boolean needsUpdate; public int lastRequested = Emulator.getIntUnixTimestamp(); private int id; @@ -91,7 +94,7 @@ public class Guild implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -116,7 +119,7 @@ public class Guild implements Runnable { this.needsUpdate = false; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java index a1c7227a..5107be53 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java @@ -9,11 +9,15 @@ import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadBeforeCreated; import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCreated; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; public class ForumThread implements Runnable, ISerialize { + private static final Logger LOGGER = LoggerFactory.getLogger(ForumThread.class); + private final static THashMap> guildThreadsCache = new THashMap<>(); private final static THashMap forumThreadsCache = new THashMap<>(); @@ -108,7 +112,7 @@ public class ForumThread implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return createdThread; @@ -156,7 +160,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return threads; @@ -195,7 +199,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return foundThread; @@ -337,7 +341,7 @@ public class ForumThread implements Runnable, ISerialize { addComment(comment); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -461,7 +465,7 @@ public class ForumThread implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java index 9ff93d55..1be9631a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java @@ -8,10 +8,13 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentBeforeCreated; import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentCreated; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class ForumThreadComment implements Runnable, ISerialize { + private static final Logger LOGGER = LoggerFactory.getLogger(ForumThreadComment.class); private static THashMap forumCommentsCache = new THashMap<>(); private final int commentId; @@ -64,7 +67,7 @@ public class ForumThreadComment implements Runnable, ISerialize { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return foundComment; @@ -103,7 +106,7 @@ public class ForumThreadComment implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return createdComment; @@ -200,7 +203,7 @@ public class ForumThreadComment implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java index ef7f1986..a4c398b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java @@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -9,6 +11,7 @@ import java.sql.SQLException; import java.sql.Statement; public class HallOfFame { + private static final Logger LOGGER = LoggerFactory.getLogger(HallOfFame.class); private final THashMap winners = new THashMap<>(); @@ -32,7 +35,7 @@ public class HallOfFame { this.winners.put(winner.getId(), winner); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java index 623cb2c5..b3bebc4f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java +++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -9,6 +11,8 @@ import java.sql.Statement; import java.util.ArrayList; public class NewsList { + private static final Logger LOGGER = LoggerFactory.getLogger(NewsList.class); + private final ArrayList newsWidgets; public NewsList() { @@ -25,7 +29,7 @@ public class NewsList { this.newsWidgets.add(new NewsWidget(set)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java index 727fb47a..60497794 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -9,6 +11,8 @@ import java.util.HashMap; import java.util.Map; public class CrackableReward { + private static final Logger LOGGER = LoggerFactory.getLogger(CrackableReward.class); + public final int itemId; public final int count; public final Map> prizes; @@ -44,7 +48,7 @@ public class CrackableReward { itemId = Integer.valueOf(prize.split(":")[0]); chance = Integer.valueOf(prize.split(":")[1]); } else if (prize.contains(":")) { - Emulator.getLogging().logErrorLine("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance."); + LOGGER.error("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance."); } else { itemId = Integer.valueOf(prize.replace(":", "")); } @@ -52,7 +56,7 @@ public class CrackableReward { this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance)); this.totalChance += chance; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java index 931be676..bc9662a3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.items; -import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Arrays; public class RandomStateParams { + private static final Logger LOGGER = LoggerFactory.getLogger(RandomStateParams.class); + private int states = -1; private int delay = -1; @@ -22,7 +25,7 @@ public class RandomStateParams { this.delay = Integer.parseInt(keyValue[1]); break; default: - Emulator.getLogging().logDebugLine("RandomStateParams: unknown key: " + keyValue[0]); + LOGGER.warn("RandomStateParams: unknown key: " + keyValue[0]); break; } }); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index e3b680cd..d2f3d3bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -6,12 +6,13 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; -import java.net.MalformedURLException; import java.net.URL; import java.sql.*; import java.util.ArrayList; @@ -20,6 +21,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class YoutubeManager { + private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class); + public class YoutubeVideo { private final String id; private final int duration; @@ -80,7 +83,7 @@ public class YoutubeManager { Emulator.getThreading().run(() -> { ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); - logger.info("YouTube Manager -> Loading..."); + LOGGER.info("YouTube Manager -> Loading..."); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) { try (ResultSet set = statement.executeQuery()) { @@ -95,7 +98,7 @@ public class YoutubeManager { if (playlist != null) { playlists.add(playlist); } else { - Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId); + LOGGER.error("Failed to load YouTube playlist: " + playlistId); } this.playlists.put(itemId, playlists); @@ -103,7 +106,7 @@ public class YoutubeManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } youtubeDataLoaderPool.shutdown(); @@ -113,7 +116,7 @@ public class YoutubeManager { e.printStackTrace(); } - logger.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); }); } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index cd089ec3..133e83c9 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -1,14 +1,17 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionColorPlate extends InteractionDefault { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionColorPlate.class); + public InteractionColorPlate(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -41,7 +44,7 @@ public class InteractionColorPlate extends InteractionDefault { try { state = Integer.valueOf(this.getExtradata()); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } state += amount; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java index 95308f40..1db3a1d2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; @@ -10,11 +9,15 @@ import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.messages.ServerMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionDefault extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionDefault.class); + public InteractionDefault(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); } @@ -74,7 +77,7 @@ public class InteractionDefault extends HabboItem { try { currentState = Integer.valueOf(this.getExtradata()); } catch (NumberFormatException e) { - Emulator.getLogging().logErrorLine("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); + LOGGER.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")"); } this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount()); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java index 869b59a3..41fb4dc1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java @@ -8,11 +8,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionGift extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGift.class); + public boolean explode = false; private int[] itemId; private int colorId = 0; @@ -28,7 +32,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId()); + LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); } } @@ -38,7 +42,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId()); + LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index 9a163257..f001fc20 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -1,17 +1,19 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class InteractionMusicDisc extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionMusicDisc.class); + private int songId; public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException { @@ -23,7 +25,7 @@ public class InteractionMusicDisc extends HabboItem { try { this.songId = Integer.valueOf(stuff[6]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); + LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); } } } @@ -37,7 +39,7 @@ public class InteractionMusicDisc extends HabboItem { try { this.songId = Integer.valueOf(stuff[6]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); + LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!"); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java index d1ee8065..48a4d35a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java @@ -12,6 +12,8 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceInfoComposer; import com.eu.habbo.threading.runnables.ClearRentedSpace; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -20,6 +22,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class InteractionRentableSpace extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionRentableSpace.class); + private int renterId; private String renterName; private int endTimestamp; @@ -50,7 +54,7 @@ public class InteractionRentableSpace extends HabboItem { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } else { @@ -180,7 +184,7 @@ public class InteractionRentableSpace extends HabboItem { statement.setInt(1, zero); statement.setInt(2, zero); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index e3c9c702..a465367c 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,6 +16,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public abstract class InteractionWired extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class); private long cooldown; InteractionWired(ResultSet set, Item baseItem) throws SQLException { @@ -71,7 +74,7 @@ public abstract class InteractionWired extends HabboItem { statement.setInt(2, this.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } super.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 88a196ac..9708c565 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -3,19 +3,23 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; -import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType; import com.eu.habbo.messages.ServerMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; public class InteractionWiredHighscore extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWiredHighscore.class); + public WiredHighscoreScoreType scoreType; public WiredHighscoreClearType clearType; @@ -33,7 +37,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.reloadData(); @@ -51,7 +55,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.reloadData(); @@ -83,7 +87,7 @@ public class InteractionWiredHighscore extends HabboItem { this.setExtradata(Math.abs(state - 1) + ""); room.updateItem(this); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index 3b064dfa..6197b017 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -13,12 +13,16 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; public class InteractionGameTimer extends HabboItem implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGameTimer.class); + private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; private int baseTime = 0; @@ -89,7 +93,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { } }).toArray(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -117,7 +121,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { room.addGame(game); game.initialise(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 079ac0e0..e47107c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -1,6 +1,5 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.rooms.Room; @@ -8,11 +7,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredConditionHabboHasHandItem.class); + public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM; private int handItem; @@ -71,7 +74,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { try { this.handItem = Integer.valueOf(set.getString("wired_data")); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index b379fe9c..f4642bf5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -17,11 +17,15 @@ import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class WiredEffectMatchFurni extends InteractionWiredEffect { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class); + private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT; public boolean checkForWiredResetPermission = true; private THashSet settings; @@ -189,7 +193,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect { } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java index 2605a4f8..e602c042 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java @@ -19,6 +19,8 @@ import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -26,6 +28,8 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectToggleFurni extends InteractionWiredEffect { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class); + public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE; private final THashSet items; @@ -136,7 +140,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()}); } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index 0caf0ef3..98b41137 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -17,6 +17,8 @@ import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -24,6 +26,8 @@ import java.util.ArrayList; import java.util.List; public class WiredEffectToggleRandom extends InteractionWiredEffect { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class); + public static final WiredEffectType type = WiredEffectType.TOGGLE_RANDOM; private final THashSet items = new THashSet<>(); @@ -120,7 +124,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + ""); room.updateItem(item); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } return true; diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java index b46c81c9..0017efe8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java @@ -1,22 +1,24 @@ package com.eu.habbo.habbohotel.items.interactions.wired.extra; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameState; import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; -import com.eu.habbo.habbohotel.games.freeze.FreezeGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionDefault; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; public class WiredBlob extends InteractionDefault { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredBlob.class); + enum WiredBlobState { ACTIVE("0"), USED("1"); @@ -104,14 +106,14 @@ public class WiredBlob extends InteractionDefault { String[] params = this.getBaseItem().getCustomParams().split(","); if (params.length != 2) { - Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)"); + LOGGER.error("Wired blobs should have customparams with two parameters (points,resetsWithGame)"); return; } try { this.POINTS_REWARD = Integer.parseInt(params[0]); } catch (NumberFormatException e) { - Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)"); + LOGGER.error("Wired blobs should have customparams with the first parameter being the amount of points (number)"); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index 56b98ebd..73c543c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -14,6 +14,8 @@ import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; @@ -21,6 +23,8 @@ import java.util.ArrayList; import java.util.List; public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class); + public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_STF; private THashSet items; @@ -157,7 +161,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { if (item != null) this.items.add(item); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java index 5949ae4b..a081bfc5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java @@ -1,12 +1,16 @@ package com.eu.habbo.habbohotel.messenger; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class Message implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(Message.class); + private final int fromId; private final int toId; private final int timestamp; @@ -31,7 +35,7 @@ public class Message implements Runnable { statement.setInt(4, this.timestamp); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index 250a7a52..15ef797a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -11,6 +11,8 @@ import com.eu.habbo.plugin.events.users.friends.UserAcceptFriendRequestEvent; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,6 +22,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Messenger { + + private static final Logger LOGGER = LoggerFactory.getLogger(Messenger.class); + //Configuration. Loaded from database & updated accordingly. public static boolean SAVE_PRIVATE_CHATS = false; public static int MAXIMUM_FRIENDS = 200; @@ -41,7 +46,7 @@ public class Messenger { statement.setInt(4, userOne); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -55,7 +60,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return users; } @@ -85,7 +90,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -102,7 +107,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -114,7 +119,7 @@ public class Messenger { statement.setInt(2, userFrom); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -133,7 +138,7 @@ public class Messenger { count = set.getInt("count"); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return count; @@ -157,7 +162,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return map; } @@ -213,7 +218,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -237,7 +242,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return buddy; @@ -252,7 +257,7 @@ public class Messenger { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -311,7 +316,7 @@ public class Messenger { statement.setInt(1, userTo); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -323,7 +328,7 @@ public class Messenger { statement.setInt(3, userFrom); return statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -345,7 +350,7 @@ public class Messenger { statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Habbo habboTo = Emulator.getGameServer().getGameClientManager().getHabbo(userTo); diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 2ce143bf..4a292b87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,6 +16,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class MessengerBuddy implements Runnable, ISerialize { + private static final Logger LOGGER = LoggerFactory.getLogger(MessengerBuddy.class); private int id; private String username; @@ -44,7 +47,7 @@ public class MessengerBuddy implements Runnable, ISerialize { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -56,7 +59,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.relation = 0; this.userOne = 0; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -149,7 +152,7 @@ public class MessengerBuddy implements Runnable, ISerialize { statement.setInt(3, this.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java index e79c9ad3..3c8517da 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -9,6 +11,8 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; public class ModToolBan implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolBan.class); + public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public int userId; public String ip; @@ -63,7 +67,7 @@ public class ModToolBan implements Runnable { statement.setInt(9, this.cfhTopic); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index de887280..da144f97 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; @@ -21,6 +22,8 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import java.sql.*; @@ -29,6 +32,8 @@ import java.util.List; import java.util.Map; public class ModToolManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolManager.class); + private final TIntObjectMap category; private final THashMap> presets; private final THashMap tickets; @@ -41,7 +46,7 @@ public class ModToolManager { this.tickets = new THashMap<>(); this.cfhCategories = new TIntObjectHashMap<>(); this.loadModTool(); - logger.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void requestUserInfo(GameClient client, ClientMessage packet) { @@ -58,9 +63,9 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -78,7 +83,7 @@ public class ModToolManager { this.loadTickets(connection); this.loadCfhCategories(connection); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -97,7 +102,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -108,7 +113,7 @@ public class ModToolManager { this.presets.get(set.getString("type")).add(set.getString("preset")); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -120,7 +125,7 @@ public class ModToolManager { this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -146,7 +151,7 @@ public class ModToolManager { this.cfhCategories.get(set.getInt("support_cfh_category_id")).addTopic(new CfhTopic(set, this.getIssuePreset(set.getInt("default_sanction")))); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -198,7 +203,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -215,7 +220,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -235,7 +240,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatLogs; @@ -272,7 +277,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -290,7 +295,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return roomVisits; @@ -348,7 +353,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return roomVisits; @@ -378,7 +383,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return null; @@ -495,7 +500,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return ban; @@ -519,7 +524,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return banned; @@ -543,7 +548,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -557,7 +562,7 @@ public class ModToolManager { statement.execute(); return statement.getUpdateCount() > 0; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -662,7 +667,7 @@ public class ModToolManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return total; diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index e909120a..3960d07e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.sanctions.SanctionEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,6 +15,7 @@ import java.util.ArrayList; import java.util.Date; public class ModToolSanctions { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolSanctions.class); private final THashMap> sanctionHashmap; private final THashMap sanctionLevelsHashmap; @@ -22,8 +25,8 @@ public class ModToolSanctions { this.sanctionHashmap = new THashMap<>(); this.sanctionLevelsHashmap = new THashMap<>(); this.loadModSanctions(); - logger.info("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public synchronized void loadModSanctions() { @@ -41,7 +44,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -68,7 +71,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return this.sanctionHashmap; @@ -87,7 +90,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -98,7 +101,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -109,7 +112,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -120,7 +123,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } 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 f13e95fc..791d12d5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -9,6 +9,8 @@ import com.eu.habbo.plugin.events.users.UserTriggerWordFilterEvent; import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -18,6 +20,8 @@ import java.text.Normalizer; import java.util.regex.Pattern; public class WordFilter { + private static final Logger LOGGER = LoggerFactory.getLogger(WordFilter.class); + private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+"); //Configuration. Loaded from database & updated accordingly. public static boolean ENABLED_FRIENDCHAT = true; @@ -29,7 +33,7 @@ public class WordFilter { public WordFilter() { long start = System.currentTimeMillis(); this.reload(); - logger.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); + LOGGER.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); } private static String stripDiacritics(String str) { @@ -54,7 +58,7 @@ public class WordFilter { try { word = new WordFilterWord(set); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); continue; } @@ -67,7 +71,7 @@ public class WordFilter { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index 7051d864..e815b4b1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -6,6 +6,8 @@ import com.eu.habbo.plugin.HabboPlugin; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; @@ -13,6 +15,8 @@ import java.util.List; import java.util.Set; public class PermissionsManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManager.class); + private final TIntObjectHashMap ranks; private final TIntIntHashMap enables; private final THashMap> badges; @@ -25,7 +29,7 @@ public class PermissionsManager { this.reload(); - logger.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void reload() { @@ -58,7 +62,7 @@ public class PermissionsManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -71,7 +75,7 @@ public class PermissionsManager { this.enables.put(set.getInt("effect_id"), set.getInt("min_rank")); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java index de49ac85..b488f968 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -11,6 +13,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class GnomePet extends Pet implements IPetLook { + private static final Logger LOGGER = LoggerFactory.getLogger(GnomePet.class); + private final String gnomeData; public GnomePet(ResultSet set) throws SQLException { @@ -47,7 +51,7 @@ public class GnomePet extends Pet implements IPetLook { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java index c4cbc233..666fa8d1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -8,6 +10,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class HorsePet extends RideablePet { + private static final Logger LOGGER = LoggerFactory.getLogger(HorsePet.class); + private int hairColor; private int hairStyle; @@ -40,7 +44,7 @@ public class HorsePet extends RideablePet { statement.setInt(6, super.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } super.run(); diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index 3f242328..7d4d0300 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -13,6 +13,8 @@ import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -23,6 +25,8 @@ import java.util.LinkedHashMap; import java.util.Map; public class MonsterplantPet extends Pet implements IPetLook { + private static final Logger LOGGER = LoggerFactory.getLogger(MonsterplantPet.class); + public static final Map> bodyRarity = new LinkedHashMap>() { { this.put(1, new Pair<>("Blungon", 0)); @@ -138,7 +142,7 @@ public class MonsterplantPet extends Pet implements IPetLook { statement.setInt(13, this.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 143f7962..d5e13742 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -14,6 +14,8 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer; import com.eu.habbo.plugin.events.pets.PetTalkEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.Calendar; @@ -21,6 +23,7 @@ import java.util.Map; import java.util.TimeZone; public class Pet implements ISerialize, Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class); public int levelThirst; public int levelHunger; @@ -62,7 +65,7 @@ public class Pet implements ISerialize, Runnable { this.name = set.getString("name"); this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(set.getInt("type")); if (this.petData == null) { - Emulator.getLogging().logErrorLine("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!"); + LOGGER.error("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!"); this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(0); } this.race = set.getInt("race"); @@ -85,7 +88,7 @@ public class Pet implements ISerialize, Runnable { this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(type); if (this.petData == null) { - Emulator.getLogging().logErrorLine(new Exception("WARNING! Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!")); + LOGGER.warn("Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!"); } this.race = race; @@ -205,7 +208,7 @@ public class Pet implements ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index dce3d5f4..6b8b3d77 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -19,7 +19,8 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TIntObjectProcedure; import gnu.trove.set.hash.THashSet; import org.apache.commons.math3.distribution.NormalDistribution; -import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; @@ -27,6 +28,7 @@ import java.util.Collection; import java.util.Map; public class PetManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PetManager.class); public static final int[] experiences = new int[]{100, 200, 400, 600, 900, 1300, 1800, 2400, 3200, 4300, 5700, 7600, 10100, 13300, 17500, 23000, 30200, 39600, 51900}; static int[] skins = new int[]{0, 1, 6, 7}; public final THashMap petActions = new THashMap() { @@ -80,7 +82,7 @@ public class PetManager { reloadPetData(); - logger.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static int getLevel(int experience) { @@ -151,8 +153,8 @@ public class PetManager { this.loadPetCommands(connection); this.loadPetBreeding(connection); } catch (SQLException e) { - logger.error("Caught SQL exception", e); - Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!"); + LOGGER.error("Caught SQL exception", e); + LOGGER.error("Pet Manager -> Failed to load!"); } } @@ -167,7 +169,7 @@ public class PetManager { this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -177,7 +179,7 @@ public class PetManager { this.petData.put(set.getInt("pet_type"), new PetData(set)); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.loadPetItems(connection); @@ -217,7 +219,7 @@ public class PetManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -231,10 +233,10 @@ public class PetManager { if (petVocalsType != null) { this.petData.get(set.getInt("pet_id")).petVocals.get(petVocalsType).add(new PetVocal(set.getString("message"))); } else { - Emulator.getLogging().logErrorLine("Unknown pet vocal type " + set.getString("type")); + LOGGER.error("Unknown pet vocal type " + set.getString("type")); } } else { - Emulator.getLogging().logErrorLine("Missing pet_actions table entry for pet id " + set.getInt("pet_id")); + LOGGER.error("Missing pet_actions table entry for pet id " + set.getInt("pet_id")); } } else { if (!PetData.generalPetVocals.containsKey(PetVocalsType.valueOf(set.getString("type").toUpperCase()))) @@ -244,7 +246,7 @@ public class PetManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -255,7 +257,7 @@ public class PetManager { commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) { @@ -267,7 +269,7 @@ public class PetManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -277,7 +279,7 @@ public class PetManager { this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) { @@ -294,13 +296,13 @@ public class PetManager { this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } public THashSet getBreeds(String petName) { if (!petName.startsWith("a0 pet")) { - Emulator.getLogging().logErrorLine("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!"); + LOGGER.error("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!"); return null; } @@ -308,7 +310,7 @@ public class PetManager { int petId = Integer.valueOf(petName.split("t")[1]); return this.petRaces.get(petId); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -346,7 +348,7 @@ public class PetManager { return this.petData.get(type); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - Emulator.getLogging().logErrorLine("Missing petdata for type " + type + ". Adding this to the database..."); + LOGGER.error("Missing petdata for type " + type + ". Adding this to the database..."); try (PreparedStatement statement = connection.prepareStatement("INSERT INTO pet_actions (pet_type) VALUES (?)")) { statement.setInt(1, type); statement.execute(); @@ -358,13 +360,13 @@ public class PetManager { if (set.next()) { PetData petData = new PetData(set); this.petData.put(type, petData); - Emulator.getLogging().logErrorLine("Missing petdata for type " + type + " added to the database!"); + LOGGER.error("Missing petdata for type " + type + " added to the database!"); return petData; } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -511,7 +513,7 @@ public class PetManager { statement.setInt(1, pet.getId()); return statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java index 2841e741..8e2d78a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java @@ -3,10 +3,14 @@ package com.eu.habbo.habbohotel.polls; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class PollManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PollManager.class); + private final THashMap activePolls = new THashMap<>(); public PollManager() { @@ -23,7 +27,7 @@ public class PollManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; } @@ -63,7 +67,7 @@ public class PollManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java index 4a30e521..3ca0650f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -8,6 +10,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class CustomRoomLayout extends RoomLayout implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(CustomRoomLayout.class); + private final int roomId; private boolean needsUpdate; @@ -30,7 +34,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable { statement.setInt(5, this.roomId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } 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 a5d3975c..69b53ec0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -72,6 +72,8 @@ import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import io.netty.util.internal.ConcurrentSet; import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -86,6 +88,9 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; public class Room implements Comparable, ISerialize, Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(Room.class); + public static final Comparator SORT_SCORE = (o1, o2) -> { if (!(o1 instanceof Room && o2 instanceof Room)) @@ -265,7 +270,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBans(connection); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.tradeMode = set.getInt("trade_mode"); @@ -313,49 +318,49 @@ public class Room implements Comparable, ISerialize, Runnable { try { this.loadLayout(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadRights(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadItems(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadHeightmap(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadBots(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadPets(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadWordFilter(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.loadWiredData(connection); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.idleCycles = 0; @@ -363,7 +368,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.traxManager = new TraxManager(this); @@ -401,7 +406,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } else { - Emulator.getLogging().logErrorLine("Unknown Room Layout for Room (ID: " + this.id + ")"); + LOGGER.error("Unknown Room Layout for Room (ID: {})", this.id); } } @@ -416,11 +421,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (this.itemCount() > Room.MAXIMUM_FURNI) { - Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ")."); + LOGGER.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); } } @@ -438,14 +443,14 @@ public class Room implements Comparable, ISerialize, Runnable { ((InteractionWired) item).loadWiredData(set, this); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -481,7 +486,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -511,12 +516,12 @@ public class Room implements Comparable, ISerialize, Runnable { this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -531,7 +536,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -921,7 +926,7 @@ public class Room implements Comparable, ISerialize, Runnable { botIterator.value().needsUpdate(true); Emulator.getThreading().run(botIterator.value()); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -929,7 +934,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.currentBots.clear(); this.currentPets.clear(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -941,7 +946,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.preLoaded = true; this.layout = null; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -1033,7 +1038,7 @@ public class Room implements Comparable, ISerialize, Runnable { Emulator.getThreading().run( Room.this::cycle); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -1096,7 +1101,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.executeUpdate(); this.needsUpdate = false; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -1107,7 +1112,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -1250,7 +1255,7 @@ public class Room implements Comparable, ISerialize, Runnable { } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -1263,7 +1268,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -1458,7 +1463,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOn(unit, room, null); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); @@ -2010,7 +2015,7 @@ public class Room implements Comparable, ISerialize, Runnable { pet.needsUpdate = true; pet.run(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -2123,7 +2128,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(10, this.promotion.getCategory()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = true; @@ -2215,7 +2220,7 @@ public class Room implements Comparable, ISerialize, Runnable { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return true; @@ -2288,7 +2293,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (habbo != null) { this.furniOwnerNames.put(item.getUserId(), habbo.getUsername()); } else { - Emulator.getLogging().logDebugLine("Failed to find username for item (ID:" + item.getId() + ", UserID: " + item.getUserId() + ")"); + LOGGER.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); } } } @@ -2613,7 +2618,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -2674,7 +2679,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2694,7 +2699,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2716,7 +2721,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2759,7 +2764,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2838,7 +2843,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2993,7 +2998,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -3180,7 +3185,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.onUserSay(roomChatMessage); } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -3204,7 +3209,7 @@ public class Room implements Comparable, ISerialize, Runnable { item.onClick(habbo.getClient(), this, new Object[0]); break; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -3757,7 +3762,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3776,7 +3781,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3820,7 +3825,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3857,7 +3862,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3875,7 +3880,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(1, this.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.refreshRightsInRoom(); @@ -3942,7 +3947,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -4246,7 +4251,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -4263,7 +4268,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java index d22adb0d..3765175b 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -9,15 +11,11 @@ import java.sql.SQLException; public class RoomBan { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomBan.class); + public final int roomId; - - public final int userId; - - public final String username; - - public final int endTimestamp; public RoomBan(int roomId, int userId, String username, int endTimestamp) { @@ -42,7 +40,7 @@ public class RoomBan { statement.setInt(3, this.endTimestamp); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -53,7 +51,7 @@ public class RoomBan { statement.setInt(2, this.userId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 7eb6dbb0..80eec020 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.ResultSet; @@ -12,6 +14,7 @@ import java.util.LinkedList; import java.util.List; public class RoomLayout { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomLayout.class); protected static final int BASICMOVEMENTCOST = 10; protected static final int DIAGONALMOVEMENTCOST = 14; public static double MAXIMUM_STEP_HEIGHT = 1.1; @@ -42,7 +45,7 @@ public class RoomLayout { this.parse(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index 853a452d..f24e111a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -1,6 +1,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -8,6 +10,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class RoomPromotion { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomPromotion.class); private final Room room; public boolean needsUpdate; private String title; @@ -43,7 +46,7 @@ public class RoomPromotion { statement.setInt(4, this.room.getId()); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = false; 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 86fd5922..c6ba64e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -10,12 +10,15 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.trading.*; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; import java.util.List; public class RoomTrade { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomTrade.class); //Configuration. Loaded from database & updated accordingly. public static boolean TRADING_ENABLED = true; public static boolean TRADING_REQUIRES_PERK = true; @@ -206,7 +209,7 @@ public class RoomTrade { statement.executeBatch(); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } THashSet itemsUserOne = new THashSet<>(userOne.getItems()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 07c2a093..e6eb506d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -24,6 +24,8 @@ import com.eu.habbo.util.pathfinding.Rotation; import gnu.trove.map.TMap; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -31,6 +33,9 @@ import java.util.concurrent.ScheduledFuture; import java.util.stream.Collectors; public class RoomUnit { + + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnit.class); + public boolean isWiredTeleporting = false; private final ConcurrentHashMap status; private final THashMap cacheable; @@ -361,7 +366,7 @@ public class RoomUnit { return false; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); return false; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index a4656a57..c445158e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -15,6 +15,8 @@ import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxNowPlayingMessageComposer; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -25,6 +27,7 @@ import java.util.List; import java.util.stream.Collectors; public class TraxManager implements Disposable { + private static final Logger LOGGER = LoggerFactory.getLogger(TraxManager.class); private final Room room; private final List songs = new ArrayList<>(0); private int totalLength = 0; @@ -51,7 +54,7 @@ public class TraxManager implements Disposable { stmt.setInt(2, musicDisc.getId()); stmt.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } } else { @@ -67,7 +70,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -157,7 +160,7 @@ public class TraxManager implements Disposable { statement.setInt(2, musicDisc.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -184,7 +187,7 @@ public class TraxManager implements Disposable { statement.setInt(2, itemId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -277,7 +280,7 @@ public class TraxManager implements Disposable { statement.setInt(1, this.room.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index 120d59bf..242bdd02 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -20,6 +20,8 @@ import com.eu.habbo.plugin.events.users.UserPointsEvent; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -28,6 +30,9 @@ import java.util.*; import java.util.stream.Collectors; public class Habbo implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(Habbo.class); + private final HabboInfo habboInfo; private final HabboStats habboStats; private final Messenger messenger; @@ -122,7 +127,7 @@ public class Habbo implements Runnable { this.messenger.connectionChanged(this, true, false); Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); - Emulator.getLogging().logUserLine(this.habboInfo.getUsername() + " logged in from IP " + this.habboInfo.getIpLogin()); + LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); } @@ -148,7 +153,7 @@ public class Habbo implements Runnable { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { @@ -164,13 +169,13 @@ public class Habbo implements Runnable { this.habboStats.dispose(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); return; } finally { Emulator.getGameEnvironment().getRoomManager().unloadRoomsForHabbo(this); Emulator.getGameEnvironment().getHabboManager().removeHabbo(this); } - Emulator.getLogging().logUserLine(this.habboInfo.getUsername() + " disconnected."); + LOGGER.info("{} disconnected.", this.habboInfo.getUsername()); this.client = null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 59afdfc3..5903cdc5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; public class HabboBadge implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboBadge.class); private int id; private String code; private int slot; @@ -77,7 +80,7 @@ public class HabboBadge implements Runnable { this.needsUpdate = false; } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index a5a0768f..a7fd28a5 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -14,13 +14,17 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.procedure.TIntIntProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; public class HabboInfo implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboInfo.class); + public boolean firstVisit = false; private String username; private String motto; @@ -66,8 +70,8 @@ public class HabboInfo implements Runnable { this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(set.getInt("rank")); if (this.rank == null) { - Emulator.getLogging().logErrorLine("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); - Emulator.getLogging().logUserLine(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + LOGGER.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); + LOGGER.warn(this.username + " has an invalid rank with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(1); } @@ -79,7 +83,7 @@ public class HabboInfo implements Runnable { this.online = false; this.currentRoom = null; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.loadCurrencies(); @@ -97,7 +101,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -113,14 +117,14 @@ public class HabboInfo implements Runnable { statement.setInt(4, b); statement.addBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return true; } }); statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -135,7 +139,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -160,7 +164,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -171,7 +175,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, search.getId()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -494,7 +498,7 @@ public class HabboInfo implements Runnable { statement.setInt(13, this.id); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java index 340819e5..7eaf048d 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -1,13 +1,17 @@ package com.eu.habbo.habbohotel.users; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer; import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceState; import com.eu.habbo.habbohotel.users.inventory.*; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HabboInventory { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboInventory.class); + //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_ITEMS = 10000; private final THashSet items; @@ -24,37 +28,37 @@ public class HabboInventory { try { this.badgesComponent = new BadgesComponent(this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.botsComponent = new BotsComponent(this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.effectsComponent = new EffectsComponent(this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.itemsComponent = new ItemsComponent(this, this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.petsComponent = new PetsComponent(this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.wardrobeComponent = new WardrobeComponent(this.habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.items = MarketPlace.getOwnOffers(this.habbo); diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index e5e05f68..35b809dd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -21,6 +21,8 @@ import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; import gnu.trove.set.hash.THashSet; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.math3.util.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -29,10 +31,12 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Deque; import java.util.List; public abstract class HabboItem implements Runnable, IEventTriggers { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboItem.class); + private static Class[] TOGGLING_INTERACTIONS = new Class[]{ InteractionGameTimer.class, InteractionWired.class, @@ -107,7 +111,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers { //serverMessage.appendString( ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? Item.getCurrentHeight(this) : "")); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -264,15 +268,15 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setInt(10, this.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); - Emulator.getLogging().logErrorLine("SQLException trying to save HabboItem: " + this.toString()); + LOGGER.error("Caught SQL exception", e); + LOGGER.error("SQLException trying to save HabboItem: " + this.toString()); } this.needsUpdate = false; } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java index 0b2051f3..36c1c975 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.navigation.DisplayMode; import com.eu.habbo.habbohotel.navigation.ListMode; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -12,6 +14,7 @@ import java.sql.SQLException; import java.util.Map; public class HabboNavigatorWindowSettings { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboNavigatorWindowSettings.class); public final THashMap displayModes = new THashMap<>(2); private final int userId; public int x = 100; @@ -53,7 +56,7 @@ public class HabboNavigatorWindowSettings { statement.setString(4, displayMode.name().toLowerCase()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.displayModes.put(category, new HabboNavigatorPersonalDisplayMode(listMode, displayMode)); @@ -114,7 +117,7 @@ public class HabboNavigatorWindowSettings { statement.execute(); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 0069d965..99bf5650 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -13,6 +13,8 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.stack.array.TIntArrayStack; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -24,6 +26,9 @@ import java.util.List; import java.util.Map; public class HabboStats implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboStats.class); + public final TIntArrayList secretRecipes; public final HabboNavigatorWindowSettings navigatorWindowSettings; public final THashMap cache; @@ -228,7 +233,7 @@ public class HabboStats implements Runnable { statement.setInt(1, habboInfo.getId()); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return load(habboInfo); @@ -287,7 +292,7 @@ public class HabboStats implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return stats; @@ -365,7 +370,7 @@ public class HabboStats implements Runnable { this.navigatorWindowSettings.save(connection); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -479,7 +484,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.favoriteRooms.add(roomId); @@ -493,7 +498,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -519,7 +524,7 @@ public class HabboStats implements Runnable { statement.setInt(2, id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.secretRecipes.add(id); @@ -605,7 +610,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -620,7 +625,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java index 01307acf..e3591750 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java @@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.users.cache; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -9,6 +11,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class HabboOfferPurchase { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboOfferPurchase.class); private final int userId; private final int offerId; private int state; @@ -38,7 +41,7 @@ public class HabboOfferPurchase { statement.setInt(2, offerId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return null; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index 1340f8d2..02573ff4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -5,6 +5,8 @@ import com.eu.habbo.habbohotel.permissions.Rank; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboBadge; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,6 +17,8 @@ import java.util.Comparator; import java.util.Set; public class BadgesComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(BadgesComponent.class); + private final THashSet badges = new THashSet<>(); public BadgesComponent(Habbo habbo) { @@ -51,7 +55,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return badgesList; @@ -78,7 +82,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return badgesList; } @@ -102,7 +106,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -112,7 +116,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index 3db630c3..cf9097bf 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -12,6 +14,7 @@ import java.sql.SQLException; import java.util.Map; public class BotsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(BotsComponent.class); private final THashMap bots = new THashMap<>(); @@ -32,7 +35,7 @@ public class BotsComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index e80f876e..99bff77a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -6,7 +6,8 @@ import com.eu.habbo.messages.outgoing.inventory.EffectsListAddComposer; import com.eu.habbo.messages.outgoing.inventory.EffectsListEffectEnableComposer; import com.eu.habbo.messages.outgoing.inventory.EffectsListRemoveComposer; import gnu.trove.map.hash.THashMap; -import gnu.trove.procedure.TObjectProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,6 +15,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class EffectsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(EffectsComponent.class); + public final THashMap effects = new THashMap<>(); public final Habbo habbo; public int activatedEffect = 0; @@ -28,7 +31,7 @@ public class EffectsComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if(habbo.getHabboInfo().getRank().getRoomEffect() > 0) this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect()); @@ -89,7 +92,7 @@ public class EffectsComponent { statement.setInt(5, effect.effect); statement.addBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } return true; @@ -97,7 +100,7 @@ public class EffectsComponent { statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.effects.clear(); @@ -205,7 +208,7 @@ public class EffectsComponent { statement.setInt(4, this.duration); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -215,7 +218,7 @@ public class EffectsComponent { statement.setInt(2, this.effect); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index e751ad66..613868c4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -15,6 +15,8 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -23,6 +25,8 @@ import java.sql.SQLException; import java.util.NoSuchElementException; public class ItemsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(ItemsComponent.class); + private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final HabboInventory inventory; @@ -46,15 +50,15 @@ public class ItemsComponent { if (item != null) { itemsList.put(set.getInt("id"), item); } else { - Emulator.getLogging().logErrorLine("Failed to load HabboItem: " + set.getInt("id")); + LOGGER.error("Failed to load HabboItem: " + set.getInt("id")); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return itemsList; @@ -150,7 +154,7 @@ public class ItemsComponent { TIntObjectIterator items = this.items.iterator(); if (items == null) { - Emulator.getLogging().logErrorLine(new RuntimeException("Items is NULL!")); + LOGGER.error("Items is NULL!"); return; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java index 4d2e20a4..cd963297 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java @@ -8,6 +8,8 @@ import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -17,6 +19,7 @@ import java.util.NoSuchElementException; import java.util.Set; public class PetsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(PetsComponent.class); private final TIntObjectMap pets = TCollections.synchronizedMap(new TIntObjectHashMap<>()); public PetsComponent(Habbo habbo) { @@ -34,7 +37,7 @@ public class PetsComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java index 1e68dacf..2d207132 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java @@ -7,6 +7,8 @@ import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.TIntSet; import gnu.trove.set.hash.TIntHashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,6 +16,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class WardrobeComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(WardrobeComponent.class); private final THashMap looks; private final TIntSet clothing; @@ -42,7 +45,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -149,7 +152,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index 935b740f..98924182 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -28,6 +28,8 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredStackExecutedEvent; import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceived; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -38,6 +40,8 @@ import java.util.Collections; import java.util.List; public class WiredHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredHandler.class); + //Configuration. Loaded from database & updated accordingly. public static int MAXIMUM_FURNI_SELECTION = 5; public static int TELEPORT_DELAY = 500; @@ -199,7 +203,7 @@ public class WiredHandler { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } effect.activateBox(room); @@ -235,7 +239,7 @@ public class WiredHandler { statement.setInt(1, wiredId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -250,7 +254,7 @@ public class WiredHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (reward.badge) { @@ -404,7 +408,7 @@ public class WiredHandler { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 42a6b353..31431699 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -3,6 +3,8 @@ package com.eu.habbo.habbohotel.wired.highscores; import com.eu.habbo.Emulator; import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -17,6 +19,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class WiredHighscoreManager { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredHighscoreManager.class); + private final HashMap> data = new HashMap<>(); private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(System.getProperty("user.language"), System.getProperty("user.country"))).getFirstDayOfWeek(); @@ -31,7 +35,7 @@ public class WiredHighscoreManager { this.data.clear(); this.loadHighscoreData(); - logger.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + LOGGER.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); } @EventHandler @@ -65,7 +69,7 @@ public class WiredHighscoreManager { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -85,7 +89,7 @@ public class WiredHighscoreManager { statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java index 30eef4b9..9d63b55a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java @@ -6,12 +6,16 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.camera.CameraPublishWaitMessageComposer; import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer; import com.eu.habbo.plugin.events.users.UserPublishPictureEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class CameraPublishToWebEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CameraPublishToWebEvent.class); + public static int CAMERA_PUBLISH_POINTS = 5; public static int CAMERA_PUBLISH_POINTS_TYPE = 0; @@ -50,7 +54,7 @@ public class CameraPublishToWebEvent extends MessageHandler { isOk = true; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index e7077d1c..8c08198a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -25,6 +25,8 @@ import com.eu.habbo.messages.outgoing.users.UserPointsComposer; import com.eu.habbo.threading.runnables.ShutdownEmulator; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -33,6 +35,8 @@ import java.sql.SQLException; import java.util.Calendar; public class CatalogBuyItemAsGiftEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogBuyItemAsGiftEvent.class); + @Override public void handle() throws Exception { if (Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboStats().lastGiftTimestamp >= CatalogManager.PURCHASE_COOLDOWN) { @@ -104,7 +108,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { userId = habbo.getHabboInfo().getId(); @@ -287,7 +291,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { try { guildId = Integer.parseInt(extraData); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -359,7 +363,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { this.client.sendResponse(new PurchaseOKComposer(item)); } catch (Exception e) { - Emulator.getLogging().logPacketError(e); + LOGGER.error("Exception caught", e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } finally { diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java index 5e8a793b..f63df2b2 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java @@ -7,8 +7,12 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.AlertPurchaseFailedComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceItemPostedComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SellItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SellItemEvent.class); + @Override public void handle() throws Exception { if (!MarketPlace.MARKETPLACE_ENABLED) { @@ -26,7 +30,7 @@ public class SellItemEvent extends MessageHandler { if (!item.getBaseItem().allowMarketplace()) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.forbidden").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -34,7 +38,7 @@ public class SellItemEvent extends MessageHandler { if (credits < 0) { String message = Emulator.getTexts().getValue("scripter.warning.marketplace.negative").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%itemname%", item.getBaseItem().getName()).replace("%credits%", credits + ""); ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java index 5d618d19..09f8ec6f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java @@ -8,6 +8,8 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.FriendRequestComposer; import com.eu.habbo.messages.outgoing.friends.FriendRequestErrorComposer; import com.eu.habbo.plugin.events.users.friends.UserRequestFriendshipEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,6 +18,8 @@ import java.sql.SQLException; public class FriendRequestEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(FriendRequestEvent.class); + @Override public void handle() throws Exception { String username = this.packet.readString(); @@ -50,7 +54,7 @@ public class FriendRequestEvent extends MessageHandler { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java index 0356b9ef..b2675d27 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java @@ -4,8 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guides.GuardianTicket; import com.eu.habbo.habbohotel.guides.GuardianVoteType; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GuardianVoteEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(GuardianVoteEvent.class); + @Override public void handle() throws Exception { int voteType = this.packet.readInt(); @@ -22,7 +26,7 @@ public class GuardianVoteEvent extends MessageHandler { } else if (voteType == 2) { type = GuardianVoteType.AWFULLY; } else { - Emulator.getLogging().logErrorLine("Uknown vote type: " + voteType); + LOGGER.error("Uknown vote type: " + voteType); } ticket.vote(this.client.getHabbo(), type); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java index ea5e530b..fd969b85 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java @@ -12,8 +12,12 @@ import com.eu.habbo.messages.outgoing.guilds.GuildBoughtComposer; import com.eu.habbo.messages.outgoing.guilds.GuildEditFailComposer; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.plugin.events.guilds.GuildPurchasedEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RequestGuildBuyEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestGuildBuyEvent.class); + @Override public void handle() throws Exception { if (!this.client.getHabbo().hasPermission("acc_infinite_credits")) { @@ -95,7 +99,7 @@ public class RequestGuildBuyEvent extends MessageHandler { } else { String message = Emulator.getTexts().getValue("scripter.warning.guild.buy.owner").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", r.getName().replace("%owner%", r.getOwnerName())); ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java index cd1307a2..991b7a7b 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java @@ -6,6 +6,8 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumListComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,6 +16,8 @@ import java.sql.SQLException; import java.util.Set; public class GuildForumListEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(GuildForumListEvent.class); + @Override public void handle() throws Exception { int mode = this.packet.readInt(); @@ -60,7 +64,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } @@ -84,7 +88,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 0923ac86..afe9ddf5 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -33,12 +33,16 @@ import com.eu.habbo.messages.outgoing.users.*; import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Date; @NoAuthMessage public class SecureLoginEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SecureLoginEvent.class); + @Override @@ -97,7 +101,7 @@ public class SecureLoginEvent extends MessageHandler { Emulator.getThreading().run(habbo); Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java index e554ceab..16f7fefd 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java @@ -1,10 +1,13 @@ package com.eu.habbo.messages.incoming.hotelview; -import com.eu.habbo.Emulator; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.HotelViewDataComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HotelViewDataEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewDataEvent.class); + @Override public void handle() { @@ -30,7 +33,7 @@ public class HotelViewDataEvent extends MessageHandler { this.client.sendResponse(new HotelViewDataComposer(data, data.split(",")[data.split(",").length - 1])); } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java index ad9a7140..2b9641cb 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java @@ -1,16 +1,19 @@ package com.eu.habbo.messages.incoming.inventory; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryItemsComposer; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.NoSuchElementException; public class RequestInventoryItemsEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestInventoryItemsEvent.class); + @Override public void handle() throws Exception { int totalItems = this.client.getHabbo().getInventory().getItemsComponent().getItems().size(); @@ -35,7 +38,7 @@ public class RequestInventoryItemsEvent extends MessageHandler { items.put(iterator.key(), iterator.value()); count++; } catch (NoSuchElementException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java index 222063b5..45ba380a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java @@ -7,8 +7,12 @@ import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer; import com.eu.habbo.messages.outgoing.navigator.RoomCreatedComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RequestCreateRoomEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestCreateRoomEvent.class); + @Override public void handle() throws Exception { @@ -20,14 +24,14 @@ public class RequestCreateRoomEvent extends MessageHandler { int tradeType = this.packet.readInt(); if (!Emulator.getGameEnvironment().getRoomManager().layoutExists(modelName)) { - Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect layout name \"" + modelName + "\". " + this.client.getHabbo().getHabboInfo().getUsername()); + LOGGER.error("[SCRIPTER] Incorrect layout name \"" + modelName + "\". " + this.client.getHabbo().getHabboInfo().getUsername()); return; } RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(categoryId); if (category == null || category.getMinRank() > this.client.getHabbo().getHabboInfo().getRank().getId()) { - Emulator.getLogging().logErrorLine("[SCRIPTER] Incorrect rank or non existing category ID: \"" + categoryId + "\"." + this.client.getHabbo().getHabboInfo().getUsername()); + LOGGER.error("[SCRIPTER] Incorrect rank or non existing category ID: \"" + categoryId + "\"." + this.client.getHabbo().getHabboInfo().getUsername()); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java index 75a7909d..3d7ebf41 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java @@ -6,12 +6,16 @@ import com.eu.habbo.habbohotel.modtool.ScripterManager; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.navigator.NavigatorRoomDeletedEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class RequestDeleteRoomEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestDeleteRoomEvent.class); + @Override public void handle() throws Exception { int roomId = this.packet.readInt(); @@ -69,12 +73,12 @@ public class RequestDeleteRoomEvent extends MessageHandler { filter.execute(); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { String message = Emulator.getTexts().getValue("scripter.warning.room.delete").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%roomname%", room.getName()).replace("%roomowner%", room.getOwnerName()); ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index c5f71d4e..4fb1dec0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -8,10 +8,14 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.navigator.NewNavigatorSearchResultsComposer; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; public class RequestNewNavigatorRoomsEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestNewNavigatorRoomsEvent.class); + @Override public void handle() throws Exception { String view = this.packet.readString(); @@ -89,7 +93,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { resultLists = toQueryResults(resultLists); this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists)); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } /* @@ -104,7 +108,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } */ } diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index 3abc1a7a..574e50ca 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -6,12 +6,16 @@ import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer; import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class AnswerPollEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AnswerPollEvent.class); + @Override public void handle() throws Exception { int pollId = this.packet.readInt(); @@ -40,7 +44,7 @@ public class AnswerPollEvent extends MessageHandler { statement.setString(4, answer.toString()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (poll.lastQuestionId == questionId) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java index 02284cbe..a38b5a03 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.incoming.polls; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.polls.Poll; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class CancelPollEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CancelPollEvent.class); + @Override public void handle() throws Exception { int pollId = this.packet.readInt(); @@ -24,7 +28,7 @@ public class CancelPollEvent extends MessageHandler { statement.setString(4, ""); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java index db338bf2..415809d6 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java @@ -7,8 +7,12 @@ import com.eu.habbo.habbohotel.rooms.RoomCategory; import com.eu.habbo.habbohotel.rooms.RoomState; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomSettingsSaveEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomSettingsSaveEvent.class); + @Override public void handle() throws Exception { int roomId = this.packet.readInt(); @@ -93,7 +97,7 @@ public class RoomSettingsSaveEvent extends MessageHandler { } ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index 048a772e..95382469 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -12,12 +12,16 @@ import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer; import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.users.UserClothesComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class RedeemClothingEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RedeemClothingEvent.class); + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); @@ -45,7 +49,7 @@ public class RedeemClothingEvent extends MessageHandler { statement.setInt(2, clothing.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().add(clothing.id); @@ -56,7 +60,7 @@ public class RedeemClothingEvent extends MessageHandler { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_OWNED_ALREADY.key)); } } else { - Emulator.getLogging().logErrorLine("[Catalog] No definition in catalog_clothing found for clothing name " + item.getBaseItem().getName() + ". Could not redeem clothing!"); + LOGGER.error("[Catalog] No definition in catalog_clothing found for clothing name " + item.getBaseItem().getName() + ". Could not redeem clothing!"); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java index a5f72a41..3533ca6d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java @@ -11,8 +11,12 @@ import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import com.eu.habbo.messages.outgoing.users.UserCurrencyComposer; import com.eu.habbo.plugin.events.furniture.FurnitureRedeemedEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RedeemItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RedeemItemEvent.class); + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); @@ -32,7 +36,7 @@ public class RedeemItemEvent extends MessageHandler { try { credits = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse redeemable furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_"); + LOGGER.error("Failed to parse redeemable furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_"); return; } @@ -43,7 +47,7 @@ public class RedeemItemEvent extends MessageHandler { try { pixels = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse redeemable pixel furniture: " + item.getBaseItem().getName() + ". Must be in format of PF_"); + LOGGER.error("Failed to parse redeemable pixel furniture: " + item.getBaseItem().getName() + ". Must be in format of PF_"); return; } @@ -55,14 +59,14 @@ public class RedeemItemEvent extends MessageHandler { try { pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); + LOGGER.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } try { points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); + LOGGER.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of DF__ where equals integer representation of seasonal currency."); return; } @@ -73,7 +77,7 @@ public class RedeemItemEvent extends MessageHandler { try { points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); } catch (Exception e) { - Emulator.getLogging().logErrorLine("Failed to parse redeemable diamonds furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_diamond_"); + LOGGER.error("Failed to parse redeemable diamonds furniture: " + item.getBaseItem().getName() + ". Must be in format of CF_diamond_"); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java index 8a672308..9f393896 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java @@ -7,10 +7,14 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.time.LocalDate; public class SavePostItStickyPoleEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SavePostItStickyPoleEvent.class); + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); @@ -26,7 +30,7 @@ public class SavePostItStickyPoleEvent extends MessageHandler { CommandHandler.handleCommand(this.client, command); } } else { - Emulator.getLogging().logUserLine("Scripter Alert! " + this.client.getHabbo().getHabboInfo().getUsername() + " | " + this.packet.readString()); + LOGGER.info("Scripter Alert! " + this.client.getHabbo().getHabboInfo().getUsername() + " | " + this.packet.readString()); } } else { String text = this.packet.readString(); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index 2bc02132..5b665d79 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -2,8 +2,8 @@ package com.eu.habbo.messages.incoming.rooms.items; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionDice; -import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed; import com.eu.habbo.habbohotel.items.interactions.InteractionWired; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; @@ -12,8 +12,12 @@ import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer; import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ToggleFloorItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(ToggleFloorItemEvent.class); + @Override public void handle() throws Exception { try { @@ -120,7 +124,7 @@ public class ToggleFloorItemEvent extends MessageHandler { this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java index f8fbcba2..85a357ff 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java @@ -1,12 +1,15 @@ package com.eu.habbo.messages.incoming.rooms.items; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.interactions.InteractionRandomState; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UseRandomStateItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(UseRandomStateItemEvent.class); + @Override public void handle() throws Exception { try { @@ -23,7 +26,7 @@ public class UseRandomStateItemEvent extends MessageHandler { InteractionRandomState randomStateItem = (InteractionRandomState)item; randomStateItem.onRandomStateClick(this.client, room); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java index 6c4b804b..15f9206a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java @@ -7,10 +7,14 @@ import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayListComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; public class YoutubeRequestPlaylists extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeRequestPlaylists.class); + @Override public void handle() throws Exception { int itemId = this.packet.readInt(); @@ -24,7 +28,7 @@ public class YoutubeRequestPlaylists extends MessageHandler { ArrayList playlists = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()); if (playlists == null) { - Emulator.getLogging().logErrorLine("No YouTube playlists set for base item #" + item.getBaseItem().getId()); + LOGGER.error("No YouTube playlists set for base item #" + item.getBaseItem().getId()); this.client.sendResponse(new ConnectionErrorComposer(1000)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java index 333e86bc..2b87a45a 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java @@ -8,12 +8,16 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.AddFloorItemComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class CompostMonsterplantEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CompostMonsterplantEvent.class); + @Override public void handle() throws Exception { int petId = this.packet.readInt(); @@ -42,7 +46,7 @@ public class CompostMonsterplantEvent extends MessageHandler { statement.setInt(1, pet.getId()); statement.executeUpdate(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java index 3b73995d..9c36827c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java @@ -10,6 +10,8 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetHorseFigureComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -17,6 +19,8 @@ import java.sql.ResultSet; import java.sql.SQLException; public class HorseRemoveSaddleEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(HorseRemoveSaddleEvent.class); + @Override public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); @@ -36,12 +40,12 @@ public class HorseRemoveSaddleEvent extends MessageHandler { if (set.next()) { saddleItemId = set.getInt("id"); } else { - Emulator.getLogging().logErrorLine("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId()); + LOGGER.error("There is no viable fallback saddle item for old horses with no saddle item ID. Horse pet ID: " + horse.getId()); return; } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java index 3e217e75..1c0e4fba 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java @@ -6,8 +6,12 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUserShoutEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserShoutEvent.class); + @Override public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) @@ -34,7 +38,7 @@ public class RoomUserShoutEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - Emulator.getLogging().logUserLine(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java index a3debf17..2201fb4c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java @@ -7,8 +7,12 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUserTalkEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserTalkEvent.class); + @Override public void handle() throws Exception { @@ -36,7 +40,7 @@ public class RoomUserTalkEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", message.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - Emulator.getLogging().logUserLine(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 1cd43572..859be049 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -12,8 +12,12 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.plugin.events.users.UserIdleEvent; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUserWalkEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserWalkEvent.class); + @Override public int getRatelimit() { return 500; @@ -154,7 +158,7 @@ public class RoomUserWalkEvent extends MessageHandler { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java index 7a35384e..b153138c 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java @@ -6,8 +6,12 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.plugin.events.users.UserTalkEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUserWhisperEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserWhisperEvent.class); + @Override public void handle() throws Exception { if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) @@ -31,7 +35,7 @@ public class RoomUserWhisperEvent extends MessageHandler { } else { String reportMessage = Emulator.getTexts().getValue("scripter.warning.chat.length").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%length%", chatMessage.getMessage().length() + ""); ScripterManager.scripterDetected(this.client, reportMessage); - Emulator.getLogging().logUserLine(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java index 8d8004b6..03e02149 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java @@ -10,6 +10,8 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserNameChangedComposer; import com.eu.habbo.messages.outgoing.users.ChangeNameCheckResultComposer; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.eu.habbo.plugin.events.users.UserNameChangedEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -18,6 +20,8 @@ import java.util.ArrayList; import java.util.List; public class ConfirmChangeNameEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfirmChangeNameEvent.class); + public static final List changingUsernames = new ArrayList<>(2); @Override @@ -80,7 +84,7 @@ public class ConfirmChangeNameEvent extends MessageHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { this.client.sendResponse(new ChangeNameCheckResultComposer(ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS, name, new ArrayList<>())); diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java index 01f1f1af..f4d37e90 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java @@ -8,10 +8,14 @@ import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.users.MeMenuSettingsComposer; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.eu.habbo.messages.outgoing.users.UserPerksComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; public class RequestUserDataEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestUserDataEvent.class); + @Override public void handle() throws Exception { if (this.client.getHabbo() != null) { @@ -59,7 +63,7 @@ public class RequestUserDataEvent extends MessageHandler { } else { - Emulator.getLogging().logDebugLine("Habbo is NULL!"); + LOGGER.debug("Attempted to request user data where Habbo was null."); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java b/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java index 97bcbf93..411f24e3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java @@ -8,8 +8,12 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; import com.eu.habbo.plugin.events.users.UserSavedLookEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UserSaveLookEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(UserSaveLookEvent.class); + @Override public void handle() throws Exception { String genderCode = this.packet.readString(); @@ -20,7 +24,7 @@ public class UserSaveLookEvent extends MessageHandler { } catch (IllegalArgumentException e) { String message = Emulator.getTexts().getValue("scripter.warning.look.gender").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%gender%", genderCode); ScripterManager.scripterDetected(this.client, message); - Emulator.getLogging().logUserLine(message); + LOGGER.info(message); return; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java index 580ab0da..54418f38 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java @@ -8,8 +8,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AchievementListComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(AchievementListComposer.class); + private final Habbo habbo; public AchievementListComposer(Habbo habbo) { @@ -49,7 +53,7 @@ public class AchievementListComposer extends MessageComposer { this.response.appendString(""); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return this.response; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java index d7c340be..1a23cd62 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java @@ -6,10 +6,14 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; public class CatalogPagesListComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPagesListComposer.class); + private final Habbo habbo; private final String mode; private final boolean hasPermission; @@ -44,7 +48,7 @@ public class CatalogPagesListComposer extends MessageComposer { return this.response; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java index 8507f9a6..d230697b 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java @@ -7,8 +7,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MarketplaceOwnItemsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketplaceOwnItemsComposer.class); + private final Habbo habbo; public MarketplaceOwnItemsComposer(Habbo habbo) { @@ -54,7 +58,7 @@ public class MarketplaceOwnItemsComposer extends MessageComposer { this.response.appendInt(0); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 4d829ac5..6832ff9e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.friends; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; @@ -8,10 +7,14 @@ import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class FriendsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(FriendsComposer.class); + private final Habbo habbo; public FriendsComposer(Habbo habbo) { @@ -67,7 +70,7 @@ public class FriendsComposer extends MessageComposer { return this.response; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java index 588a974a..3a64640a 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java @@ -12,6 +12,8 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,6 +22,8 @@ import java.sql.SQLException; public class GuildForumDataComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(GuildForumDataComposer.class); + public final Guild guild; public Habbo habbo; @@ -73,7 +77,7 @@ public class GuildForumDataComposer extends MessageComposer { newComments = set.getInt(1); } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } response.appendInt(guild.getId()); diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index 3a7dae3f..6fb8a0cd 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.inventory; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.FurnitureType; import com.eu.habbo.habbohotel.items.interactions.InteractionGift; import com.eu.habbo.habbohotel.users.HabboItem; @@ -9,8 +8,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.TIntObjectMap; import gnu.trove.procedure.TIntObjectProcedure; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure { + private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); + private final int page; private final int out; private final TIntObjectMap items; @@ -32,7 +35,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.items.forEachEntry(this); return this.response; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index da10c277..36e63b84 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -8,12 +8,16 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; public class ModToolUserInfoComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolUserInfoComposer.class); + private final ResultSet set; public ModToolUserInfoComposer(ResultSet set) { @@ -61,7 +65,7 @@ public class ModToolUserInfoComposer extends MessageComposer { return this.response; } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java index 8628a1d2..36a13e8c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java @@ -1,14 +1,17 @@ package com.eu.habbo.messages.outgoing.navigator; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; public class PrivateRoomsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(PrivateRoomsComposer.class); + private final List rooms; public PrivateRoomsComposer(List rooms) { @@ -42,7 +45,7 @@ public class PrivateRoomsComposer extends MessageComposer { this.response.appendString("E"); return this.response; } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java index 4bf9a48e..4cae8211 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.outgoing.users; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; @@ -8,6 +7,8 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; @@ -15,6 +16,8 @@ import java.util.Map; import java.util.Random; public class ProfileFriendsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(ProfileFriendsComposer.class); + private final List lovers = new ArrayList<>(); private final List friends = new ArrayList<>(); private final List haters = new ArrayList<>(); @@ -47,7 +50,7 @@ public class ProfileFriendsComposer extends MessageComposer { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.userId = habbo.getHabboInfo().getId(); @@ -101,7 +104,7 @@ public class ProfileFriendsComposer extends MessageComposer { this.response.appendString(this.haters.get(hatersIndex).getLook()); } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return this.response; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java index d4e4df03..d974ce80 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java @@ -5,8 +5,12 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UserCurrencyComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(UserCurrencyComposer.class); + private final Habbo habbo; public UserCurrencyComposer(Habbo habbo) { @@ -23,7 +27,7 @@ public class UserCurrencyComposer extends MessageComposer { try { type = Integer.valueOf(s); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); return null; } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java index 75895e72..b2944ea8 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java @@ -9,6 +9,8 @@ import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,6 +22,8 @@ import java.util.Date; import java.util.List; public class UserProfileComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(UserProfileComposer.class); + private final HabboInfo habboInfo; private Habbo habbo; private GameClient viewer; @@ -60,7 +64,7 @@ public class UserProfileComposer extends MessageComposer { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } this.response.appendInt(achievementScore); diff --git a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java index ca772404..fd16a35c 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java +++ b/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java @@ -4,8 +4,12 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.commands.CommandHandler; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ExecuteCommand extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteCommand.class); + public ExecuteCommand() { super(JSONExecuteCommand.class); @@ -25,7 +29,7 @@ public class ExecuteCommand extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveBadge.class); + public GiveBadge() { super(GiveBadgeJSON.class); @@ -74,7 +78,7 @@ public class GiveBadge extends RCONMessage { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.status = RCONMessage.STATUS_ERROR; this.message = e.getMessage(); } diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java index 6c566e1d..60e9326a 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class GiveCredits extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveCredits.class); + public GiveCredits() { super(JSONGiveCredits.class); @@ -27,7 +31,7 @@ public class GiveCredits extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java index 82b492c1..45001f98 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class GivePixels extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GivePixels.class); + public GivePixels() { super(JSONGivePixels.class); @@ -27,7 +31,7 @@ public class GivePixels extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java index 072389b6..2afff479 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class GivePoints extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GivePoints.class); + public GivePoints() { super(JSONGivePoints.class); @@ -29,7 +33,7 @@ public class GivePoints extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java index ee01e139..078f7143 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class GiveRespect extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveRespect.class); + public GiveRespect() { super(JSONGiveRespect.class); @@ -31,7 +35,7 @@ public class GiveRespect extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java index 94c27399..41b81669 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java +++ b/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java @@ -7,12 +7,16 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.users.UserClothesComposer; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class GiveUserClothing extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveUserClothing.class); + public GiveUserClothing() { super(GiveUserClothing.JSONGiveUserClothing.class); } @@ -26,7 +30,7 @@ public class GiveUserClothing extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(IgnoreUser.class); + public IgnoreUser() { super(JSONIgnoreUser.class); } @@ -26,7 +30,7 @@ public class IgnoreUser extends RCONMessage { statement.setInt(2, object.target_id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; diff --git a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java index abacad3e..711b7d22 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/MuteUser.java @@ -3,12 +3,16 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class MuteUser extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(MuteUser.class); + public MuteUser() { super(MuteUser.JSON.class); } @@ -31,7 +35,7 @@ public class MuteUser extends RCONMessage { this.status = HABBO_NOT_FOUND; } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java index 33a2cf46..8f644659 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -13,6 +15,7 @@ import java.sql.ResultSet; import java.sql.SQLException; public class SendGift extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(SendGift.class); public SendGift() { super(SendGiftJSON.class); @@ -56,7 +59,7 @@ public class SendGift extends RCONMessage { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { username = habbo.getHabboInfo().getUsername(); diff --git a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java index fc3546d5..88ce9c20 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -4,12 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class SetMotto extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(SetMotto.class); + public SetMotto() { super(SetMottoJSON.class); } @@ -29,7 +33,7 @@ public class SetMotto extends RCONMessage { statement.execute(); } } catch (SQLException e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java index 1e1a6bf2..7357a760 100644 --- a/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -6,12 +6,15 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.MeMenuSettingsComposer; import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer; import com.google.gson.Gson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class UpdateUser extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(UpdateUser.class); public UpdateUser() { super(UpdateUser.JSON.class); @@ -105,7 +108,7 @@ public class UpdateUser extends RCONMessage { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java index 8d52ee08..b0dc0582 100644 --- a/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java +++ b/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java @@ -1,13 +1,16 @@ package com.eu.habbo.networking.camera; -import com.eu.habbo.Emulator; import com.eu.habbo.networking.camera.messages.incoming.*; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; public class CameraPacketHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CameraPacketHandler.class); + private static CameraPacketHandler INSTANCE; private final HashMap> packetDefinitions; @@ -38,7 +41,7 @@ public class CameraPacketHandler { message.handle(channel); message.buffer.release(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } 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 022d5f16..143b6c61 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 @@ -8,11 +8,13 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.TooLongFrameException; - -import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @ChannelHandler.Sharable public class GameMessageHandler extends ChannelInboundHandlerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(GameMessageHandler.class); + @Override public void channelRegistered(ChannelHandlerContext ctx) { @@ -40,7 +42,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { handler.run(); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -52,15 +54,15 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (cause instanceof TooLongFrameException) { - Emulator.getLogging().logErrorLine("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); + LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); } else { cause.printStackTrace(); - Emulator.getLogging().logErrorLine("Disconnecting client, exception in GameMessageHander:"); - Emulator.getLogging().logErrorLine(cause.toString()); + LOGGER.error("Disconnecting client, exception in GameMessageHander:"); + LOGGER.error(cause.toString()); for (StackTraceElement element : cause.getStackTrace()) { - Emulator.getLogging().logErrorLine(element.toString()); + LOGGER.error(element.toString()); } } diff --git a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java index be426435..36ccd05a 100644 --- a/src/main/java/com/eu/habbo/threading/HabboExecutorService.java +++ b/src/main/java/com/eu/habbo/threading/HabboExecutorService.java @@ -1,12 +1,15 @@ package com.eu.habbo.threading; -import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; public class HabboExecutorService extends ScheduledThreadPoolExecutor { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboExecutorService.class); + public HabboExecutorService(int corePoolSize, ThreadFactory threadFactory) { super(corePoolSize, threadFactory); } @@ -16,10 +19,7 @@ public class HabboExecutorService extends ScheduledThreadPoolExecutor { super.afterExecute(r, t); if (t != null && !(t instanceof IOException)) { - try { - Emulator.getLogging().logErrorLine(t); - } catch (Exception e) { - } + LOGGER.error("Error in HabboExecutorService", t); } } } diff --git a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java index 2888ed04..1517ce17 100644 --- a/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java +++ b/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java @@ -1,14 +1,16 @@ package com.eu.habbo.threading; -import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RejectedExecutionHandlerImpl.class); @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { - Emulator.getLogging().logErrorLine(r.toString() + " is rejected"); + LOGGER.error(r.toString() + " is rejected"); } } diff --git a/src/main/java/com/eu/habbo/threading/ThreadPooling.java b/src/main/java/com/eu/habbo/threading/ThreadPooling.java index 160ca121..eb7e25c4 100644 --- a/src/main/java/com/eu/habbo/threading/ThreadPooling.java +++ b/src/main/java/com/eu/habbo/threading/ThreadPooling.java @@ -1,7 +1,6 @@ package com.eu.habbo.threading; import com.eu.habbo.Emulator; -import com.eu.habbo.util.imager.badges.BadgeImager; import io.netty.util.concurrent.DefaultThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +19,7 @@ public class ThreadPooling { public ThreadPooling(Integer threads) { this.threads = threads; - this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("ArcturusThreadFactory")); + this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("HabExec")); this.canAdd = true; LOGGER.info("Thread Pool -> Loaded!"); } diff --git a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 23f72bba..03e02605 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -11,6 +11,8 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryUpdateItemComposer; import com.eu.habbo.messages.outgoing.rooms.items.PresentItemOpenedComposer; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.HashMap; @@ -18,6 +20,8 @@ import java.util.List; import java.util.Map; public class OpenGift implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenGift.class); + private final HabboItem item; private final Habbo habbo; private final Room room; @@ -100,7 +104,7 @@ public class OpenGift implements Runnable { this.habbo.getClient().sendResponse(new PresentItemOpenedComposer(inside, "", false)); } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java index b13decab..2910fedd 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java @@ -2,12 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; class QueryDeleteHabboBadge implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboBadge.class); + private final String name; private final Habbo habbo; @@ -23,7 +27,7 @@ class QueryDeleteHabboBadge implements Runnable { statement.setString(2, this.name); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java index d12d16de..91579bfd 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -2,12 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class QueryDeleteHabboItem implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItem.class); + private final int itemId; public QueryDeleteHabboItem(int itemId) { @@ -24,7 +28,7 @@ public class QueryDeleteHabboItem implements Runnable { statement.setInt(1, this.itemId); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java index 20340ee1..71e30aca 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -3,12 +3,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.map.TIntObjectMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class QueryDeleteHabboItems implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItems.class); + private TIntObjectMap items; public QueryDeleteHabboItems(TIntObjectMap items) { @@ -28,7 +32,7 @@ public class QueryDeleteHabboItems implements Runnable { statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.items.clear(); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 399e683f..9228596a 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -1,6 +1,5 @@ package com.eu.habbo.threading.runnables; -import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -8,10 +7,14 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.LinkedList; public class RoomUnitTeleport implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitTeleport.class); + private RoomUnit roomUnit; private Room room; private int x; @@ -42,7 +45,7 @@ public class RoomUnitTeleport implements Runnable { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } this.roomUnit.setPath(new LinkedList<>()); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index f3ab7254..61c65c74 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -5,8 +5,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUnitTeleportWalkToAction implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitTeleportWalkToAction.class); + private final Habbo habbo; private final HabboItem habboItem; private final Room room; @@ -29,7 +33,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { if (tile.isWalkable()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index fde3f333..926e38f3 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -5,8 +5,12 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RoomUnitVendingMachineAction implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitVendingMachineAction.class); + private final Habbo habbo; private final HabboItem habboItem; private final Room room; @@ -28,7 +32,7 @@ public class RoomUnitVendingMachineAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java index d046b669..44151ae6 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -4,12 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.GamePlayer; import com.eu.habbo.habbohotel.games.GameTeam; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class SaveScoreForTeam implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(SaveScoreForTeam.class); + public final GameTeam team; public final Game game; @@ -34,7 +38,7 @@ public class SaveScoreForTeam implements Runnable { statement.executeBatch(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index 3513b8f6..83c6388d 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -11,8 +11,12 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class TeleportInteraction extends Thread { + private static final Logger LOGGER = LoggerFactory.getLogger(TeleportInteraction.class); + private final Room room; private final GameClient client; private final HabboItem teleportOne; @@ -112,7 +116,7 @@ class TeleportInteraction extends Thread { } } } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java index b79c87ec..70ea304b 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java +++ b/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java @@ -2,12 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; public class UpdateModToolIssue implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(UpdateModToolIssue.class); + private final ModToolIssue issue; public UpdateModToolIssue(ModToolIssue issue) { @@ -24,7 +28,7 @@ public class UpdateModToolIssue implements Runnable { statement.setInt(5, this.issue.id); statement.execute(); } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index c7b923a6..c8ba4612 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -10,8 +10,12 @@ import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class FreezeHandleSnowballExplosion implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(FreezeHandleSnowballExplosion.class); + private final FreezeThrowSnowball thrownData; public FreezeHandleSnowballExplosion(FreezeThrowSnowball thrownData) { @@ -100,7 +104,7 @@ class FreezeHandleSnowballExplosion implements Runnable { Emulator.getThreading().run(new FreezeResetExplosionTiles(freezeTiles, this.thrownData.room), 1000); } catch (Exception e) { - logger.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index cdefe057..97b04dca 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -4,6 +4,8 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -11,6 +13,8 @@ import java.sql.ResultSet; import java.sql.SQLException; class HopperActionTwo implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(HopperActionTwo.class); + private final HabboItem teleportOne; private final Room room; private final GameClient client; @@ -39,7 +43,7 @@ class HopperActionTwo implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (targetRoomId != 0 && targetItemId != 0) { diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index 3e362919..feedd769 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -9,6 +9,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.threading.runnables.HabboItemNewState; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -16,6 +18,8 @@ import java.sql.ResultSet; import java.sql.SQLException; class TeleportActionTwo implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(TeleportActionTwo.class); + private final HabboItem currentTeleport; private final Room room; private final GameClient client; @@ -72,7 +76,7 @@ class TeleportActionTwo implements Runnable { } } } catch (SQLException e) { - logger.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } From a0582c09eeef826b1ff1b6b7fa810988d9076ae3 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 00:20:07 +0200 Subject: [PATCH 03/12] Re-added Jansi, moved ClientMessage logging. --- pom.xml | 6 ++++ src/main/java/com/eu/habbo/Emulator.java | 15 ++++++++++ .../com/eu/habbo/messages/ClientMessage.java | 11 ++----- .../com/eu/habbo/messages/PacketManager.java | 19 ++++-------- .../com/eu/habbo/messages/ServerMessage.java | 11 ++----- .../java/com/eu/habbo/networking/Server.java | 11 ++++--- .../networking/gameserver/GameServer.java | 24 +++++++++------ .../decoders/GameClientMessageLogger.java | 23 ++++++++++++++ ...der.java => GameServerMessageEncoder.java} | 3 +- .../encoders/GameServerMessageLogger.java | 12 +++----- src/main/java/com/eu/habbo/util/ANSI.java | 16 ++++++++++ src/main/java/com/eu/habbo/util/HexUtils.java | 30 ------------------- .../java/com/eu/habbo/util/PacketUtils.java | 19 ++++++++++++ 13 files changed, 115 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java rename src/main/java/com/eu/habbo/networking/gameserver/encoders/{ServerMessageEncoder.java => GameServerMessageEncoder.java} (78%) create mode 100644 src/main/java/com/eu/habbo/util/ANSI.java create mode 100644 src/main/java/com/eu/habbo/util/PacketUtils.java diff --git a/pom.xml b/pom.xml index 68c85820..35de71dc 100644 --- a/pom.xml +++ b/pom.xml @@ -154,6 +154,12 @@ compile + + org.fusesource.jansi + jansi + 1.18 + + joda-time joda-time diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 8aece311..e361e1e5 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -1,6 +1,8 @@ package com.eu.habbo; import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.ConsoleAppender; import com.eu.habbo.core.*; import com.eu.habbo.core.consolecommands.ConsoleCommand; import com.eu.habbo.database.Database; @@ -30,6 +32,8 @@ import java.util.concurrent.ThreadLocalRandom; public final class Emulator { private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); + private static final String OS_NAME = System.getProperty("os.name"); + private static final String CLASS_PATH = System.getProperty("java.class.path"); public final static int MAJOR = 2; public final static int MINOR = 4; @@ -81,6 +85,17 @@ public final class Emulator { public static void main(String[] args) throws Exception { try { + // Check if running on Windows and not in IntelliJ. + // If so, we need to reconfigure the console appender and enable Jansi for colors. + if (OS_NAME.startsWith("Windows") && !CLASS_PATH.contains("idea_rt.jar")) { + ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + ConsoleAppender appender = (ConsoleAppender) root.getAppender("Console"); + + appender.stop(); + appender.setWithJansi(true); + appender.start(); + } + Locale.setDefault(new Locale("en")); setBuild(); Emulator.stopped = false; diff --git a/src/main/java/com/eu/habbo/messages/ClientMessage.java b/src/main/java/com/eu/habbo/messages/ClientMessage.java index 4cbd2f2d..a5185cb9 100644 --- a/src/main/java/com/eu/habbo/messages/ClientMessage.java +++ b/src/main/java/com/eu/habbo/messages/ClientMessage.java @@ -1,10 +1,9 @@ package com.eu.habbo.messages; +import com.eu.habbo.util.PacketUtils; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import java.nio.charset.Charset; - public class ClientMessage { private final int header; private final ByteBuf buffer; @@ -65,13 +64,7 @@ public class ClientMessage { } public String getMessageBody() { - String consoleText = this.buffer.toString(Charset.defaultCharset()); - - for (int i = -1; i < 31; i++) { - consoleText = consoleText.replace(Character.toString((char) i), "[" + i + "]"); - } - - return consoleText; + return PacketUtils.formatPacket(this.buffer); } public int bytesAvailable() { diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index d7657c25..8360b2bb 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -1,7 +1,6 @@ package com.eu.habbo.messages; import com.eu.habbo.Emulator; -import com.eu.habbo.core.CreditsScheduler; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; @@ -53,9 +52,9 @@ import com.eu.habbo.messages.incoming.rooms.items.jukebox.*; import com.eu.habbo.messages.incoming.rooms.items.lovelock.LoveLockStartConfirmEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentSpaceCancelEvent; import com.eu.habbo.messages.incoming.rooms.items.rentablespace.RentSpaceEvent; -import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestStateChange; -import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlaylists; import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlaylistChange; +import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestPlaylists; +import com.eu.habbo.messages.incoming.rooms.items.youtube.YoutubeRequestStateChange; import com.eu.habbo.messages.incoming.rooms.pets.*; import com.eu.habbo.messages.incoming.rooms.promotions.BuyRoomPromotionEvent; import com.eu.habbo.messages.incoming.rooms.promotions.RequestPromotionRoomsEvent; @@ -169,7 +168,7 @@ public class PacketManager { if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { if (DEBUG_SHOW_PACKETS) { - LOGGER.debug("[CLIENT][NOT LOGGED IN][{}] => {}", packet.getMessageId(), packet.getMessageBody()); + LOGGER.warn("Client packet {} requires an authenticated session.", packet.getMessageId()); } return; @@ -180,7 +179,7 @@ public class PacketManager { if (handler.getRatelimit() > 0) { if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) { if (PacketManager.DEBUG_SHOW_PACKETS) { - LOGGER.debug("[CLIENT][{}][RATELIMITED] => {}", packet.getMessageId(), packet.getMessageBody()); + LOGGER.warn("Client packet {} was ratelimited.", packet.getMessageId()); } return; @@ -189,12 +188,8 @@ public class PacketManager { } } - if (PacketManager.DEBUG_SHOW_PACKETS) { - LOGGER.debug("[CLIENT][{}] => {}", packet.getMessageId(), packet.getMessageBody()); - } - if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) { - LOGGER.debug("[CLIENT][{}][{}] => {}", client.getHabbo().getHabboInfo().getUsername(), packet.getMessageId(), packet.getMessageBody()); + LOGGER.info("User {} sent packet {} with body {}", client.getHabbo().getHabboInfo().getUsername(), packet.getMessageId(), packet.getMessageBody()); } handler.client = client; @@ -209,10 +204,6 @@ public class PacketManager { if (!handler.isCancelled) { handler.handle(); } - } else { - if (PacketManager.DEBUG_SHOW_PACKETS) { - LOGGER.debug("[CLIENT][UNDEFINED][{}] => {}", packet.getMessageId(), packet.getMessageBody()); - } } } catch (Exception e) { LOGGER.error("Caught exception", e); diff --git a/src/main/java/com/eu/habbo/messages/ServerMessage.java b/src/main/java/com/eu/habbo/messages/ServerMessage.java index e5cf3204..b6e5a840 100644 --- a/src/main/java/com/eu/habbo/messages/ServerMessage.java +++ b/src/main/java/com/eu/habbo/messages/ServerMessage.java @@ -1,10 +1,9 @@ package com.eu.habbo.messages; -import com.eu.habbo.util.HexUtils; +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; @@ -173,13 +172,7 @@ public class ServerMessage implements ReferenceCounted { } public String getBodyString() { - byte[] data = this.get().array(); - - if (data.length == 0) { - return ""; - } - - return HexUtils.pretty(data); + return PacketUtils.formatPacket(this.channelBuffer); } public int getHeader() { diff --git a/src/main/java/com/eu/habbo/networking/Server.java b/src/main/java/com/eu/habbo/networking/Server.java index f59a6d5a..800529c1 100644 --- a/src/main/java/com/eu/habbo/networking/Server.java +++ b/src/main/java/com/eu/habbo/networking/Server.java @@ -8,6 +8,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.FixedRecvByteBufAllocator; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.util.concurrent.DefaultThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,8 +30,10 @@ public abstract class Server { this.host = host; this.port = port; - this.bossGroup = new NioEventLoopGroup(bossGroupThreads); - this.workerGroup = new NioEventLoopGroup(workerGroupThreads); + String threadName = name.replace("Server", "").replace(" ", ""); + + this.bossGroup = new NioEventLoopGroup(bossGroupThreads, new DefaultThreadFactory(threadName + "Boss")); + this.workerGroup = new NioEventLoopGroup(workerGroupThreads, new DefaultThreadFactory(threadName + "Worker")); this.serverBootstrap = new ServerBootstrap(); } @@ -40,8 +43,8 @@ public abstract class Server { this.serverBootstrap.childOption(ChannelOption.TCP_NODELAY, true); this.serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, true); this.serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, true); - this.serverBootstrap.childOption(ChannelOption.SO_RCVBUF, 5120); - this.serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(5120)); + this.serverBootstrap.childOption(ChannelOption.SO_RCVBUF, 4096); + this.serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(4096)); this.serverBootstrap.childOption(ChannelOption.ALLOCATOR, new UnpooledByteBufAllocator(false)); } 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 933eb65a..bbd2f4bf 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/GameServer.java @@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClientManager; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.networking.Server; import com.eu.habbo.networking.gameserver.decoders.*; -import com.eu.habbo.networking.gameserver.encoders.ServerMessageEncoder; +import com.eu.habbo.networking.gameserver.encoders.GameServerMessageEncoder; import com.eu.habbo.networking.gameserver.encoders.GameServerMessageLogger; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; @@ -30,17 +30,23 @@ 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(), - new GameByteFrameDecoder(), - new GameByteDecoder(), - new GameMessageRateLimit(), - new GameMessageHandler() - ); + ch.pipeline().addLast(new GamePolicyDecoder()); + ch.pipeline().addLast(new GameByteFrameDecoder()); + ch.pipeline().addLast(new GameByteDecoder()); + + if (PacketManager.DEBUG_SHOW_PACKETS) { + ch.pipeline().addLast(new GameClientMessageLogger()); + } + + ch.pipeline().addLast(new GameMessageRateLimit()); + ch.pipeline().addLast(new GameMessageHandler()); // Encoders. - ch.pipeline().addLast(new ServerMessageEncoder()); + ch.pipeline().addLast(new GameServerMessageEncoder()); if (PacketManager.DEBUG_SHOW_PACKETS) { ch.pipeline().addLast(new GameServerMessageLogger()); diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java new file mode 100644 index 00000000..8891e5a2 --- /dev/null +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java @@ -0,0 +1,23 @@ +package com.eu.habbo.networking.gameserver.decoders; + +import com.eu.habbo.messages.ClientMessage; +import com.eu.habbo.util.ANSI; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageDecoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +public class GameClientMessageLogger extends MessageToMessageDecoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameClientMessageLogger.class); + + @Override + protected void decode(ChannelHandlerContext ctx, ClientMessage message, List out) { + LOGGER.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d] => %s", message.getMessageId(), message.getMessageBody())); + + out.add(message); + } + +} diff --git a/src/main/java/com/eu/habbo/networking/gameserver/encoders/ServerMessageEncoder.java b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageEncoder.java similarity index 78% rename from src/main/java/com/eu/habbo/networking/gameserver/encoders/ServerMessageEncoder.java rename to src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageEncoder.java index 3baba4ce..a3a59dbd 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/encoders/ServerMessageEncoder.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageEncoder.java @@ -4,9 +4,8 @@ import com.eu.habbo.messages.ServerMessage; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; -import io.netty.util.IllegalReferenceCountException; -public class ServerMessageEncoder extends MessageToByteEncoder { +public class GameServerMessageEncoder extends MessageToByteEncoder { @Override protected void encode(ChannelHandlerContext ctx, ServerMessage message, ByteBuf out) { 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 b6ac3cf3..bcbe5b13 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 @@ -1,6 +1,7 @@ package com.eu.habbo.networking.gameserver.encoders; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageEncoder; import org.slf4j.Logger; @@ -13,15 +14,10 @@ public class GameServerMessageLogger extends MessageToMessageEncoder out) throws Exception { - LOGGER.debug("[SERVER][{}]", message.getHeader()); - - String body = message.getBodyString(); - if (body == null || body.length() == 0) { - LOGGER.debug("\n" + message.getBodyString()); - } + protected void encode(ChannelHandlerContext ctx, ServerMessage message, List out) { + LOGGER.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d] => %s", message.getHeader(), message.getBodyString())); out.add(message.retain()); } -} +} \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/util/ANSI.java b/src/main/java/com/eu/habbo/util/ANSI.java new file mode 100644 index 00000000..4c59761f --- /dev/null +++ b/src/main/java/com/eu/habbo/util/ANSI.java @@ -0,0 +1,16 @@ +package com.eu.habbo.util; + +import ch.qos.logback.core.pattern.color.ANSIConstants; + +public class ANSI { + + public static final String RED = "\u001B[" + ANSIConstants.RED_FG + "m"; + public static final String GREEN = "\u001B[" + ANSIConstants.GREEN_FG + "m"; + public static final String YELLOW = "\u001B[" + ANSIConstants.YELLOW_FG + "m"; + public static final String BLUE = "\u001B[" + ANSIConstants.BLUE_FG + "m"; + public static final String MAGENTA = "\u001B[" + ANSIConstants.MAGENTA_FG + "m"; + public static final String CYAN = "\u001B[" + ANSIConstants.CYAN_FG + "m"; + public static final String WHITE = "\u001B[" + ANSIConstants.WHITE_FG + "m"; + public static final String DEFAULT = "\u001B[" + ANSIConstants.DEFAULT_FG + "m"; + +} diff --git a/src/main/java/com/eu/habbo/util/HexUtils.java b/src/main/java/com/eu/habbo/util/HexUtils.java index 63846653..82ad1990 100644 --- a/src/main/java/com/eu/habbo/util/HexUtils.java +++ b/src/main/java/com/eu/habbo/util/HexUtils.java @@ -1,7 +1,5 @@ package com.eu.habbo.util; -import java.nio.charset.StandardCharsets; - public class HexUtils { private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); @@ -26,32 +24,4 @@ public class HexUtils { return data; } - public static String pretty(byte[] array) { - final int width = 32; - - StringBuilder builder = new StringBuilder(); - - for (int rowOffset = 0; rowOffset < array.length; rowOffset += width) { - builder.append(String.format("%06d: ", rowOffset)); - - for (int index = 0; index < width; index++) { - if (rowOffset + index < array.length) { - builder.append(String.format("%02x ", array[rowOffset + index])); - } else { - builder.append(" "); - } - } - - int asciiWidth = Math.min(width, array.length - rowOffset); - builder.append(" | "); - builder.append(new String(array, rowOffset, asciiWidth, StandardCharsets.UTF_8).replaceAll("\r\n", " ").replaceAll("\n", " ")); - - if (rowOffset + width < array.length) { - builder.append(String.format("%n")); - } - } - - return builder.toString(); - } - } diff --git a/src/main/java/com/eu/habbo/util/PacketUtils.java b/src/main/java/com/eu/habbo/util/PacketUtils.java new file mode 100644 index 00000000..855ca9ae --- /dev/null +++ b/src/main/java/com/eu/habbo/util/PacketUtils.java @@ -0,0 +1,19 @@ +package com.eu.habbo.util; + +import io.netty.buffer.ByteBuf; + +import java.nio.charset.Charset; + +public class PacketUtils { + + public static String formatPacket(ByteBuf buffer) { + String result = buffer.toString(Charset.defaultCharset()); + + for (int i = -1; i < 31; i++) { + result = result.replace(Character.toString((char) i), "[" + i + "]"); + } + + return result; + } + +} From 1bd9db75a6cdb960dffad44dabc59cabb2878497 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 00:22:54 +0200 Subject: [PATCH 04/12] Added logback xml because it was ignored somehow. --- .gitignore | 1 - src/main/resources/logback.xml | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/logback.xml diff --git a/.gitignore b/.gitignore index 54f0682d..94c0cbd9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ target/** TODO.txt packet.pkt plugins/** -src/main/resources/ src/test/ target/ config.ini diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 00000000..8e8ca6b1 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + false + + %d{HH:mm:ss.SSS} [%-14thread] %highlight(%-5level) %cyan(%-36logger{36}) - %msg%n + + + + + + + + + + + + + + + \ No newline at end of file From a7946b4adcce7c496c3298a62da22321d46687e4 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 00:28:25 +0200 Subject: [PATCH 05/12] Replace remainder sout with logger. --- .../core/consolecommands/ConsoleCommand.java | 7 ++-- .../consolecommands/ConsoleInfoCommand.java | 32 +++++++++++-------- .../ConsoleReconnectCameraCommand.java | 6 +++- .../consolecommands/ConsoleTestCommand.java | 6 +++- .../ShowInteractionsCommand.java | 6 +++- .../consolecommands/ShowRCONCommands.java | 6 +++- .../teleport/TeleportActionThree.java | 2 +- 7 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java index 43aa98d0..23604f3e 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java @@ -5,7 +5,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class ConsoleCommand { - private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleCommand.class); private static final THashMap commands = new THashMap<>(); @@ -48,11 +47,11 @@ public abstract class ConsoleCommand { LOGGER.error("Caught exception", e); } } else { - System.out.println("Unknown Console Command " + message[0]); - System.out.println("Commands Available (" + commands.size() + "): "); + LOGGER.info("Unknown Console Command " + message[0]); + LOGGER.info("Commands Available (" + commands.size() + "): "); for (ConsoleCommand c : commands.values()) { - System.out.println(c.key + " - " + c.usage); + LOGGER.info(c.key + " - " + c.usage); } } } diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java index c36f82bf..db7c22bf 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java @@ -2,10 +2,14 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; public class ConsoleInfoCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleInfoCommand.class); + public ConsoleInfoCommand() { super("info", "Show current statistics."); } @@ -18,21 +22,21 @@ public class ConsoleInfoCommand extends ConsoleCommand { long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60); - System.out.println("Emulator version: " + Emulator.version); - System.out.println("Emulator build: " + Emulator.build); + LOGGER.info("Emulator version: " + Emulator.version); + LOGGER.info("Emulator build: " + Emulator.build); - System.out.println(""); + LOGGER.info(""); - System.out.println("Hotel Statistics"); - System.out.println("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount()); - System.out.println("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size()); - System.out.println("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items."); - System.out.println("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items."); - System.out.println(""); - System.out.println("Server Statistics"); - System.out.println("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!")); - System.out.println("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB"); - System.out.println("- CPU Cores: " + Emulator.getRuntime().availableProcessors()); - System.out.println("- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB"); + LOGGER.info("Hotel Statistics"); + LOGGER.info("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount()); + LOGGER.info("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size()); + LOGGER.info("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items."); + LOGGER.info("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items."); + LOGGER.info(""); + LOGGER.info("Server Statistics"); + LOGGER.info("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!")); + LOGGER.info("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB"); + LOGGER.info("- CPU Cores: " + Emulator.getRuntime().availableProcessors()); + LOGGER.info("- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB"); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java index 0520a5e3..587130d1 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java @@ -1,15 +1,19 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.networking.camera.CameraClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConsoleReconnectCameraCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleReconnectCameraCommand.class); + public ConsoleReconnectCameraCommand() { super("camera", "Attempt to reconnect to the camera server."); } @Override public void handle(String[] args) throws Exception { - System.out.println("Connecting to the camera..."); + LOGGER.info("Connecting to the camera..."); CameraClient.attemptReconnect = true; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java index d40fb13e..cd02b90c 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java @@ -3,8 +3,12 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConsoleTestCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleTestCommand.class); + public ConsoleTestCommand() { super("test", "This is just a test."); } @@ -12,7 +16,7 @@ public class ConsoleTestCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { if (Emulator.debugging) { - System.out.println("This is a test command for live debugging."); + LOGGER.info("This is a test command for live debugging."); //AchievementManager.progressAchievement(4, Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"), 30); diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java index 9aa6eee9..e8487a92 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java @@ -1,8 +1,12 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ShowInteractionsCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ShowInteractionsCommand.class); + public ShowInteractionsCommand() { super("interactions", "Show a list of available furniture interactions."); } @@ -10,7 +14,7 @@ public class ShowInteractionsCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) { - System.out.println(interaction); + LOGGER.info(interaction); } } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java index a7df7bf3..821d2f1f 100644 --- a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java +++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java @@ -1,8 +1,12 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ShowRCONCommands extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ShowRCONCommands.class); + public ShowRCONCommands() { super("rconcommands", "Show a list of all RCON commands"); } @@ -10,7 +14,7 @@ public class ShowRCONCommands extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String command : Emulator.getRconServer().getCommands()) { - System.out.println(command); + LOGGER.info(command); } } } 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..8289a1b6 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 @@ -66,7 +66,7 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); //targetRoom.updateHabbo(this.client.getHabbo()); - //System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY()); + //LOGGER.info((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); From 14a1c56877fa73e95af025768a25121cc513e2f4 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 01:27:39 +0200 Subject: [PATCH 06/12] Remove unused packet ids and fix duplicate composer. --- .../eu/habbo/messages/incoming/Incoming.java | 4 --- .../rooms/bots/BotSaveSettingsEvent.java | 4 +-- .../eu/habbo/messages/outgoing/Outgoing.java | 23 +++++----------- .../users/RoomUnitUpdateUsernameComposer.java | 25 ------------------ .../users/RoomUserNameChangedComposer.java | 26 ++++++++++++------- 5 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index ee3b7193..2f2bfc1d 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -35,7 +35,6 @@ public class Incoming { public static final int RoomUserShoutEvent = 2085; public static final int ScratchPetEvent = 3202; public static final int RoomUserWalkEvent = 3320; - public static final int RequestUserTagsEvent = 17; public static final int RequestTagsEvent = 826; public static final int GetMarketplaceConfigEvent = 2597; public static final int RequestHeightmapEvent = 3898; @@ -114,8 +113,6 @@ public class Incoming { public static final int SearchRoomsMyFavoriteEvent = 2578; public static final int TradeStartEvent = 1481; public static final int RequestTargetOfferEvent = 2487; - public static final int ClientActionsMessageEvent = 3457; - public static final int UknownMessageEventSomethingSomething = 1827; public static final int ChangeRelationEvent = 3768; public static final int RoomUserSitEvent = 2235; public static final int RequestCanCreateRoomEvent = 2128; @@ -275,7 +272,6 @@ public class Incoming { public static final int GuardianNoUpdatesWantedEvent = 2501; public static final int GuardianVoteEvent = 3961; public static final int GuardianAcceptRequestEvent = 3365; - public static final int RequestGameConfigurationsEvent = 741; public static final int RequestAchievementConfigurationEvent = -1; public static final int RequestReportUserBullyingEvent = 3786; public static final int ReportBullyEvent = 3060; diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java index a0d13549..aea766c0 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java @@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; -import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitUpdateUsernameComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserNameChangedComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.plugin.events.bots.BotSavedChatEvent; import com.eu.habbo.plugin.events.bots.BotSavedLookEvent; @@ -143,7 +143,7 @@ public class BotSaveSettingsEvent extends MessageHandler { bot.setName(nameEvent.name); bot.needsUpdate(true); - room.sendComposer(new RoomUnitUpdateUsernameComposer(bot.getRoomUnit(), nameEvent.name).compose()); + room.sendComposer(new RoomUserNameChangedComposer(bot.getRoomUnit().getId(), bot.getRoomUnit().getId(), nameEvent.name).compose()); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java index 38cba122..c6e299c0 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/Outgoing.java @@ -138,11 +138,11 @@ public class Outgoing { public final static int WallItemUpdateComposer = 2009; // PRODUCTION-201611291003-338511768 public final static int TradeAcceptedComposer = 2568; // PRODUCTION-201611291003-338511768 public final static int AddWallItemComposer = 2187; // PRODUCTION-201611291003-338511768 - public final static int RoomEntryInfoComposer = 749; // PRODUCTION-201611291003-338511768 + public final static int RoomEntryInfoComposer = -1; // PRODUCTION-201611291003-338511768 public final static int HotelViewDataComposer = 1745; // PRODUCTION-201611291003-338511768 public final static int PresentItemOpenedComposer = 56; // PRODUCTION-201611291003-338511768 public final static int RoomUserRemoveRightsComposer = 84; // PRODUCTION-201611291003-338511768 - public final static int UserBCLimitsComposer = 3828; // PRODUCTION-201611291003-338511768 + public final static int UserBCLimitsComposer = -1; // PRODUCTION-201611291003-338511768 public final static int PetTrainingPanelComposer = 1164; // PRODUCTION-201611291003-338511768 public final static int RoomPaneComposer = 749; // PRODUCTION-201611291003-338511768 public final static int RedeemVoucherErrorComposer = 714; // PRODUCTION-201611291003-338511768 @@ -199,7 +199,6 @@ public class Outgoing { public final static int NewNavigatorCollapsedCategoriesComposer = 1543; // PRODUCTION-201611291003-338511768 public final static int NewNavigatorLiftedRoomsComposer = 3104; // PRODUCTION-201611291003-338511768 public final static int NewNavigatorSavedSearchesComposer = 3984; // PRODUCTION-201611291003-338511768 - public final static int RoomUnitUpdateUsernameComposer = 2182; // PRODUCTION-201611291003-338511768 public final static int PostItDataComposer = 2202; // PRODUCTION-201611291003-338511768 public final static int ModToolReportReceivedAlertComposer = 3635; // PRODUCTION-201611291003-338511768 public final static int ModToolIssueResponseAlertComposer = 3796; // PRODUCTION-201611291003-338511768 @@ -237,7 +236,7 @@ public class Outgoing { public final static int ItemExtraDataComposer = 2547; // PRODUCTION-201611291003-338511768 public final static int PostUpdateMessageComposer = 324; // PRODUCTION-201611291003-338511768 //NotSure Needs Testing - public final static int QuestionInfoComposer = 2665; // PRODUCTION-201611291003-338511768 + public final static int QuestionInfoComposer = -1; // PRODUCTION-201611291003-338511768 public final static int TalentTrackEmailVerifiedComposer = 612; // PRODUCTION-201611291003-338511768 public final static int TalentTrackEmailFailedComposer = 1815; // PRODUCTION-201611291003-338511768 public final static int UnknownAvatarEditorComposer = 3473; // PRODUCTION-201611291003-338511768 @@ -249,8 +248,8 @@ public class Outgoing { public final static int GuildForumAddCommentComposer = 2049; // PRODUCTION-201611291003-338511768 public final static int GuildForumDataComposer = 3011; // PRODUCTION-201611291003-338511768 public final static int GuildForumCommentsComposer = 509; // PRODUCTION-201611291003-338511768 - public final static int UnknownGuildForumComposer6 = 324; // PRODUCTION-201611291003-338511768 - public final static int UnknownGuildForumComposer7 = 2528; // PRODUCTION-201611291003-338511768 + public final static int UnknownGuildForumComposer6 = -1; // PRODUCTION-201611291003-338511768 + public final static int UnknownGuildForumComposer7 = -1; // PRODUCTION-201611291003-338511768 public final static int GuildForumThreadsComposer = 1073; // PRODUCTION-201611291003-338511768 public final static int GuildForumListComposer = 3001; // PRODUCTION-201611291003-338511768 public final static int ThreadUpdateMessageComposer = 2528; @@ -342,11 +341,11 @@ public class Outgoing { public final static int MostUselessErrorAlertComposer = 662; // PRODUCTION-201611291003-338511768 public final static int AchievementsConfigurationComposer = 1689; // PRODUCTION-201611291003-338511768 public final static int PetBreedingResultComposer = 634; // PRODUCTION-201611291003-338511768 - public final static int RoomUserQuestionAnsweredComposer = 2589; // PRODUCTION-201611291003-338511768 + public final static int RoomUserQuestionAnsweredComposer = -1; // PRODUCTION-201611291003-338511768 public final static int PetBreedingStartComposer = 1746; // PRODUCTION-201611291003-338511768 public final static int CustomNotificationComposer = 909; // PRODUCTION-201611291003-338511768 public final static int UpdateStackHeightTileHeightComposer = 2816; // PRODUCTION-201611291003-338511768 - public final static int HotelViewCustomTimerComposer = 3926; // PRODUCTION-201611291003-338511768 + public final static int HotelViewCustomTimerComposer = -1; // PRODUCTION-201611291003-338511768 public final static int MarketplaceItemPostedComposer = 1359; // PRODUCTION-201611291003-338511768 public final static int HabboWayQuizComposer2 = 2927; // PRODUCTION-201611291003-338511768 public final static int GuildFavoriteRoomUserUpdateComposer = 3403; // PRODUCTION-201611291003-338511768 @@ -413,7 +412,6 @@ public class Outgoing { public final static int CraftingComposerFour = 2124; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_100 = 1553; // PRODUCTION-201611291003-338511768 //PetBReedingResult - public final static int UnknownComposer_1031 = 1001; // PRODUCTION-201611291003-338511768 public final static int ConnectionErrorComposer = 1004; // PRODUCTION-201611291003-338511768 public final static int BotForceOpenContextMenuComposer = 296; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1111 = 1551; // PRODUCTION-201611291003-338511768 @@ -421,13 +419,10 @@ public class Outgoing { public final static int UnknownComposer_1165 = 904; // PRODUCTION-201611291003-338511768 public final static int EffectsListAddComposer = 2867; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1188 = 1437; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_1218 = 1730; // PRODUCTION-201611291003-338511768 public final static int SubmitCompetitionRoomComposer = 3841; // PRODUCTION-201611291003-338511768 public final static int GameAchievementsListComposer = 2265; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_1271 = 1660; // PRODUCTION-201611291003-338511768 public final static int OtherTradingDisabledComposer = 1254; // PRODUCTION-201611291003-338511768 public final static int BaseJumpUnloadGameComposer = 1715; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_1322 = 1730; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_137 = 2897; // PRODUCTION-201611291003-338511768 public final static int GameCenterAccountInfoComposer = 2893; // PRODUCTION-201611291003-338511768 public final static int UnknowComposer_1390 = 2270; // PRODUCTION-201611291003-338511768 @@ -435,20 +430,16 @@ public class Outgoing { public final static int UnknowComposer_1427 = 3319; // PRODUCTION-201611291003-338511768 public final static int AdventCalendarDataComposer = 2531; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_152 = 3954; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_1529 = 1730; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1577 = 2641; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_1712 = 1730; // PRODUCTION-201611291003-338511768 public final static int NewYearResolutionCompletedComposer = 740; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1741 = 2246; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1744 = 2873; // PRODUCTION-201611291003-338511768 public final static int AdventCalendarProductComposer = 2551; // PRODUCTION-201611291003-338511768 public final static int ModToolSanctionInfoComposer = 2221; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_1965 = 3292; // PRODUCTION-201611291003-338511768 - public final static int UnknownComposer_2053 = 1660; // PRODUCTION-201611291003-338511768 public final static int GuideSessionPartnerIsPlayingComposer = 448; // PRODUCTION-201611291003-338511768 public final static int BaseJumpLeaveQueueComposer = 1477; // PRODUCTION-201611291003-338511768 public final static int Game2WeeklySmallLeaderboardComposer = 3512; // PRODUCTION-201611291003-338511768 - public final static int CatalogBuyVIPSMSComposer = 3315; // PRODUCTION-201611291003-338511768 public final static int GameCenterGameListComposer = 222; // PRODUCTION-201611291003-338511768 public final static int RoomUsersGuildBadgesComposer = 2402; // PRODUCTION-201611291003-338511768 public final static int UnknownComposer_2563 = 1774; // PRODUCTION-201611291003-338511768 diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java deleted file mode 100644 index c3cde9be..00000000 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitUpdateUsernameComposer.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.eu.habbo.messages.outgoing.rooms.users; - -import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.messages.outgoing.MessageComposer; -import com.eu.habbo.messages.outgoing.Outgoing; - -public class RoomUnitUpdateUsernameComposer extends MessageComposer { - private RoomUnit roomUnit; - private String name; - - public RoomUnitUpdateUsernameComposer(RoomUnit roomUnit, String name) { - this.roomUnit = roomUnit; - this.name = name; - } - - @Override - public ServerMessage compose() { - this.response.init(Outgoing.RoomUnitUpdateUsernameComposer); - this.response.appendInt(this.roomUnit.getId()); - this.response.appendInt(this.roomUnit.getId()); - this.response.appendString(this.name); - return this.response; - } -} diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java index 53c8b5b9..f62b4d2e 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserNameChangedComposer.java @@ -7,25 +7,33 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; public class RoomUserNameChangedComposer extends MessageComposer { - private final Habbo habbo; - private final boolean includePrefix; + + private final int userId; + private final int roomId; + private final String name; public RoomUserNameChangedComposer(Habbo habbo) { - this.habbo = habbo; - this.includePrefix = false; + this(habbo, false); } public RoomUserNameChangedComposer(Habbo habbo, boolean includePrefix) { - this.habbo = habbo; - this.includePrefix = includePrefix; + this.userId = habbo.getHabboInfo().getId(); + this.roomId = habbo.getRoomUnit().getId(); + this.name = (includePrefix ? Room.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getRank().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getRank().getPrefix()) : "") + habbo.getHabboInfo().getUsername(); + } + + public RoomUserNameChangedComposer(int userId, int roomId, String name) { + this.userId = userId; + this.roomId = roomId; + this.name = name; } @Override public ServerMessage compose() { this.response.init(Outgoing.RoomUserNameChangedComposer); - this.response.appendInt(this.habbo.getHabboInfo().getId()); - this.response.appendInt(this.habbo.getRoomUnit().getId()); - this.response.appendString((this.includePrefix ? Room.PREFIX_FORMAT.replace("%color%", this.habbo.getHabboInfo().getRank().getPrefixColor()).replace("%prefix%", this.habbo.getHabboInfo().getRank().getPrefix()) : "") + this.habbo.getHabboInfo().getUsername()); + this.response.appendInt(this.userId); + this.response.appendInt(this.roomId); + this.response.appendString(this.name); return this.response; } } \ No newline at end of file From 5fc6bc4002dc001898080ee5c9ba62b6daa16a0d Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 01:31:50 +0200 Subject: [PATCH 07/12] Add packet names to logger. --- .../com/eu/habbo/messages/PacketManager.java | 7 +++ .../com/eu/habbo/messages/PacketNames.java | 58 +++++++++++++++++++ .../decoders/GameClientMessageLogger.java | 12 +++- .../encoders/GameServerMessageLogger.java | 12 +++- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/PacketNames.java diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index 8360b2bb..54ad2f77 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -85,10 +85,13 @@ public class PacketManager { public static boolean MULTI_THREADED_PACKET_HANDLING = false; private final THashMap> incoming; private final THashMap> callables; + private final PacketNames names; public PacketManager() throws Exception { this.incoming = new THashMap<>(); this.callables = new THashMap<>(); + this.names = new PacketNames(); + this.names.initialize(); this.registerHandshake(); this.registerCatalog(); @@ -115,6 +118,10 @@ public class PacketManager { this.registerGameCenter(); } + public PacketNames getNames() { + return names; + } + @EventHandler public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) { logList.clear(); diff --git a/src/main/java/com/eu/habbo/messages/PacketNames.java b/src/main/java/com/eu/habbo/messages/PacketNames.java new file mode 100644 index 00000000..4fa159ec --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/PacketNames.java @@ -0,0 +1,58 @@ +package com.eu.habbo.messages; + +import com.eu.habbo.messages.incoming.Incoming; +import com.eu.habbo.messages.outgoing.Outgoing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; + +public class PacketNames { + + private static final Logger LOGGER = LoggerFactory.getLogger(PacketNames.class); + + private final HashMap incoming; + private final HashMap outgoing; + + public PacketNames() { + this.incoming = new HashMap<>(); + this.outgoing = new HashMap<>(); + } + + public void initialize() { + PacketNames.getNames(Incoming.class, this.incoming); + PacketNames.getNames(Outgoing.class, this.outgoing); + } + + public String getIncomingName(int key) { + return this.incoming.getOrDefault(key, "Unknown"); + } + + public String getOutgoingName(int key) { + return this.outgoing.getOrDefault(key, "Unknown"); + } + + private static void getNames(Class clazz, HashMap target) { + for (Field field : clazz.getFields()) { + int modifiers = field.getModifiers(); + if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers) && field.getType() == int.class) { + try { + int packetId = field.getInt(null); + if (packetId > 0) { + if (target.containsKey(packetId)) { + LOGGER.warn("Duplicate packet id found {} for {}.", packetId, clazz.getSimpleName()); + continue; + } + + target.put(packetId, field.getName()); + } + } catch (IllegalAccessException e) { + LOGGER.error("Failed to read field integer.", e); + } + } + } + } + +} diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java index 8891e5a2..bf433250 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java @@ -1,6 +1,8 @@ package com.eu.habbo.networking.gameserver.decoders; +import com.eu.habbo.Emulator; import com.eu.habbo.messages.ClientMessage; +import com.eu.habbo.messages.PacketNames; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; @@ -12,10 +14,18 @@ import java.util.List; public class GameClientMessageLogger extends MessageToMessageDecoder { private static final Logger LOGGER = LoggerFactory.getLogger(GameClientMessageLogger.class); + private final PacketNames names; + + public GameClientMessageLogger() { + this.names = Emulator.getGameServer().getPacketManager().getNames(); + } @Override protected void decode(ChannelHandlerContext ctx, ClientMessage message, List out) { - LOGGER.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d] => %s", message.getMessageId(), message.getMessageBody())); + LOGGER.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + message.getMessageId(), + this.names.getIncomingName(message.getMessageId()), + message.getMessageBody())); out.add(message); } 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 bcbe5b13..a21edde9 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 @@ -1,5 +1,7 @@ package com.eu.habbo.networking.gameserver.encoders; +import com.eu.habbo.Emulator; +import com.eu.habbo.messages.PacketNames; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; @@ -12,10 +14,18 @@ import java.util.List; public class GameServerMessageLogger extends MessageToMessageEncoder { private static final Logger LOGGER = LoggerFactory.getLogger(GameServerMessageLogger.class); + private final PacketNames names; + + public GameServerMessageLogger() { + this.names = Emulator.getGameServer().getPacketManager().getNames(); + } @Override protected void encode(ChannelHandlerContext ctx, ServerMessage message, List out) { - LOGGER.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d] => %s", message.getHeader(), message.getBodyString())); + LOGGER.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + message.getHeader(), + this.names.getOutgoingName(message.getHeader()), + message.getBodyString())); out.add(message.retain()); } From fd2293342fae6d41508437a116b0ee21607b9360 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 01:59:28 +0200 Subject: [PATCH 08/12] Add rolling files. --- pom.xml | 12 +++++++ src/main/resources/logback.xml | 64 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/pom.xml b/pom.xml index 35de71dc..d2571ab0 100644 --- a/pom.xml +++ b/pom.xml @@ -160,6 +160,18 @@ 1.18 + + org.codehaus.janino + janino + 3.1.2 + + + + org.codehaus.groovy + groovy-all + 3.0.3 + + joda-time joda-time diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 8e8ca6b1..7597aff6 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -7,6 +7,67 @@ + + logging/debug.txt + + + + e.level == DEBUG + + + DENY + NEUTRAL + + + logging/debug.%d{yyyy-MM-dd}.%i.gz + 50MB + 7 + + + %d{HH:mm:ss.SSS} [%thread] %level %logger - %msg%n + + + + + logging/errors/runtime.txt + + error + + + + java.sql.SQLException.class.isInstance(throwable) + + DENY + + + logging/errors/runtime.%d{yyyy-MM-dd}.%i.gz + 50MB + 7 + + + %d{HH:mm:ss.SSS} [%thread] %level %logger - %msg%n + + + + + logging/errors/sql.txt + + + java.sql.SQLException.class.isInstance(throwable) + + DENY + NEUTRAL + + + logging/errors/sql.%d{yyyy-MM-dd}.%i.gz + 50MB + 7 + + + %d{HH:mm:ss.SSS} [%thread] %level %logger - %msg%n + + + @@ -17,5 +78,8 @@ + + + \ No newline at end of file From b5265a1fd24bf115951110944284292ec647f62d Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 02:01:36 +0200 Subject: [PATCH 09/12] Fix groovy? --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index d2571ab0..d38ccad3 100644 --- a/pom.xml +++ b/pom.xml @@ -170,6 +170,7 @@ org.codehaus.groovy groovy-all 3.0.3 + pom From ca5ca73a9d79291607200d7a5b14e549d3efd5b4 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 02:24:33 +0200 Subject: [PATCH 10/12] Try to improve build size by reducing dependencies used for logging. --- pom.xml | 13 -------- .../util/logback/SqlExceptionFilter.java | 23 +++++++++++++ src/main/resources/logback.xml | 32 ++++++------------- 3 files changed, 32 insertions(+), 36 deletions(-) create mode 100644 src/main/java/com/eu/habbo/util/logback/SqlExceptionFilter.java diff --git a/pom.xml b/pom.xml index d38ccad3..35de71dc 100644 --- a/pom.xml +++ b/pom.xml @@ -160,19 +160,6 @@ 1.18 - - org.codehaus.janino - janino - 3.1.2 - - - - org.codehaus.groovy - groovy-all - 3.0.3 - pom - - joda-time joda-time diff --git a/src/main/java/com/eu/habbo/util/logback/SqlExceptionFilter.java b/src/main/java/com/eu/habbo/util/logback/SqlExceptionFilter.java new file mode 100644 index 00000000..1026ad58 --- /dev/null +++ b/src/main/java/com/eu/habbo/util/logback/SqlExceptionFilter.java @@ -0,0 +1,23 @@ +package com.eu.habbo.util.logback; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.classic.spi.ThrowableProxy; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + +import java.sql.SQLException; + +public class SqlExceptionFilter extends Filter { + + @Override + public FilterReply decide(ILoggingEvent event) { + ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy(); + + if (proxy.getThrowable() instanceof SQLException){ + return FilterReply.ACCEPT; + } + + return FilterReply.DENY; + } + +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 7597aff6..6b298c13 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -9,14 +9,10 @@ logging/debug.txt - - - - e.level == DEBUG - - - DENY - NEUTRAL + + DEBUG + ACCEPT + DENY logging/debug.%d{yyyy-MM-dd}.%i.gz @@ -30,14 +26,10 @@ logging/errors/runtime.txt - - error - - - - java.sql.SQLException.class.isInstance(throwable) - - DENY + + ERROR + ACCEPT + DENY logging/errors/runtime.%d{yyyy-MM-dd}.%i.gz @@ -51,13 +43,7 @@ logging/errors/sql.txt - - - java.sql.SQLException.class.isInstance(throwable) - - DENY - NEUTRAL - + logging/errors/sql.%d{yyyy-MM-dd}.%i.gz 50MB From 2bc4bc34736b3b117c2bd5007f63c8755d83a61b Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 03:56:21 +0200 Subject: [PATCH 11/12] Added stub for old logger so plugins don't break. --- src/main/java/com/eu/habbo/Emulator.java | 10 ++ src/main/java/com/eu/habbo/core/Logging.java | 97 ++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 src/main/java/com/eu/habbo/core/Logging.java diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index e361e1e5..e5ca801e 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -66,6 +66,7 @@ public final class Emulator { private static GameServer gameServer; private static RCONServer rconServer; private static CameraClient cameraClient; + private static Logging logging; private static Database database; private static DatabaseLogger databaseLogger; private static ThreadPooling threading; @@ -100,6 +101,7 @@ public final class Emulator { setBuild(); Emulator.stopped = false; ConsoleCommand.load(); + Emulator.logging = new Logging(); System.out.println(logo); @@ -319,6 +321,14 @@ public final class Emulator { return rconServer; } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public static Logging getLogging() { + return logging; + } + public static ThreadPooling getThreading() { return threading; } diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java new file mode 100644 index 00000000..b1384a42 --- /dev/null +++ b/src/main/java/com/eu/habbo/core/Logging.java @@ -0,0 +1,97 @@ +package com.eu.habbo.core; + +import com.eu.habbo.Emulator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.SQLException; + +public class Logging { + + private static final Logger LOGGER = LoggerFactory.getLogger("LegacyLogger"); + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logStart(Object line) { + LOGGER.info("[LOADING] {}", line); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logShutdownLine(Object line) { + LOGGER.info("[SHUTDOWN] {}", line); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logUserLine(Object line) { + LOGGER.info("[USER] {}", line); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logDebugLine(Object line) { + LOGGER.debug("[DEBUG] {}", line); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logPacketLine(Object line) { + if (Emulator.getConfig().getBoolean("debug.show.packets")) { + LOGGER.debug("[PACKET] {}", line); + } + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logUndefinedPacketLine(Object line) { + if (Emulator.getConfig().getBoolean("debug.show.packets.undefined")) { + LOGGER.debug("[PACKET] [UNDEFINED] {}", line); + } + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logErrorLine(Object line) { + LOGGER.error("[ERROR] {}", line); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logSQLException(SQLException e) { + LOGGER.error("[ERROR] SQLException", e); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void logPacketError(Object e) { + LOGGER.error("[ERROR] PacketError {}", e); + } + + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ + @Deprecated + public void handleException(Exception e) { + LOGGER.error("[ERROR] Exception", e); + } + +} From 401af627ffa328b7e9a38aee02260bf9e33dae22 Mon Sep 17 00:00:00 2001 From: Mike <76-Mike@users.noreply.git.krews.org> Date: Tue, 5 May 2020 04:00:02 +0200 Subject: [PATCH 12/12] Fix exception spam on busy hotels. --- .../networking/gameserver/decoders/GameMessageHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 143b6c61..a0ba3112 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 @@ -11,6 +11,8 @@ import io.netty.handler.codec.TooLongFrameException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; + @ChannelHandler.Sharable public class GameMessageHandler extends ChannelInboundHandlerAdapter { private static final Logger LOGGER = LoggerFactory.getLogger(GameMessageHandler.class); @@ -53,6 +55,11 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + if (cause instanceof IOException) { + ctx.channel().close(); + return; + } + if (cause instanceof TooLongFrameException) { LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); } else {