diff --git a/Emulator/.gitignore b/.gitignore similarity index 88% rename from Emulator/.gitignore rename to .gitignore index 7d36551..94c0cbd 100644 --- a/Emulator/.gitignore +++ b/.gitignore @@ -5,10 +5,12 @@ compiled-builds/ target/** TODO.txt packet.pkt +plugins/** src/test/ target/ config.ini *.txt +*.jar *.log *.zip .DS_Store diff --git a/Emulator/.gitlab-ci.yml b/Emulator/.gitlab-ci.yml deleted file mode 100644 index e1d0de3..0000000 --- a/Emulator/.gitlab-ci.yml +++ /dev/null @@ -1,18 +0,0 @@ -image: maven:latest - -stages: - - build - -build: - stage: build - script: - - mvn package - only: - changes: - - src/**/* - - pom.xml - artifacts: - expire_in: 2 weeks - paths: - - target/Habbo-*.jar - diff --git a/Emulator/.gitmodules b/Emulator/.gitmodules deleted file mode 100644 index efe4ac3..0000000 --- a/Emulator/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "morningstar-default-database"] - path = morningstar-default-database - url = https://git.krews.org/morningstar/morningstar-default-database diff --git a/Emulator/.idea/.gitignore b/Emulator/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Emulator/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Emulator/.idea/compiler.xml b/Emulator/.idea/compiler.xml new file mode 100644 index 0000000..3376806 --- /dev/null +++ b/Emulator/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Emulator/.idea/encodings.xml b/Emulator/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/Emulator/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Emulator/.idea/jarRepositories.xml b/Emulator/.idea/jarRepositories.xml new file mode 100644 index 0000000..27bf039 --- /dev/null +++ b/Emulator/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Emulator/.idea/misc.xml b/Emulator/.idea/misc.xml new file mode 100644 index 0000000..749dacb --- /dev/null +++ b/Emulator/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/Emulator/Dockerfile b/Emulator/Dockerfile deleted file mode 100644 index e045ce4..0000000 --- a/Emulator/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM maven:latest AS builder - -# Copy the Emulator sources to the container -COPY . . -# Package it -RUN mvn package && mv /target/Habbo*-with-dependencies.jar /target/Habbo.jar - -# Use Java 8 for running -FROM java:8 AS runner - -# Copy the generated source -COPY --from=builder /target/Habbo.jar / - -# Save the script to wait for the database, among running the Arcturus Emulator -RUN echo "#!/bin/bash \n java -Dfile.encoding=UTF-8 -jar /Habbo.jar" > /entrypoint.sh -RUN chmod +x /entrypoint.sh - -# Run the Emulator with Java -ENTRYPOINT ["/entrypoint.sh"] diff --git a/Emulator/LICENSE b/Emulator/LICENSE deleted file mode 100644 index 418dc9a..0000000 --- a/Emulator/LICENSE +++ /dev/null @@ -1,165 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file diff --git a/Emulator/featurelist.md b/Emulator/featurelist.md deleted file mode 100644 index 7f49499..0000000 --- a/Emulator/featurelist.md +++ /dev/null @@ -1,208 +0,0 @@ - - -The following file contains the current feature list for Arcturus Morningstar as of the 4.x Beta Branch. -We hope this file will provide an easy place to find functions in Arcturus Morningstar for new developers, as well as give people the chance to see exactly what Arcturus Morningstar can do! - -If you wish to contribute to this list, features are laid out in the following format: - - - -## ✍️ Example Header: - -##### Example Feature Header- ✔️ (completed) ⭕ (incomplete/ not implemented) - -> [`ExampleLinkToRelatedClasses`](https://google.com) -> -> ###### Example Sub Feature Header - ✔️ -> -> > [`ExampleLinkToRelatedSubClasses`](https://google.com) - - - - - -## 🖥️ Connection / User: - -##### Login via SSO Ticket ✔️ - -> [`SecureLoginEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java) -> [`HabboManager.loadHabbo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L104) - -##### Support RSA Encryption ✔️ - -> [`HabboRSACrypto`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/crypto/HabboRSACrypto.java) -> [`HabboRC4`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/crypto/HabboRC4.java) -> [`HabboDiffieHellman`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java) -> [`CompleteDiffieHandshakeEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/handshake/CompleteDiffieHandshakeEvent.java) -> [`InitDiffieHandshakeEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/handshake/InitDiffieHandshakeEvent.java) - - - -## 🧸 RCON: - -##### RCON ✔️ - -> [`RCONMessage`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java) -> -> ###### RCON Messages - ✔️ -> -> > [`AlertUser`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/AlertUser.java)) -> > [`ChangeRoomOwner`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/ChangeRoomOwner.java) -> > [`CreateModToolTicket`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/CreateModToolTicket.java) -> > [`DisconnectUser`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/DisconnectUser.java) -> > [`ExecuteCommand`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java) -> > [`ForwardUser`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/ForwardUser.java) -> > // todo finish this - -##### - -## 💠 Subscriptions: - -###### Subscriptions Manager ✔️ - -> > [`Subscription`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java) -> > [`SubscriptionManager`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java) -> > [`SubscriptionScheduler`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java) -> > [`UserSubscriptionCreatedEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/plugin/events/users/subscriptions/UserSubscriptionCreatedEvent.java) -> > [`UserSubscriptionExpiredEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/plugin/events/users/subscriptions/UserSubscriptionExpiredEvent.java) -> > [`UserSubscriptionExtendedEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/master/src/main/java/com/eu/habbo/messages/rcon/RCONMessage.java) -> > -> > ##### Habbo Club - ✔️ -> > -> > > [`SubscriptionHabboClub`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java) -> > > [`RequestUserClubEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserClubEvent.java) -> > > [`RequestClubDataEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/catalog/RequestClubDataEvent.java) -> > > [`ClubDataComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubDataComposer.java) -> > > [`HabboStats.hasActiveClub()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java#L555) -> > > -> > > ###### HC Catalogue - ✔️ -> > > -> > > > [`ClubBuyLayout`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubBuyLayout.java) -> > > > [`ClubOffer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/ClubOffer.java) -> > > > [`ClubGiftsLayout`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ClubGiftsLayout.java) -> > > > [`ClubGiftsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubGiftsComposer.java) -> > > > [`ClubCenterDataComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/catalog/ClubCenterDataComposer.java) -> > > > [`ClubGiftReceivedComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/users/ClubGiftReceivedComposer.java) -> > > -> > > ###### HC Payday - ✔️ -> > > -> > > > [`SecureLoginEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java#L202) -> > > > [`SubscriptionScheduler`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java) -> > > > [`SubscriptionHabboClub.calculatePayDay()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java#L184) -> > > > [`SubscriptionHabboClub.executePayDay()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java#L257) -> > > > [`SubscriptionHabboClub.processUnclaimed()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java#L316) -> > > > [`SubscriptionHabboClub.claimPayDay()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java#L368) -> > > > [`SubscriptionHabboClub.progressAchievement()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java#L419) -> > > -> > > ###### HC Checks on clothing - ✔️ -> > > -> > > > [`ClothingValidationManager`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java) -> > > > [`ClothingValidationManager.validateLook()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java#L61) -> > > -> > > ###### HC dances - ✔️ -> > > -> > > > [`RoomUserDanceEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserDanceEvent.java) -> > > > [`RoomUserDanceComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserDanceComposer.java) -> > > > [`RoomUnit.getDanceType()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java#L456) -> > > > [`RoomUnit.setDanceType()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java#L460) -> > -> > Builders Club - ⭕ -> > -> > > [`SubscriptionScheduler`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java) -> > > [`BuildersClubExpiredComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/unknown/BuildersClubExpiredComposer.java) -> > > -> > > ###### Builders Club Catalogue - ⭕ -> > > -> > > > [`BuildersClubAddonsLayout`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java) -> > > > [`BuildersClubLoyaltyLayout`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java)) -> > > > [`BuildersClubFrontPageLayout`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubFrontPageLayout.java) -> > -> > - - - -## 🤹 Entities: - -##### Habbo ✔️ - -> [`Habbo`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java) -> [`Habbo.getClient()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L110) -> [`Habbo.isOnline()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L64) -> [`Habbo.getHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L90) -> [`Habbo.getHabboStats()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L94) -> [`Habbo.getRoomUnit()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L102) -> [`HabboManager`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java) -> [`HabboManager.getOfflineHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L47) -> [`HabboManager.getCloneAccounts()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L203) -> [`HabboManager.setRank()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L243) -> [`HabboInfo`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java) - -> ###### Clothing - ✔️ -> -> -> > [`UserClothesComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/users/UserClothesComposer.java) -> > [`HabboInventory.getWardrobeComponent()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java#L67) -> > [`HabboInventory.setWardrobeComponent()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java#L71) -> -> ###### Inventory - ✔️ -> -> -> > [`HabboInventory`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java) -> > [`Habbo.getInventory()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L98) -> > [`ItemsComponent.addItem()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L67) -> > [`ItemsComponent.addItems()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L82) -> > [`ItemsComponent.getHabboItem()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L99) -> > [`ItemsComponent.getAndRemoveHabboItem()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L103) -> > [`ItemsComponent.removeHabboItem()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L126) -> > [`ItemsComponent.getItemsAsValueCollection()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java#L141) -> > [`InventoryItemsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java#L265) -> > [`InventoryBotsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryBotsComposer.java) -> > [`InventoryPetsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryPetsComposer.java) -> > [`InventoryAchievementsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryAchievementsComposer.java) -> > [`InventoryRefreshComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryRefreshComposer.java) -> > [`InventoryItemsAddedEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemsAddedEvent.java) -> > [`InventoryItemEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java) -> -> ###### Motto - ✔️ -> -> -> > [`HabboInfo.setMotto()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java#L269) -> > [`HabboInfo.getMotto()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java#L265) -> -> ###### Badges - ✔️ -> -> -> > [`BadgesComponent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java) -> > [`BadgesComponent.loadBadges()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L28) -> > [`BadgesComponent.getBadgesOfflineHabbo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L75) -> > [`BadgesComponent.createBadge()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L90) -> > [`BadgesComponent.deleteBadge()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L113) -> > [`BadgesComponent.getWearingBadges()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L123) -> > [`BadgesComponent.hasBadge()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L147) -> > [`BadgesComponent.getBadge()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L151) -> > [`BadgesComponent.removeBadge()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java#L167) -> -> ##### Load Currency and Seasonal Currency - ✔️ -> -> > [`RequestUserCreditsEvent`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserCreditsEvent.java) -> > [`UserCurrencyComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java) -> > [`UserCreditsComposer`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/messages/outgoing/users/UserCreditsComposer.java) -> > [`Habbo.getHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L90) - -> Save/Load Achievements -> -> Save/Load Friends -> -> Save/Load Own Rooms -> -> Save/Load Guilds -> -> Save/Load Currencies -> -> Save/Load Inventory -> -> Save/Load Friendships - Love/Hate/Like - -​ - -- diff --git a/Emulator/pom.xml b/Emulator/pom.xml index 276a08d..cf63987 100644 --- a/Emulator/pom.xml +++ b/Emulator/pom.xml @@ -32,17 +32,17 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.8.1 - 16 - 16 + 1.8 + 1.8 org.apache.maven.plugins maven-assembly-plugin - 3.6.0 + 3.3.0 jar-with-dependencies @@ -67,11 +67,9 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + 3.2.0 - - -Xdoclint:none - + -Xdoclint:none public @@ -94,28 +92,21 @@ io.netty netty-all - 4.1.106.Final + 4.1.49.Final com.google.code.gson gson - 2.10.1 + 2.8.6 - - - com.mysql - mysql-connector-j - 8.3.0 + mysql + mysql-connector-java + 8.0.22 runtime @@ -131,36 +122,14 @@ com.zaxxer HikariCP - 5.1.0 + 3.4.3 compile - - - org.projectlombok - lombok - 1.18.30 - provided - - - - - org.slf4j - jcl-over-slf4j - 2.0.11 - runtime - - - - org.slf4j - slf4j-api - 2.0.11 - - org.apache.commons commons-lang3 - 3.14.0 + 3.10 compile @@ -174,27 +143,27 @@ org.jsoup jsoup - 1.17.2 + 1.13.1 compile ch.qos.logback logback-classic - 1.4.7 + 1.2.3 compile org.fusesource.jansi jansi - 2.4.1 + 1.18 joda-time joda-time - 2.12.6 + 2.10.6 \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/Emulator.java b/Emulator/src/main/java/com/eu/habbo/Emulator.java index 739b361..0968e22 100644 --- a/Emulator/src/main/java/com/eu/habbo/Emulator.java +++ b/Emulator/src/main/java/com/eu/habbo/Emulator.java @@ -17,8 +17,6 @@ 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 io.netty.util.AttributeKey; -import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,16 +26,15 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ThreadLocalRandom; -import java.security.SecureRandom; import java.util.regex.Matcher; import java.util.regex.Pattern; -@Slf4j public final class Emulator { + private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); private static final String OS_NAME = (System.getProperty("os.name") != null ? System.getProperty("os.name") : "Unknown"); private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown"); - private static final SecureRandom secureRandom = new SecureRandom(); + public final static int MAJOR = 3; public final static int MINOR = 6; public final static int BUILD = 0; @@ -52,11 +49,9 @@ public final class Emulator { "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" + "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" + "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" + - " Extended version"; - + "Still Rocking in 2024.\n"; public static String build = ""; - public static String debuglevel = ""; public static boolean isReady = false; public static boolean isShuttingDown = false; public static boolean stopped = false; @@ -76,7 +71,6 @@ public final class Emulator { private static GameEnvironment gameEnvironment; private static PluginManager pluginManager; private static BadgeImager badgeImager; - public static final AttributeKey WS_IP = AttributeKey.valueOf("WS_IP"); static { Thread hook = new Thread(new Runnable() { @@ -88,6 +82,13 @@ public final class Emulator { Runtime.getRuntime().addShutdownHook(hook); } + public static void promptEnterKey(){ + System.out.println("\n"); + System.out.println("Press \"ENTER\" if you agree to the terms stated above..."); + Scanner scanner = new Scanner(System.in); + scanner.nextLine(); + } + public static void main(String[] args) throws Exception { try { // Check if running on Windows and not in IntelliJ. @@ -109,8 +110,18 @@ public final class Emulator { System.out.println(logo); - log.info("Version: {}", version); - log.info("Build: {}", build); + // Checks if this is a BETA build before allowing them to continue. + if (PREVIEW.toLowerCase().contains("beta")) { + System.out.println("Warning, this is a beta build, this means that there may be unintended consequences so make sure you take regular backups while using this build. If you notice any issues you should make an issue on the Krews Git."); + promptEnterKey(); + } + System.out.println(""); + LOGGER.warn("Arcturus Morningstar 3.x is no longer accepting merge requests. Please target MS4 branches if you wish to contribute."); + LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community, "); + System.out.println(""); + LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral."); + LOGGER.info("Version: {}", version); + LOGGER.info("Build: {}", build); long startTime = System.nanoTime(); @@ -143,22 +154,16 @@ public final class Emulator { Emulator.rconServer.connect(); Emulator.badgeImager = new BadgeImager(); - log.info("Arcturus Morningstar has successfully loaded."); - log.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2); - log.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024)); + LOGGER.info("Arcturus Morningstar has successfully 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"); - Emulator.debuglevel = Emulator.getConfig().getValue("debug.level", "DEBUG"); - /* Debug level can be : INFO WARN DEBUG TRACE*/ if (debugging) { ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.DEBUG); - log.debug("Debugging enabled."); - Level logLevel = Level.toLevel(Emulator.debuglevel); - root.setLevel(logLevel); - log.info("Debugging enabled."); - log.info("The loaded debug mode is {}", Emulator.debuglevel); + LOGGER.debug("Debugging enabled."); } Emulator.getPluginManager().fireEvent(new EmulatorLoadedEvent()); @@ -166,7 +171,7 @@ public final class Emulator { Emulator.timeStarted = getIntUnixTimestamp(); if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) { - log.warn("Emulator settings runtime.threads ({}) can be increased to ({}) 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); } @@ -189,7 +194,7 @@ public final class Emulator { System.out.println("Waiting for command: "); } catch (Exception e) { if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) { - log.error("Error while reading command", e); + LOGGER.error("Error while reading command", e); } } } @@ -231,7 +236,7 @@ public final class Emulator { Emulator.isShuttingDown = true; Emulator.isReady = false; - log.info("Stopping Arcturus Morningstar {}", version); + LOGGER.info("Stopping Arcturus Morningstar {}", version); try { if (Emulator.getPluginManager() != null) @@ -282,7 +287,7 @@ public final class Emulator { } catch (Exception e) { } - log.info("Stopped Arcturus Morningstar {}", version); + LOGGER.info("Stopped Arcturus Morningstar {}", version); if (Emulator.database != null) { Emulator.getDatabase().dispose(); @@ -332,6 +337,9 @@ 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; @@ -352,10 +360,6 @@ public final class Emulator { public static Random getRandom() { return ThreadLocalRandom.current(); } - - public static SecureRandom getRandomDice() { - return secureRandom; - } public static BadgeImager getBadgeImager() { return badgeImager; @@ -456,7 +460,7 @@ public final class Emulator { try { res = format.parse(date); } catch (Exception e) { - log.error("Error parsing date", e); + LOGGER.error("Error parsing date", e); } return res; } diff --git a/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java b/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java index 04ee5f4..e9e2f12 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java +++ b/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java @@ -7,7 +7,8 @@ import com.eu.habbo.messages.incoming.friends.SearchUserEvent; import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.eu.habbo.threading.runnables.AchievementUpdater; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,15 +16,17 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Map; -@Slf4j public class CleanerThread implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(CleanerThread.class); + 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; @@ -32,6 +35,7 @@ public class CleanerThread implements Runnable { 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(); @@ -77,6 +81,11 @@ public class CleanerThread implements Runnable { LAST_INACTIVE_TOURS_CLEARED = time; } + if (time - LAST_ERROR_LOGS_SAVED > SAVE_ERROR_LOGS) { + Emulator.getDatabaseLogger().save(); + LAST_ERROR_LOGS_SAVED = time; + } + if (time - LAST_CALLBACK > CALLBACK_TIME) { // Emulator.getThreading().run(new HTTPPostStatus()); LAST_CALLBACK = time; @@ -119,10 +128,10 @@ public class CleanerThread implements Runnable { statement.execute("DELETE FROM users_effects WHERE total <= 0"); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } - log.info("Database -> Cleaned!"); + LOGGER.info("Database -> Cleaned!"); } public void refillDailyRespects() { @@ -131,7 +140,7 @@ public class CleanerThread implements Runnable { statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets")); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (Emulator.isReady) { @@ -153,7 +162,7 @@ public class CleanerThread implements Runnable { habbo.clearCaches(); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/CommandLog.java b/Emulator/src/main/java/com/eu/habbo/core/CommandLog.java index a0039a5..1dfb284 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/CommandLog.java +++ b/Emulator/src/main/java/com/eu/habbo/core/CommandLog.java @@ -14,13 +14,13 @@ public class CommandLog implements DatabaseLoggable { private final int timestamp = Emulator.getIntUnixTimestamp(); private final Command command; private final String params; - private final boolean success; + private final boolean succes; - public CommandLog(int userId, Command command, String params, boolean success) { + public CommandLog(int userId, Command command, String params, boolean succes) { this.userId = userId; this.command = command; this.params = params; - this.success = success; + this.succes = succes; } @Override @@ -34,7 +34,7 @@ public class CommandLog implements DatabaseLoggable { statement.setInt(2, this.timestamp); statement.setString(3, this.command.getClass().getSimpleName()); statement.setString(4, this.params); - statement.setString(5, this.success ? "yes" : "no"); + statement.setString(5, this.succes ? "yes" : "no"); statement.addBatch(); } diff --git a/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java index e583ea0..19b442f 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java +++ b/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java @@ -3,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -13,9 +14,10 @@ import java.sql.*; import java.util.Map; import java.util.Properties; -@Slf4j public class ConfigurationManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class); + private final Properties properties; private final String configurationPath; public boolean loaded = false; @@ -49,7 +51,7 @@ public class ConfigurationManager { this.properties.load(input); } catch (IOException ex) { - log.error("Failed to load config file.", ex); + LOGGER.error("Failed to load config file.", ex); ex.printStackTrace(); } finally { if (input != null) { @@ -90,7 +92,7 @@ public class ConfigurationManager { String envValue = System.getenv(entry.getValue()); if (envValue == null || envValue.length() == 0) { - log.info("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); } @@ -102,7 +104,7 @@ public class ConfigurationManager { } this.isLoading = false; - log.info("Configuration Manager -> Loaded!"); + LOGGER.info("Configuration Manager -> Loaded!"); if (Emulator.getPluginManager() != null) { Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent()); @@ -110,7 +112,7 @@ public class ConfigurationManager { } public void loadFromDatabase() { - log.info("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()) { @@ -122,10 +124,10 @@ public class ConfigurationManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } - log.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void saveToDatabase() { @@ -136,7 +138,7 @@ public class ConfigurationManager { statement.executeUpdate(); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -151,7 +153,7 @@ public class ConfigurationManager { return defaultValue; if (!this.properties.containsKey(key)) { - log.error("Config key not found {}", key); + LOGGER.error("Config key not found {}", key); } return this.properties.getProperty(key, defaultValue); } @@ -167,7 +169,7 @@ public class ConfigurationManager { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - log.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key)); + LOGGER.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key)); } return defaultValue; } @@ -183,7 +185,7 @@ public class ConfigurationManager { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - log.error("Failed to parse key {} with value '{}' to type integer.", key, this.getValue(key)); + LOGGER.error("Failed to parse key {} with value '{}' to type integer.", key, this.getValue(key)); } return defaultValue; } @@ -199,7 +201,7 @@ public class ConfigurationManager { try { return Double.parseDouble(this.getValue(key, defaultValue.toString())); } catch (Exception e) { - log.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key)); + LOGGER.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key)); } return defaultValue; @@ -218,7 +220,7 @@ public class ConfigurationManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.update(key, value); diff --git a/Emulator/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/Emulator/src/main/java/com/eu/habbo/core/CreditsScheduler.java index 4265226..db5e74f 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/CreditsScheduler.java +++ b/Emulator/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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Map; -@Slf4j 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; public static double HC_MODIFIER; @@ -51,7 +55,7 @@ public class CreditsScheduler extends Scheduler { habbo.giveCredits((int)(habbo.getHabboInfo().getRank().getCreditsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/DatabaseLogger.java b/Emulator/src/main/java/com/eu/habbo/core/DatabaseLogger.java index ddb4a97..2f8806a 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/DatabaseLogger.java +++ b/Emulator/src/main/java/com/eu/habbo/core/DatabaseLogger.java @@ -1,25 +1,46 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +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; -@Slf4j public class DatabaseLogger { - public void store(final DatabaseLoggable loggable) { - Emulator.getThreading().run(() -> { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { + 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) { - log.error("Exception caught while saving loggable to database.", e); + } - }); + } catch (SQLException e) { + LOGGER.error("Exception caught while saving loggables to database.", e); + } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/ErrorLog.java b/Emulator/src/main/java/com/eu/habbo/core/ErrorLog.java index 31b4fd8..f0d6207 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/ErrorLog.java +++ b/Emulator/src/main/java/com/eu/habbo/core/ErrorLog.java @@ -1,18 +1,23 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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 final String version; public final String buildHash; + public final int timeStamp; public final String type; public final String stackTrace; @@ -33,7 +38,7 @@ public class ErrorLog implements DatabaseLoggable { pw.close(); sw.close(); } catch (IOException e1) { - log.error("Exception caught", e1); + LOGGER.error("Exception caught", e1); } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/Emulator/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java index add7148..58350a9 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java +++ b/Emulator/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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Map; -@Slf4j 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; @@ -64,7 +68,7 @@ public class GotwPointsScheduler extends Scheduler { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/Logging.java b/Emulator/src/main/java/com/eu/habbo/core/Logging.java index b64087c..b1384a4 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/Logging.java +++ b/Emulator/src/main/java/com/eu/habbo/core/Logging.java @@ -1,63 +1,97 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.SQLException; -@Slf4j 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) { - log.info("[LOADING] {}", line); + LOGGER.info("[LOADING] {}", line); } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void logShutdownLine(Object line) { - log.info("[SHUTDOWN] {}", line); + LOGGER.info("[SHUTDOWN] {}", line); } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void logUserLine(Object line) { - log.info("[USER] {}", line); + LOGGER.info("[USER] {}", line); } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void logDebugLine(Object line) { - log.debug("[DEBUG] {}", 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")) { - log.debug("[PACKET] {}", line); + 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")) { - log.debug("[PACKET] [UNDEFINED] {}", line); + LOGGER.debug("[PACKET] [UNDEFINED] {}", line); } } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void logErrorLine(Object line) { - log.error("[ERROR] {}", line); + LOGGER.error("[ERROR] {}", line); } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void logSQLException(SQLException e) { - log.error("[ERROR] 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) { - log.error("[ERROR] PacketError {}", e); + LOGGER.error("[ERROR] PacketError {}", e); } + /** + * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log. + */ @Deprecated public void handleException(Exception e) { - log.error("[ERROR] Exception", e); + LOGGER.error("[ERROR] Exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/PixelScheduler.java b/Emulator/src/main/java/com/eu/habbo/core/PixelScheduler.java index a75589a..2b0bddd 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/PixelScheduler.java +++ b/Emulator/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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Map; -@Slf4j 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; public static double HC_MODIFIER; @@ -48,7 +52,7 @@ public class PixelScheduler extends Scheduler { habbo.givePixels((int)(habbo.getHabboInfo().getRank().getPixelsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/PointsScheduler.java b/Emulator/src/main/java/com/eu/habbo/core/PointsScheduler.java index 04a875d..ca863cb 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/PointsScheduler.java +++ b/Emulator/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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Map; -@Slf4j 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; public static double HC_MODIFIER; @@ -51,7 +55,7 @@ public class PointsScheduler extends Scheduler { habbo.givePoints((int)(habbo.getHabboInfo().getRank().getDiamondsTimerAmount() * (habbo.getHabboStats().hasActiveClub() ? HC_MODIFIER : 1.0))); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/TextsManager.java b/Emulator/src/main/java/com/eu/habbo/core/TextsManager.java index acb5397..4b0bf66 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/TextsManager.java +++ b/Emulator/src/main/java/com/eu/habbo/core/TextsManager.java @@ -1,14 +1,16 @@ package com.eu.habbo.core; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.Properties; -@Slf4j public class TextsManager { + private static final Logger LOGGER = LoggerFactory.getLogger(TextsManager.class); + private final Properties texts; public TextsManager() { @@ -19,7 +21,7 @@ public class TextsManager { try { this.reload(); - log.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } catch (Exception e) { e.printStackTrace(); } @@ -35,7 +37,7 @@ public class TextsManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -45,7 +47,7 @@ public class TextsManager { public String getValue(String key, String defaultValue) { if (!this.texts.containsKey(key)) { - log.error("Text key not found: {}", key); + LOGGER.error("Text key not found: {}", key); } return this.texts.getProperty(key, defaultValue); } @@ -58,7 +60,7 @@ public class TextsManager { try { return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true")); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return defaultValue; } @@ -71,7 +73,7 @@ public class TextsManager { try { return Integer.parseInt(this.getValue(key, defaultValue.toString())); } catch (NumberFormatException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return defaultValue; } @@ -89,7 +91,7 @@ public class TextsManager { statement.setString(2, value); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.update(key, value); diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java index c4f50ad..ea10362 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java @@ -1,10 +1,11 @@ package com.eu.habbo.core.consolecommands; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public abstract class ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleCommand.class); private static final THashMap commands = new THashMap<>(); public final String key; @@ -44,19 +45,21 @@ public abstract class ConsoleCommand { command.handle(message); return true; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { - log.info("Unknown Console Command " + message[0]); - log.info("Commands Available (" + commands.size() + "): "); + LOGGER.info("Unknown Console Command " + message[0]); + LOGGER.info("Commands Available (" + commands.size() + "): "); for (ConsoleCommand c : commands.values()) { - log.info(c.key + " - " + c.usage); + LOGGER.info(c.key + " - " + c.usage); } } } return false; } + public abstract void handle(String[] args) throws Exception; + } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java index 3038210..db7c22b 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java @@ -2,12 +2,14 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogManager; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.TimeUnit; -@Slf4j public class ConsoleInfoCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleInfoCommand.class); + public ConsoleInfoCommand() { super("info", "Show current statistics."); } @@ -20,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); - log.info("Emulator version: " + Emulator.version); - log.info("Emulator build: " + Emulator.build); + LOGGER.info("Emulator version: " + Emulator.version); + LOGGER.info("Emulator build: " + Emulator.build); - log.info(""); + LOGGER.info(""); - log.info("Hotel Statistics"); - log.info("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount()); - log.info("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size()); - log.info("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items."); - log.info("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items."); - log.info(""); - log.info("Server Statistics"); - log.info("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!")); - log.info("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB"); - log.info("- CPU Cores: " + Emulator.getRuntime().availableProcessors()); - log.info("- 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/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java index 40f1f9b..587130d 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java @@ -1,17 +1,19 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.networking.camera.CameraClient; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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 { - log.info("Connecting to the camera..."); + LOGGER.info("Connecting to the camera..."); CameraClient.attemptReconnect = true; } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java index 3f69e05..cd02b90 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java @@ -1,11 +1,14 @@ package com.eu.habbo.core.consolecommands; + import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class ConsoleTestCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleTestCommand.class); + public ConsoleTestCommand() { super("test", "This is just a test."); } @@ -13,7 +16,9 @@ public class ConsoleTestCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { if (Emulator.debugging) { - log.info("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); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(1); habbo.getHabboInfo().getMachineID(); diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java index 1d93112..e8487a9 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java @@ -1,11 +1,12 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; - -@Slf4j 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."); } @@ -13,7 +14,7 @@ public class ShowInteractionsCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) { - log.info(interaction); + LOGGER.info(interaction); } } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java index 4da7f13..821d2f1 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java @@ -1,10 +1,11 @@ package com.eu.habbo.core.consolecommands; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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"); @@ -13,7 +14,7 @@ public class ShowRCONCommands extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { for (String command : Emulator.getRconServer().getCommands()) { - log.info(command); + LOGGER.info(command); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java index ab53bf8..64378af 100644 --- a/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java @@ -1,10 +1,11 @@ package com.eu.habbo.core.consolecommands; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class ThankyouArcturusCommand extends ConsoleCommand { + private static final Logger LOGGER = LoggerFactory.getLogger(ThankyouArcturusCommand.class); public ThankyouArcturusCommand() { super("thankyou", "A thankyou message."); @@ -12,31 +13,31 @@ public class ThankyouArcturusCommand extends ConsoleCommand { @Override public void handle(String[] args) throws Exception { - log.info("Arcturus Morningstar is an opensource community fork of Arcturus Emulator by TheGeneral"); - log.info("Thankyou to the following people who have helped with it's development:"); - log.info("TheGeneral - For Creating Arcturus."); - log.info("Capheus - Decompilation"); - log.info("Beny - Lead Developer"); - log.info("Alejandro - Lead Developer"); - log.info("Harmonic - Developer"); - log.info("ArpyAge - Developer"); - log.info("Mike - Developer"); - log.info("Skeletor - Developer"); - log.info("zGrav - Developer"); - log.info("Swirny - Developer"); - log.info("Quadral - Developer"); - log.info("Dome - Developer"); - log.info("Necmi - Developer"); - log.info("Oliver - Support"); - log.info("Rasmus - Support"); - log.info("Layne - Support"); - log.info("Bill - Support"); - log.info("Harmony - Support"); - log.info("Ridge - Catalogue"); - log.info("Tenshie - Catalogue"); - log.info("Wulles - Catalogue"); - log.info("Gizmo - Catalogue"); - log.info("TheJava - Motivation"); - log.info("The Entire Krews.org Community."); + LOGGER.info("Arcturus Morningstar is an opensource community fork of Arcturus Emulator by TheGeneral"); + LOGGER.info("Thankyou to the following people who have helped with it's development:"); + LOGGER.info("TheGeneral - For Creating Arcturus."); + LOGGER.info("Capheus - Decompilation"); + LOGGER.info("Beny - Lead Developer"); + LOGGER.info("Alejandro - Lead Developer"); + LOGGER.info("Harmonic - Developer"); + LOGGER.info("ArpyAge - Developer"); + LOGGER.info("Mike - Developer"); + LOGGER.info("Skeletor - Developer"); + LOGGER.info("zGrav - Developer"); + LOGGER.info("Swirny - Developer"); + LOGGER.info("Quadral - Developer"); + LOGGER.info("Dome - Developer"); + LOGGER.info("Necmi - Developer"); + LOGGER.info("Oliver - Support"); + LOGGER.info("Rasmus - Support"); + LOGGER.info("Layne - Support"); + LOGGER.info("Bill - Support"); + LOGGER.info("Harmony - Support"); + LOGGER.info("Ridge - Catalogue"); + LOGGER.info("Tenshie - Catalogue"); + LOGGER.info("Wulles - Catalogue"); + LOGGER.info("Gizmo - Catalogue"); + LOGGER.info("TheJava - Motivation"); + LOGGER.info("The Entire Krews.org Community."); } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/database/Database.java b/Emulator/src/main/java/com/eu/habbo/database/Database.java index 171e7c9..00be0fe 100644 --- a/Emulator/src/main/java/com/eu/habbo/database/Database.java +++ b/Emulator/src/main/java/com/eu/habbo/database/Database.java @@ -5,7 +5,9 @@ import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariDataSource; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -13,8 +15,10 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -@Slf4j public class Database { + + private static final Logger LOGGER = LoggerFactory.getLogger(Database.class); + private HikariDataSource dataSource; private DatabasePool databasePool; @@ -26,21 +30,21 @@ public class Database { try { this.databasePool = new DatabasePool(); if (!this.databasePool.getStoragePooling(config)) { - log.info("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; - log.error("Failed to connect to your database.", e); + LOGGER.error("Failed to connect to your database.", e); } finally { if (SQLException) { Emulator.prepareShutdown(); } } - log.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis); + LOGGER.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis); } public void dispose() { diff --git a/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java b/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java index 5e09e06..d840b68 100644 --- a/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java +++ b/Emulator/src/main/java/com/eu/habbo/database/DatabasePool.java @@ -3,10 +3,11 @@ package com.eu.habbo.database; import com.eu.habbo.core.ConfigurationManager; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j class DatabasePool { + private final Logger log = LoggerFactory.getLogger(DatabasePool.class); private static final String DB_POOL_MAX_SIZE = "db.pool.maxsize"; private static final String DB_POOL_MIN_SIZE = "db.pool.minsize"; private static final String DB_HOSTNAME_KEY = "db.hostname"; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java index db5e3ba..7944ae8 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java @@ -23,10 +23,13 @@ import com.eu.habbo.habbohotel.rooms.RoomManager; import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionScheduler; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class GameEnvironment { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameEnvironment.class); + public CreditsScheduler creditsScheduler; public PixelScheduler pixelScheduler; public PointsScheduler pointsScheduler; @@ -55,7 +58,7 @@ public class GameEnvironment { private CalendarManager calendarManager; public void load() throws Exception { - log.info("GameEnvironment -> Loading..."); + LOGGER.info("GameEnvironment -> Loading..."); this.permissionsManager = new PermissionsManager(); this.habboManager = new HabboManager(); @@ -97,7 +100,7 @@ public class GameEnvironment { this.subscriptionScheduler = new SubscriptionScheduler(); Emulator.getThreading().run(this.subscriptionScheduler); - log.info("GameEnvironment -> Loaded!"); + LOGGER.info("GameEnvironment -> Loaded!"); } public void dispose() { @@ -115,7 +118,7 @@ public class GameEnvironment { this.hotelViewManager.dispose(); this.subscriptionManager.dispose(); this.calendarManager.dispose(); - log.info("GameEnvironment -> Disposed!"); + LOGGER.info("GameEnvironment -> Disposed!"); } public HabboManager getHabboManager() { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/LatencyTracker.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/LatencyTracker.java deleted file mode 100644 index b2ffb9d..0000000 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/LatencyTracker.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.eu.habbo.habbohotel; - -import com.eu.habbo.habbohotel.gameclients.GameClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -public class LatencyTracker { - - private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); - - private boolean initialPing; - - private long last; - private long average; - - public LatencyTracker() { - this.initialPing = true; - this.average = 0; - } - - public void update(long latencyInNano) { - this.last = latencyInNano; - - if (this.initialPing) { - this.initialPing = false; - this.average = latencyInNano; - return; - } - - this.average = (long) (this.average * .7f + latencyInNano * .3f); - } - - public boolean hasInitialized() { - return !this.initialPing; - } - - public long getLastMs() { - return TimeUnit.NANOSECONDS.toMillis(this.last); - } - - public long getAverageMs() { - return TimeUnit.NANOSECONDS.toMillis(this.average); - } - -} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java index 5e614aa..78304cd 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java @@ -18,14 +18,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.LinkedHashMap; import java.util.Map; -@Slf4j public class AchievementManager { + private static final Logger LOGGER = LoggerFactory.getLogger(AchievementManager.class); + public static boolean TALENTTRACK_ENABLED = false; private final THashMap achievements; @@ -57,7 +59,7 @@ public class AchievementManager { statement.setInt(4, amount); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -139,7 +141,7 @@ public class AchievementManager { try { badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase()); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return; } } @@ -207,7 +209,7 @@ public class AchievementManager { statement.setInt(3, 1); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -221,7 +223,7 @@ public class AchievementManager { } statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -235,7 +237,7 @@ public class AchievementManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -258,9 +260,9 @@ public class AchievementManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } @@ -280,13 +282,13 @@ public class AchievementManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); - log.error("Achievement Manager -> Failed to load!"); + LOGGER.error("Caught SQL exception", e); + LOGGER.error("Achievement Manager -> Failed to load!"); return; } } - log.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/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java index b9425a7..e491523 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java @@ -5,13 +5,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class TalentTrackLevel { + private static final Logger LOGGER = LoggerFactory.getLogger(TalentTrackLevel.class); public TalentTrackType type; public int level; @@ -38,7 +39,7 @@ public class TalentTrackLevel { if (achievement != null) { this.achievements.put(achievement, Integer.valueOf(achievementLevels[i])); } else { - log.error("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); } } } @@ -49,7 +50,7 @@ public class TalentTrackLevel { if (item != null) { this.items.add(item); } else { - log.error("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/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 189106c..b1149aa 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -12,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -21,8 +22,9 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; -@Slf4j 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(";"); @@ -162,7 +164,7 @@ public class Bot implements Runnable { statement.execute(); this.needsUpdate = false; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -196,7 +198,7 @@ public class Bot implements Runnable { .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "") .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name) .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getName()) - .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + ""); // TODO: Should getUserCount be replaced with getUsersWithoutInvisibleHabbos? + .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + ""); if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) { this.talk(message); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index fa6182e..2eebcc6 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -17,14 +17,18 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.sql.*; import java.util.Map; -@Slf4j + + 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; public static int MAXIMUM_CHAT_SPEED = 604800; @@ -41,7 +45,7 @@ public class BotManager { this.reload(); - log.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 { @@ -56,10 +60,10 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - log.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) { - log.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; } } @@ -86,12 +90,12 @@ public class BotManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return bot; @@ -147,7 +151,7 @@ public class BotManager { try { topItem.onWalkOn(bot.getRoomUnit(), room, null); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -205,11 +209,11 @@ public class BotManager { if (botClazz != null) return botClazz.getDeclaredConstructor(ResultSet.class).newInstance(set); else - log.error("Unknown Bot Type: " + type); + LOGGER.error("Unknown Bot Type: " + type); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -220,7 +224,7 @@ public class BotManager { statement.setInt(1, bot.getId()); return statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -233,9 +237,9 @@ public class BotManager { m.setAccessible(true); m.invoke(null); } catch (NoSuchMethodException e) { - log.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) { - log.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/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java index 99ad733..b5acb9f 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java @@ -10,7 +10,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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -21,8 +22,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; -@Slf4j 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 { @@ -47,7 +48,7 @@ public class ButlerBot extends Bot { serveItems.put(ks, set.getInt("item")); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java index e384ace..1336f88 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java @@ -5,7 +5,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer; import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; @@ -13,15 +14,17 @@ import java.util.Date; import static java.time.temporal.ChronoUnit.DAYS; -@Slf4j + public class CalendarManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CalendarCampaign.class); + final private static Map calendarCampaigns = new THashMap<>(); public static double HC_MODIFIER; public CalendarManager() { long millis = System.currentTimeMillis(); this.reload(); - log.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); + LOGGER.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis)); } public void dispose(){ @@ -37,7 +40,7 @@ public class CalendarManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return false; } @@ -51,7 +54,7 @@ public class CalendarManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return false; } @@ -82,7 +85,7 @@ public class CalendarManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } calendarCampaigns.put(campaign.getId(), campaign); @@ -95,7 +98,7 @@ public class CalendarManager { statement.setInt(1, campaign.getId()); return statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -141,7 +144,7 @@ public class CalendarManager { statement.setInt(5, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java index 6cb29e7..b266111 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java @@ -7,7 +7,8 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,8 +16,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -@Slf4j public class CatalogItem implements ISerialize, Runnable, Comparable { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogItem.class); int id; int limitedStack; private int pageId; @@ -28,12 +29,26 @@ public class CatalogItem implements ISerialize, Runnable, Comparable bundle; public CatalogItem(ResultSet set) throws SQLException { @@ -203,7 +218,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0) { @@ -250,8 +265,8 @@ public class CatalogItem implements ISerialize, Runnable, Comparable limitedNumbers; private int totalSet; @@ -49,7 +51,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(5, item.getLimitedSells()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -67,7 +69,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.totalSet += amount; @@ -100,7 +102,7 @@ public class CatalogLimitedConfiguration implements Runnable { statement.setInt(3, this.itemId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java index abe0f5e..886e492 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java @@ -41,15 +41,17 @@ import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; import java.util.stream.Collectors; -@Slf4j public class CatalogManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogManager.class); + public static final THashMap> pageDefinitions = new THashMap>(CatalogPageLayouts.values().length) { { for (CatalogPageLayouts layout : CatalogPageLayouts.values()) { @@ -219,7 +221,7 @@ public class CatalogManager { this.ecotronItem = Emulator.getGameEnvironment().getItemManager().getItem("ecotron_box"); - log.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -258,7 +260,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } for (Map.Entry> set : limiteds.entrySet()) { @@ -278,7 +280,7 @@ public class CatalogManager { Class pageClazz = pageDefinitions.get(set.getString("page_layout")); if (pageClazz == null) { - log.info("Unknown Page Layout: " + set.getString("page_layout")); + LOGGER.info("Unknown Page Layout: " + set.getString("page_layout")); continue; } @@ -286,12 +288,12 @@ public class CatalogManager { CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set); pages.put(page.getId(), page); } catch (Exception e) { - log.error("Failed to load layout: {}", set.getString("page_layout")); + LOGGER.error("Failed to load layout: {}", set.getString("page_layout")); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } pages.forEachValue((object) -> { @@ -303,7 +305,7 @@ public class CatalogManager { } } else { if (object.parentId != -2) { - log.info("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; @@ -311,7 +313,7 @@ public class CatalogManager { this.catalogPages.putAll(pages); - log.info("Loaded " + this.catalogPages.size() + " Catalog Pages!"); + LOGGER.info("Loaded " + this.catalogPages.size() + " Catalog Pages!"); } @@ -332,7 +334,7 @@ public class CatalogManager { )); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -376,7 +378,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } for (CatalogPage page : this.catalogPages.valueCollection()) { @@ -401,7 +403,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -417,7 +419,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -432,7 +434,7 @@ public class CatalogManager { this.vouchers.add(new Voucher(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -452,11 +454,11 @@ public class CatalogManager { this.prizes.get(set.getInt("rarity")).add(item); } else { - log.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id")); + LOGGER.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id")); } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -481,7 +483,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -496,7 +498,7 @@ public class CatalogManager { this.clothing.put(set.getInt("id"), new ClothItem(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -573,7 +575,7 @@ public class CatalogManager { return statement.executeUpdate() >= 1; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -701,7 +703,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 { - log.error("No rewards specified for rarity level {}", level); + LOGGER.error("No rewards specified for rarity level {}", level); } return null; @@ -733,10 +735,10 @@ public class CatalogManager { try { catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { - log.error("Unknown page layout: {}", page.getString("page_layout")); + LOGGER.error("Unknown page layout: {}", page.getString("page_layout")); } } } @@ -744,7 +746,7 @@ public class CatalogManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (catalogPage != null) { @@ -803,7 +805,7 @@ public class CatalogManager { } } - log.info("Catalog Manager -> Disposed!"); + LOGGER.info("Catalog Manager -> Disposed!"); } @@ -872,7 +874,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); - log.info(message); + LOGGER.info(message); habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); return; } @@ -959,7 +961,7 @@ public class CatalogManager { try { pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient()); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } @@ -1018,7 +1020,7 @@ public class CatalogManager { try { guildId = Integer.parseInt(extradata); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -1141,7 +1143,7 @@ public class CatalogManager { } } catch (Exception e) { - log.error("Exception caught", e); + LOGGER.error("Exception caught", e); habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } finally { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java index 96c46db..b161c20 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java @@ -7,14 +7,15 @@ import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -@Slf4j 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<>(); @@ -72,8 +73,8 @@ public abstract class CatalogPage implements Comparable, ISerialize try { this.included.add(Integer.valueOf(id)); } catch (Exception e) { - log.error("Caught exception", e); - log.error("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/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java index 18a23df..468e2a2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java @@ -1,8 +1,8 @@ package com.eu.habbo.habbohotel.catalog; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -11,8 +11,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -@Slf4j public class Voucher { + private static final Logger LOGGER = LoggerFactory.getLogger(Voucher.class); public final int id; public final String code; @@ -46,7 +46,7 @@ public class Voucher { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -69,7 +69,7 @@ public class Voucher { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java index 06d2053..d283ada 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java @@ -14,13 +14,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.Map; -@Slf4j public class RoomBundleLayout extends SingleBundle { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleLayout.class); public int roomId; public Room room; @@ -47,7 +48,7 @@ public class RoomBundleLayout extends SingleBundle { if (this.room != null) this.room.preventUnloading = true; } else { - log.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); + LOGGER.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")"); } } @@ -189,7 +190,7 @@ public class RoomBundleLayout extends SingleBundle { statement.setInt(3, this.room.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -223,7 +224,7 @@ public class RoomBundleLayout extends SingleBundle { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java index 610f038..f4d9aef 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java @@ -16,7 +16,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -25,8 +27,9 @@ import java.util.ArrayList; import java.util.List; -@Slf4j public class MarketPlace { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlace.class); + //Configuration. Loaded from database & updated accordingly. public static boolean MARKETPLACE_ENABLED = true; @@ -44,7 +47,7 @@ public class MarketPlace { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return offers; @@ -102,7 +105,7 @@ public class MarketPlace { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, false)); } } @@ -166,7 +169,7 @@ public class MarketPlace { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return offers; @@ -196,7 +199,7 @@ public class MarketPlace { message.appendInt(1); message.appendInt(itemId); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -211,7 +214,7 @@ public class MarketPlace { number = set.getInt("number"); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return number; @@ -229,7 +232,7 @@ public class MarketPlace { avg = set.getInt("avg"); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return calculateCommision(avg); @@ -296,7 +299,7 @@ public class MarketPlace { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -323,7 +326,7 @@ public class MarketPlace { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -389,7 +392,7 @@ public class MarketPlace { statement.setInt(2, offer.getOfferId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java index d242648..196544e 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java @@ -5,11 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; -@Slf4j public class MarketPlaceOffer implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlaceOffer.class); + public int avarage; public int count; private int offerId; @@ -67,7 +70,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -87,7 +90,7 @@ public class MarketPlaceOffer implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -161,7 +164,7 @@ public class MarketPlaceOffer implements Runnable { statement.setInt(3, this.offerId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java index cf58ac5..cddf2f2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -3,14 +3,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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(";")); @@ -44,7 +45,7 @@ public class AddYoutubePlaylistCommand extends Command { return true; } - Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(itemId, playlist); + Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.parseInt(params[1]), playlist); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `youtube_playlists` (`item_id`, `playlist_id`) VALUES (?, ?)")) { statement.setInt(1, itemId); @@ -52,7 +53,7 @@ public class AddYoutubePlaylistCommand extends Command { statement.execute(); } catch (SQLException e) { - log.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/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java index e5a25e8..1328ed1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java @@ -6,15 +6,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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(";")); @@ -75,7 +76,7 @@ public class BadgeCommand extends Command { return true; } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java index 90751de..b2f98f3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java @@ -16,16 +16,18 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; -@Slf4j 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) { @@ -37,7 +39,7 @@ public class CommandHandler { public CommandHandler() { long millis = System.currentTimeMillis(); this.reloadCommands(); - log.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static void addCommand(Command command) { @@ -46,6 +48,19 @@ public class CommandHandler { commands.put(command.getClass().getName(), command); } + + + public static void addCommand(Class command) { + try { + //command.getConstructor().setAccessible(true); + addCommand(command.newInstance()); + LOGGER.debug("Added command: {}", command.getName()); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + } + + public static boolean handleCommand(GameClient gameClient, String commandLine) { if (gameClient != null && commandLine != null) { if (commandLine.startsWith(":")) { @@ -75,7 +90,7 @@ public class CommandHandler { succes = event.succes; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) { @@ -279,7 +294,6 @@ public class CommandHandler { addCommand(new AddYoutubePlaylistCommand()); addCommand(new SoftKickCommand()); addCommand(new SubscriptionCommand()); - addCommand(new PingCommand()); addCommand(new TestCommand()); } @@ -306,6 +320,6 @@ public class CommandHandler { public void dispose() { commands.clear(); - log.info("Command Handler -> Disposed!"); + LOGGER.info("Command Handler -> Disposed!"); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java index 43800a0..cf69a1d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java @@ -5,10 +5,11 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.users.Habbo; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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(";")); @@ -42,7 +43,7 @@ public class EnableCommand extends Command { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java index e1f1647..9e208a0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java @@ -4,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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(";")); } @@ -36,7 +39,7 @@ public class FilterWordCommand extends Command { statement.setString(2, replacement); statement.execute(); } catch (SQLException e) { - log.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/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java index 119b1ef..52a3d45 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java @@ -23,7 +23,7 @@ public class HotelAlertCommand extends Command { message.append(params[i]).append(" "); } - ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n\r\nVan:" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); + ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { Habbo habbo = set.getValue(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java index 7f40f52..e433735 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/InvisibleCommand.java @@ -4,7 +4,6 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.rooms.RoomLayout; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer; @@ -19,16 +18,14 @@ public class InvisibleCommand extends Command { @Override public boolean handle(GameClient gameClient, String[] params) throws Exception { - HabboInfo habboInfo = gameClient.getHabbo().getHabboInfo(); RoomUnit roomUnit = gameClient.getHabbo().getRoomUnit(); - habboInfo.toggleInvisibility(); - - if (!habboInfo.isInvisibleInRooms() && !roomUnit.isInRoom()) { + if (roomUnit.isInvisible()) { RoomLayout roomLayout = roomUnit.getRoom().getLayout(); new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().x, roomLayout.getDoorTile().y, roomLayout.getDoorTile().z, 0).run(); + roomUnit.setInvisible(false); roomUnit.setInRoom(true); roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose()); @@ -37,12 +34,13 @@ public class InvisibleCommand extends Command { WiredHandler.handle(WiredTriggerType.ENTER_ROOM, roomUnit, roomUnit.getRoom(), null); roomUnit.getRoom().habboEntered(gameClient.getHabbo()); - gameClient.getHabbo().whisper("Je bent weer zichtbaar voor anderen."); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated.back")); return true; } - gameClient.getHabbo().whisper("Je bent nu onzichtbaar. Typ opnieuw :invisible om weer zichtbaar te zijn in kamers."); + roomUnit.setInvisible(true); + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_invisible.updated")); gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRemoveComposer(roomUnit).compose()); return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java index dadb88b..13d72c3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java @@ -32,6 +32,9 @@ public class MimicCommand extends Command { } else if (habbo.hasPermission(Permission.ACC_NOT_MIMICED) && !gameClient.getHabbo().hasPermission(Permission.ACC_NOT_MIMICED)) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.blocked").replace("%user%", params[1]).replace("%gender_name%", (habbo.getHabboInfo().getGender().equals(HabboGender.M) ? Emulator.getTexts().getValue("gender.him") : Emulator.getTexts().getValue("gender.her"))), RoomChatMessageBubbles.ALERT); return true; + } else if (!habbo.hasPermission("acc_mimic_unredeemed") && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) { + gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.forbidden_clothing"), RoomChatMessageBubbles.ALERT); + return true; } else { gameClient.getHabbo().getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_MIMIC ? ClothingValidationManager.validateLook(gameClient.getHabbo(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getGender().name()) : habbo.getHabboInfo().getLook()); gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender()); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/PingCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/PingCommand.java deleted file mode 100644 index c76429e..0000000 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/PingCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.eu.habbo.habbohotel.commands; - -import com.eu.habbo.habbohotel.LatencyTracker; -import com.eu.habbo.habbohotel.gameclients.GameClient; - -public class PingCommand extends Command { - public PingCommand() { - super(null, new String[]{"ping"}); - } - - @Override - public boolean handle(GameClient gameClient, String[] params) throws Exception { - if (gameClient.getHabbo().getRoomUnit() == null) { - return true; - } - - final LatencyTracker latencyTracker = gameClient.getLatencyTracker(); - - if (latencyTracker.hasInitialized()) { - gameClient.getHabbo().whisper(String.format("Gemiddelde ping %dms, laatste ping %dms", - latencyTracker.getAverageMs(), - latencyTracker.getLastMs())); - } else { - gameClient.getHabbo().whisper("Ping-snelheid is nog niet berekend, probeer het over een minuut opnieuw."); - } - - return true; - } -} \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java index 346a1e3..3b3f516 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java @@ -7,12 +7,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; -@Slf4j 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(";")); @@ -65,7 +66,7 @@ public class RoomBundleCommand extends Command { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } ((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom()); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java index ef4afe9..d6e9487 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StaffAlertCommand.java @@ -19,7 +19,7 @@ public class StaffAlertCommand extends Command { message.append(params[i]).append(" "); } - Emulator.getGameEnvironment().getHabboManager().staffAlert(message + "\r\n\r\nVan:" + gameClient.getHabbo().getHabboInfo().getUsername()); + Emulator.getGameEnvironment().getHabboManager().staffAlert(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new FriendChatMessageComposer(new Message(gameClient.getHabbo().getHabboInfo().getId(), -1, message.toString())).compose(), "acc_staff_chat", gameClient); } else { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffalert.forgot_message"), RoomChatMessageBubbles.ALERT); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java index ac87441..de6bde5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/StalkCommand.java @@ -24,11 +24,6 @@ public class StalkCommand extends Command { return true; } - if (habbo.getHabboInfo().isInvisibleInRooms()) { - gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); - return true; - } - if (habbo.getHabboInfo().getCurrentRoom() == null) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.not_room").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java index 9299a86..b4a3ca7 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java @@ -70,7 +70,7 @@ public class UserInfoCommand extends Command { message.append(Emulator.getTexts().getValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r"); } - message.append("\r").append(onlineHabbo != null ? "" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + ((onlineHabbo.getHabboInfo().getCurrentRoom() != null && !onlineHabbo.getHabboInfo().isInvisibleInRooms()) ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : ""); + message.append("\r").append(onlineHabbo != null ? "" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : ""); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java index 079f31f..9fe611a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java @@ -4,14 +4,17 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class CraftingManager { + private static final Logger LOGGER = LoggerFactory.getLogger(CraftingManager.class); + private final THashMap altars; public CraftingManager() { @@ -53,14 +56,14 @@ public class CraftingManager { recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount")); altar.addIngredient(ingredientItem); } else { - log.error("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -114,7 +117,7 @@ public class CraftingManager { } statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.altars.clear(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java index ea122b4..a05ef0a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java @@ -2,36 +2,31 @@ package com.eu.habbo.habbohotel.gameclients; import com.eu.habbo.Emulator; import com.eu.habbo.crypto.HabboEncryption; -import com.eu.habbo.habbohotel.LatencyTracker; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.MessageComposer; import io.netty.channel.Channel; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; -@Slf4j public class GameClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); + private final Channel channel; private final HabboEncryption encryption; - private final LatencyTracker latencyTracker; private Habbo habbo; private boolean handshakeFinished; private String machineId = ""; - private boolean finishedReleaseEvent = false; - - public void finishedReleaseEvent() { - this.finishedReleaseEvent = true; - } - - public boolean didFinishReleaseEvent() { - return this.finishedReleaseEvent; - } - public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25); public final ConcurrentHashMap, Long> messageTimestamps = new ConcurrentHashMap<>(); public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); @@ -44,7 +39,6 @@ public class GameClient { Emulator.getCrypto().getModulus(), Emulator.getCrypto().getPrivateExponent()) : null; - this.latencyTracker = new LatencyTracker(); } public Channel getChannel() { @@ -55,10 +49,6 @@ public class GameClient { return encryption; } - public LatencyTracker getLatencyTracker() { - return latencyTracker; - } - public Habbo getHabbo() { return this.habbo; } @@ -129,7 +119,7 @@ public class GameClient { this.habbo = null; } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/Game.java index b0cb883..24a8051 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/Game.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/Game.java @@ -20,11 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Map; import java.util.stream.Collectors; -@Slf4j + 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; @@ -72,7 +75,7 @@ public abstract class Game implements Runnable { return true; } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return false; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java index fbd7995..c14f640 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java @@ -17,18 +17,26 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; -@Slf4j public class BattleBanzaiGame extends Game { + private static final Logger LOGGER = LoggerFactory.getLogger(BattleBanzaiGame.class); + public static final int effectId = 32; + + public static final int POINTS_HIJACK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.steal", 0); + + public static final int POINTS_FILL_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.fill", 0); + + public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock", 1); private static final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Emulator.getConfig().getInt("hotel.banzai.fill.threads", 2)); @@ -157,7 +165,7 @@ public class BattleBanzaiGame extends Game { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java index ef8cb6d..642564d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java @@ -23,13 +23,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.HashMap; import java.util.Map; -@Slf4j 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; public static int POWER_UP_CHANCE; public static int POWER_UP_PROTECT_TIME; @@ -261,7 +265,7 @@ public class FreezeGame extends Game { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java index e778c20..d77f677 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java @@ -1,14 +1,16 @@ package com.eu.habbo.habbohotel.guilds; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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; @@ -92,7 +94,7 @@ public class Guild implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -117,7 +119,7 @@ public class Guild implements Runnable { this.needsUpdate = false; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java index 65c6903..2f84660 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java @@ -13,15 +13,21 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.*; import java.util.stream.Collectors; -@Slf4j public class GuildManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(GuildManager.class); + private final THashMap> guildParts; + private final TIntObjectMap guilds; + private final THashSet views = new THashSet<>(); public GuildManager() { @@ -32,7 +38,7 @@ public class GuildManager { this.loadGuildParts(); this.loadGuildViews(); - log.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } @@ -50,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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -64,7 +70,7 @@ public class GuildManager { this.views.add(new ForumView(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -105,7 +111,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } habbo.getHabboStats().addGuild(guild.getId()); @@ -150,10 +156,10 @@ public class GuildManager { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); if (room != null) { - room.setGuildId(0); + room.setGuild(0); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -274,7 +280,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -286,7 +292,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -301,7 +307,7 @@ public class GuildManager { statement.setInt(3, guild.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -323,7 +329,7 @@ public class GuildManager { statement.setInt(2, guild.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -350,7 +356,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return member; @@ -373,7 +379,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return guildMembers; @@ -395,7 +401,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return guildMembers; @@ -414,7 +420,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -432,7 +438,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return guildAdmins; @@ -464,7 +470,7 @@ public class GuildManager { if (g != null) g.loadMemberCount(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -492,7 +498,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return guilds; @@ -512,7 +518,7 @@ public class GuildManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return guilds; @@ -591,7 +597,7 @@ public class GuildManager { statement.setInt(2, furni.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -606,7 +612,7 @@ public class GuildManager { guildIterator.remove(); } - log.info("Guild Manager -> Disposed!"); + LOGGER.info("Guild Manager -> Disposed!"); } public boolean hasViewedForum(int userId, int guildId) { @@ -626,7 +632,7 @@ public class GuildManager { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java index 444f34b..f4325c0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java @@ -9,12 +9,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.*; -@Slf4j 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<>(); private final int threadId; @@ -70,7 +74,7 @@ public class ForumThread implements Runnable, ISerialize { try { this.lastComment = ForumThreadComment.getById(set.getInt("last_comment_id")); } catch (SQLException e) { - log.error("ForumThread last_comment_id exception", e); + LOGGER.error("ForumThread last_comment_id exception", e); } this.comments = new THashMap<>(); @@ -109,7 +113,7 @@ public class ForumThread implements Runnable, ISerialize { Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return createdThread; @@ -157,7 +161,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return threads; @@ -196,7 +200,7 @@ public class ForumThread implements Runnable, ISerialize { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return foundThread; @@ -338,7 +342,7 @@ public class ForumThread implements Runnable, ISerialize { addComment(comment); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -462,7 +466,7 @@ public class ForumThread implements Runnable, ISerialize { this.needsUpdate = false; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java index 7819064..1be9631 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java @@ -8,11 +8,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; -@Slf4j 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; private final int threadId; @@ -64,7 +67,7 @@ public class ForumThreadComment implements Runnable, ISerialize { } } } catch (SQLException e) { - log.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) { - log.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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java index a6d8cd1..a4c398b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java @@ -2,22 +2,29 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -@Slf4j public class HallOfFame { + private static final Logger LOGGER = LoggerFactory.getLogger(HallOfFame.class); + private final THashMap winners = new THashMap<>(); + + private String competitionName; + public HallOfFame() { this.setCompetitionName("xmasRoomComp"); this.reload(); } + public void reload() { this.winners.clear(); @@ -28,7 +35,7 @@ public class HallOfFame { this.winners.put(winner.getId(), winner); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java index d8a03d8..998de6f 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFameWinner.java @@ -20,7 +20,7 @@ public class HallOfFameWinner implements Comparable { this.id = set.getInt("id"); this.username = set.getString("username"); this.look = set.getString("look"); - this.points = set.getInt("achievement_score"); + this.points = set.getInt("hof_points"); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java index d85eaf8..81048f3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java @@ -1,9 +1,12 @@ package com.eu.habbo.habbohotel.hotelview; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class HotelViewManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewManager.class); + private final HallOfFame hallOfFame; private final NewsList newsList; @@ -12,7 +15,7 @@ public class HotelViewManager { this.hallOfFame = new HallOfFame(); this.newsList = new NewsList(); - log.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis); + LOGGER.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis); } public HallOfFame getHallOfFame() { @@ -24,7 +27,7 @@ public class HotelViewManager { } public void dispose() { - log.info("HotelView Manager -> Disposed!"); + LOGGER.info("HotelView Manager -> Disposed!"); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java index 3eed86d..b3bebc4 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java @@ -1,15 +1,18 @@ package com.eu.habbo.habbohotel.hotelview; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -@Slf4j public class NewsList { + private static final Logger LOGGER = LoggerFactory.getLogger(NewsList.class); + private final ArrayList newsWidgets; public NewsList() { @@ -26,7 +29,7 @@ public class NewsList { this.newsWidgets.add(new NewsWidget(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -35,4 +38,4 @@ public class NewsList { public ArrayList getNewsWidgets() { return this.newsWidgets; } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java index af7cd65..6049779 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java @@ -1,15 +1,17 @@ package com.eu.habbo.habbohotel.items; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; -@Slf4j public class CrackableReward { + private static final Logger LOGGER = LoggerFactory.getLogger(CrackableReward.class); public final int itemId; public final int count; @@ -46,7 +48,7 @@ public class CrackableReward { itemId = Integer.valueOf(prize.split(":")[0]); chance = Integer.valueOf(prize.split(":")[1]); } else if (prize.contains(":")) { - log.error("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(":", "")); } @@ -54,7 +56,7 @@ public class CrackableReward { this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance)); this.totalChance += chance; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index 344c066..16ec285 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -60,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Constructor; import java.sql.*; import java.util.*; -@Slf4j public class ItemManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(ItemManager.class); + //Configuration. Loaded from database & updated accordingly. public static boolean RECYCLER_ENABLED = true; @@ -101,7 +105,7 @@ public class ItemManager { this.highscoreManager.load(); this.loadNewUserGifts(); - log.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } protected void loadItemInteractions() { @@ -262,6 +266,7 @@ public class ItemManager { this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class)); + this.interactionsList.add(new ItemInteraction("wf_xtra_random", WiredExtraRandom.class)); this.interactionsList.add(new ItemInteraction("wf_xtra_unseen", WiredExtraUnseen.class)); this.interactionsList.add(new ItemInteraction("wf_blob", WiredBlob.class)); @@ -357,7 +362,7 @@ public class ItemManager { return interaction; } - log.debug("Can't find interaction class: {}", type.getName()); + LOGGER.debug("Can't find interaction class: {}", type.getName()); return this.getItemInteraction(InteractionDefault.class); } @@ -387,12 +392,12 @@ public class ItemManager { else this.items.get(id).update(set); } catch (Exception e) { - log.error("Failed to load Item ({})", set.getInt("id")); - log.error("Caught exception", e); + LOGGER.error("Failed to load Item ({})", set.getInt("id")); + LOGGER.error("Caught exception", e); } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -405,16 +410,16 @@ public class ItemManager { try { reward = new CrackableReward(set); } catch (Exception e) { - log.error("Failed to load items_crackable item_id = {}", set.getInt("item_id")); - log.error("Caught exception", 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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -448,7 +453,7 @@ public class ItemManager { this.soundTracks.put(set.getString("code"), new SoundTrack(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -481,16 +486,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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells); } } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; } @@ -505,7 +510,7 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -530,7 +535,7 @@ public class ItemManager { statement.setInt(1, item.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -557,7 +562,7 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return item; @@ -597,9 +602,9 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return item; @@ -611,7 +616,7 @@ public class ItemManager { statement.setInt(2, itemTwoId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -621,7 +626,7 @@ public class ItemManager { statement.setInt(2, hopper.getBaseItem().getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -636,7 +641,7 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return a; @@ -652,9 +657,9 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return item; @@ -675,7 +680,7 @@ public class ItemManager { return (HabboItem) c.newInstance(set, baseItem); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -699,7 +704,7 @@ public class ItemManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -715,7 +720,7 @@ public class ItemManager { return null; if (extraData.length() > 1000) { - log.error("Extradata exceeds maximum length of 1000 characters: {}", extraData); + LOGGER.error("Extradata exceeds maximum length of 1000 characters: {}", extraData); extraData = extraData.substring(0, 1000); } @@ -770,8 +775,9 @@ public class ItemManager { public void dispose() { this.items.clear(); + this.highscoreManager.dispose(); - log.info("Item Manager -> Disposed!"); + LOGGER.info("Item Manager -> Disposed!"); } public List getInteractionList() { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java index f046227..4822d78 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/PostItColor.java @@ -13,25 +13,7 @@ public enum PostItColor { PINK("FF9CFF"), - YELLOW("FFFF33"), - - - RED("FF9C9D"), - - - ORANGE("FFCD9C"), - - - PURPLE("C3B1E1"), - - - LIGHTBLUE("DBDEFB"), - - - WHITE("FFFFFF"), - - - BLACK("282828"); + YELLOW("FFFF33"); public final String hexColor; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java index ff3babe..bc9662a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java @@ -1,10 +1,13 @@ package com.eu.habbo.habbohotel.items; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Arrays; -@Slf4j 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: - log.warn("RandomStateParams: unknown key: " + keyValue[0]); + LOGGER.warn("RandomStateParams: unknown key: " + keyValue[0]); break; } }); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index 9ac2b61..082c0a8 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -6,7 +6,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.IOException; @@ -20,8 +22,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -@Slf4j public class YoutubeManager { + private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class); public static class YoutubeVideo { private final String id; @@ -84,7 +86,7 @@ public class YoutubeManager { Emulator.getThreading().run(() -> { ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10); - log.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()) { @@ -92,7 +94,6 @@ public class YoutubeManager { final int itemId = set.getInt("item_id"); final String playlistId = set.getString("playlist_id"); - youtubeDataLoaderPool.submit(() -> { YoutubePlaylist playlist; try { @@ -101,13 +102,13 @@ public class YoutubeManager { this.addPlaylistToItem(itemId, playlist); } } catch (IOException e) { - log.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); + LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); } }); } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } youtubeDataLoaderPool.shutdown(); @@ -116,7 +117,8 @@ public class YoutubeManager { } catch (InterruptedException e) { e.printStackTrace(); } - log.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + + LOGGER.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); }); } @@ -133,7 +135,7 @@ public class YoutubeManager { BufferedReader playlistBR = new BufferedReader(playlistISR); JsonObject errorObj = JsonParser.parseReader(playlistBR).getAsJsonObject(); String message = errorObj.get("error").getAsJsonObject().get("message").getAsString(); - log.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message); + LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message); return null; } InputStream playlistInputStream = playlistCon.getInputStream(); @@ -144,7 +146,7 @@ public class YoutubeManager { JsonArray playlists = playlistData.get("items").getAsJsonArray(); if (playlists.size() == 0) { - log.error("Playlist {} not found!", playlistId); + LOGGER.error("Playlist {} not found!", playlistId); return null; } JsonObject playlistItem = playlists.get(0).getAsJsonObject().get("snippet").getAsJsonObject(); @@ -207,13 +209,12 @@ public class YoutubeManager { } while (nextPageToken != null); if (videos.isEmpty()) { - log.warn("Playlist {} has no videos!", playlistId); + LOGGER.warn("Playlist {} has no videos!", playlistId); return null; } playlist = new YoutubePlaylist(playlistId, name, description, videos); this.playlistCache.put(playlistId, playlist); - log.info("Loaded youtube playList into cache:" + playlistId); return playlist; @@ -225,6 +226,5 @@ public class YoutubeManager { public void addPlaylistToItem(int itemId, YoutubePlaylist playlist) { this.playlists.computeIfAbsent(itemId, k -> new ArrayList<>()).add(playlist); - log.info("Loaded youtube playList into FurniID:" + itemId); } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java index d045698..133e83c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java @@ -3,12 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } state += amount; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java index 150ae99..4860d0f 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java @@ -9,12 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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); } @@ -76,7 +79,7 @@ public class InteractionDefault extends HabboItem { try { currentState = Integer.valueOf(this.getExtradata()); } catch (NumberFormatException e) { - log.error("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()); @@ -96,36 +99,33 @@ public class InteractionDefault extends HabboItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - Habbo habbo = room.getHabbo(roomUnit); - - if (habbo != null && habbo.getHabboInfo().getRiding() == null) { super.onWalkOn(roomUnit, room, objects); - if (roomUnit != null) { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { - if (habbo != null) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); - log.error("newHabbos Effect Male"); - return; - } - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); - log.error("newHabbos Effect Female"); - } + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + Habbo habbo = room.getHabbo(roomUnit); + + if (habbo != null) { + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) { + room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1); + return; } - } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getBot(roomUnit); - if (bot != null) { - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) { - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); - return; - } - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) { - room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); - } + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) { + room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1); + } + } + } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { + Bot bot = room.getBot(roomUnit); + + if (bot != null) { + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) { + room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1); + return; + } + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) { + room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1); } } } @@ -135,58 +135,54 @@ public class InteractionDefault extends HabboItem { @Override public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - Habbo habboride = room.getHabbo(roomUnit); + super.onWalkOff(roomUnit, room, objects); - if (habboride != null && habboride.getHabboInfo().getRiding() == null) { - super.onWalkOff(roomUnit, room, objects); + if (roomUnit != null) { + if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { + int nextEffectM = 0; + int nextEffectF = 0; - if (roomUnit != null) { - if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) { - int nextEffectM = 0; - int nextEffectF = 0; + if (objects != null && objects.length == 2) { + if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) { + RoomTile goalTile = (RoomTile) objects[0]; + HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y, (objects[0] != objects[1]) ? this : null); - if (objects != null && objects.length == 2) { - if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile) { - RoomTile goalTile = (RoomTile) objects[0]; - HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y, (objects[0] != objects[1]) ? this : null); + if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { + return; + } - if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) { - return; - } - - if (topItem != null) { - nextEffectM = topItem.getBaseItem().getEffectM(); - nextEffectF = topItem.getBaseItem().getEffectF(); - } + if(topItem != null) { + nextEffectM = topItem.getBaseItem().getEffectM(); + nextEffectF = topItem.getBaseItem().getEffectF(); } } + } - if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { - Habbo habbo = room.getHabbo(roomUnit); + if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) { + Habbo habbo = room.getHabbo(roomUnit); - if (habbo != null) { + if (habbo != null) { - if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - room.giveEffect(habbo, nextEffectM, -1); - return; - } - - if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - room.giveEffect(habbo, nextEffectF, -1); - } + if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { + room.giveEffect(habbo, nextEffectM, -1); + return; } - } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { - Bot bot = room.getBot(roomUnit); - if (bot != null) { - if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { - room.giveEffect(roomUnit, nextEffectM, -1); - return; - } + if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { + room.giveEffect(habbo, nextEffectF, -1); + } + } + } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) { + Bot bot = room.getBot(roomUnit); - if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { - room.giveEffect(roomUnit, nextEffectF, -1); - } + if (bot != null) { + if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) { + room.giveEffect(roomUnit, nextEffectM, -1); + return; + } + + if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) { + room.giveEffect(roomUnit, nextEffectF, -1); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java index af3f799..b2255e2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java @@ -11,14 +11,18 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -@Slf4j public class InteractionFireworks extends InteractionDefault { + + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class); + private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels private static final String STATE_CHARGED = "1"; private static final String STATE_EXPLOSION = "2"; @@ -125,7 +129,7 @@ public class InteractionFireworks extends InteractionDefault { try { explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams()); } catch (NumberFormatException e) { - log.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); + LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")"); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java index 5aa15da..41fb4dc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java @@ -8,12 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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; @@ -29,7 +32,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - log.warn("Incorrect extradata for gift with ID " + this.getId()); + LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); } } @@ -39,7 +42,7 @@ public class InteractionGift extends HabboItem { try { this.loadData(); } catch (Exception e) { - log.warn("Incorrect extradata for gift with ID " + this.getId()); + LOGGER.warn("Incorrect extradata for gift with ID " + this.getId()); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java index 5009359..f001fc2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java @@ -5,13 +5,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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 { super(set, baseItem); @@ -21,7 +25,7 @@ public class InteractionMusicDisc extends HabboItem { try { this.songId = Integer.valueOf(stuff[6]); } catch (Exception e) { - log.error("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!"); } } } @@ -35,7 +39,7 @@ public class InteractionMusicDisc extends HabboItem { try { this.songId = Integer.valueOf(stuff[6]); } catch (Exception e) { - log.error("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/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java index 4e18542..a63dcad 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java @@ -1,29 +1,34 @@ package com.eu.habbo.habbohotel.items.interactions; -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.pets.HorsePet; +import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; -import com.eu.habbo.threading.runnables.HabboItemNewState; +import gnu.trove.set.hash.THashSet; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Objects; -public class InteractionObstacle extends HabboItem { +public class InteractionObstacle extends HabboItem implements ICycleable { + + private THashSet middleTiles; public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); this.setExtradata("0"); + this.middleTiles = new THashSet<>(); } public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); this.setExtradata("0"); + this.middleTiles = new THashSet<>(); } @Override @@ -51,79 +56,59 @@ public class InteractionObstacle extends HabboItem { @Override public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { - final HorsePet horse = room.getHabboHorse(roomUnit); + /*Pet pet = room.getPet(roomUnit); - if (horse == null) { - return; - } + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { + if (pet.getTask() != null && pet.getTask().equals(PetTasks.RIDE)) { + if (pet.getRoomUnit().hasStatus(RoomUnitStatus.JUMP)) { + pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + Emulator.getThreading().run(new HabboItemNewState(this, room, "0"), 2000); + } else { + int state = 0; + for (int i = 0; i < 2; i++) { + state = Emulator.getRandom().nextInt(4) + 1; - if (horse.getRoomUnit().hasStatus(RoomUnitStatus.JUMP)) { - return; - } + if (state == 4) + break; + } - // Random state. - int state = 0; - for (int i = 0; i < 2; i++) { - state = Emulator.getRandom().nextInt(4) + 1; + this.setExtradata(state + ""); + pet.getRoomUnit().setStatus(RoomUnitStatus.JUMP, "0"); - if (state == 4) - break; - } + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("HorseConsecutiveJumpsCount")); + AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("HorseJumping")); + } - this.setExtradata(state + ""); - - // Reset state. - Emulator.getThreading().run(new HabboItemNewState(this, room, "0"), 2000); - - // Jump animation. - roomUnit.removeStatus(RoomUnitStatus.MOVE); - roomUnit.removeStatus(RoomUnitStatus.JUMP); - roomUnit.statusUpdate(true); - - horse.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); - horse.getRoomUnit().removeStatus(RoomUnitStatus.MOVE); - horse.getRoomUnit().setStatus(RoomUnitStatus.JUMP, "0"); - room.updateRoomUnit(horse.getRoomUnit()); - - Emulator.getThreading().run(() -> { - horse.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); - room.updateRoomUnit(horse.getRoomUnit()); - }, 1000); - - // Achievement. - final Habbo habbo = horse.getRider(); - - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("HorseConsecutiveJumpsCount")); - AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("HorseJumping")); - - room.updateItemState(this); + room.updateItemState(this); + } + }*/ } @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - final HorsePet horse = room.getHabboHorse(roomUnit); + Habbo habbo = room.getHabbo(roomUnit); - if (horse == null) { - return; - } + if (habbo == null) { + Pet pet = room.getPet(roomUnit); - if (roomUnit.getBodyRotation().getValue() % 2 != 0) { - return; - } - - if (this.getRotation() == 2) { - if (roomUnit.getBodyRotation() == RoomUserRotation.WEST) { - roomUnit.setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() - 3), roomUnit.getY())); - } else if (roomUnit.getBodyRotation() == RoomUserRotation.EAST) { - roomUnit.setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() + 3), roomUnit.getY())); - } - } else if (this.getRotation() == 4) { - if (roomUnit.getBodyRotation() == RoomUserRotation.NORTH) { - roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() - 3))); - } else if (roomUnit.getBodyRotation() == RoomUserRotation.SOUTH) { - roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() + 3))); + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { + if (roomUnit.getBodyRotation().getValue() % 2 == 0) { + if (this.getRotation() == 2) { + if (roomUnit.getBodyRotation().equals(RoomUserRotation.WEST)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() - 3), roomUnit.getY())); + } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.EAST)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() + 3), roomUnit.getY())); + } + } else if (this.getRotation() == 4) { + if (roomUnit.getBodyRotation().equals(RoomUserRotation.NORTH)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() - 3))); + } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.SOUTH)) { + ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() + 3))); + } + } + } } } } @@ -132,12 +117,80 @@ public class InteractionObstacle extends HabboItem { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOff(roomUnit, room, objects); - final HorsePet horse = room.getHabboHorse(roomUnit); + Habbo habbo = room.getHabbo(roomUnit); - if (horse == null) { - return; + if (habbo == null) { + Pet pet = room.getPet(roomUnit); + + if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) { + pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + } + } + } + + @Override + public void onPlace(Room room) { + super.onPlace(room); + this.calculateMiddleTiles(room); + } + + @Override + public void onPickUp(Room room) { + super.onPickUp(room); + middleTiles.clear(); + } + + @Override + public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + super.onMove(room, oldLocation, newLocation); + this.calculateMiddleTiles(room); + } + + private void calculateMiddleTiles(Room room) { + middleTiles.clear(); + + if(this.getRotation() == 2) { + middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), this.getY())); + middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1))); + } + else if(this.getRotation() == 4) { + middleTiles.add(room.getLayout().getTile(this.getX(), (short)(this.getY() + 1))); + middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1))); + } + } + + @Override + public RoomTileState getOverrideTileState(RoomTile tile, Room room) { + if(this.middleTiles.contains(tile)) + return RoomTileState.BLOCKED; + + return null; + } + + @Override + public void cycle(Room room) { + if(this.middleTiles.size() == 0) { + this.calculateMiddleTiles(room); } - horse.getRoomUnit().removeStatus(RoomUnitStatus.JUMP); + for(RoomTile tile : this.middleTiles) { + for(RoomUnit unit : tile.getUnits()) { + if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) { + if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation()) + continue; + + RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentLocation(), unit.getBodyRotation().getValue()); + if(tileInfront.state != RoomTileState.INVALID && tileInfront.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) { + unit.setGoalLocation(tileInfront); + } + else { + RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentLocation(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue()); + if(tileBehind.state != RoomTileState.INVALID && tileBehind.state != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) { + unit.setGoalLocation(tileBehind); + } + } + } + } + } } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java index b1c7ba9..48a4d35 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java @@ -12,15 +12,18 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.awt.*; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class InteractionRentableSpace extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionRentableSpace.class); + private int renterId; private String renterName; private int endTimestamp; @@ -51,7 +54,7 @@ public class InteractionRentableSpace extends HabboItem { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } else { @@ -181,7 +184,7 @@ public class InteractionRentableSpace extends HabboItem { statement.setInt(1, zero); statement.setInt(2, zero); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java index c2e7ea4..1048969 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java @@ -16,7 +16,7 @@ import java.util.List; public class InteractionRoller extends HabboItem { public static boolean NO_RULES = false; - public static final int DELAY = 400; + public static int DELAY = 400; public InteractionRoller(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -52,7 +52,7 @@ public class InteractionRoller extends HabboItem { } @Override - public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) { + public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java index 8a0f084..cf74069 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java @@ -24,9 +24,6 @@ public class InteractionTrap extends InteractionDefault { public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { if (!this.getExtradata().equals("0")) { Habbo habbo = room.getHabbo(roomUnit); - if(habbo == null) { - return; - } int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId(); roomUnit.stopWalking(); super.onWalkOn(roomUnit, room, objects); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java index 7aa6231..f2541e1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java @@ -2,8 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer; import gnu.trove.map.hash.TLongLongHashMap; @@ -75,7 +77,7 @@ public abstract class InteractionWired extends InteractionDefault { } public void activateBox(Room room, RoomUnit roomUnit, long millis) { - if (!room.isHideWired()) { + if(!room.isHideWired()) { this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); room.sendComposer(new ItemStateComposer(this).compose()); } @@ -129,4 +131,35 @@ public abstract class InteractionWired extends InteractionDefault { public void addUserExecutionCache(int roomUnitId, long timestamp) { this.userExecutionCache.put((long)roomUnitId, timestamp); } + + public static WiredSettings readSettings(ClientMessage packet, boolean isEffect) + { + int intParamCount = packet.readInt(); + int[] intParams = new int[intParamCount]; + + for(int i = 0; i < intParamCount; i++) + { + intParams[i] = packet.readInt(); + } + + String stringParam = packet.readString(); + + int itemCount = packet.readInt(); + int[] itemIds = new int[itemCount]; + + for(int i = 0; i < itemCount; i++) + { + itemIds[i] = packet.readInt(); + } + + WiredSettings settings = new WiredSettings(intParams, stringParam, itemIds, -1); + + if(isEffect) + { + settings.setDelay(packet.readInt()); + } + + settings.setStuffTypeSelectionCode(packet.readInt()); + return settings; + } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java index 7bf21fe..ef63491 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java @@ -2,11 +2,11 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionOperator; import com.eu.habbo.habbohotel.wired.WiredConditionType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer; import java.sql.ResultSet; @@ -43,7 +43,7 @@ public abstract class InteractionWiredCondition extends InteractionWired { public abstract WiredConditionType getType(); - public abstract boolean saveData(ClientMessage packet); + public abstract boolean saveData(WiredSettings settings); public WiredConditionOperator operator() { return WiredConditionOperator.AND; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java index 59da2b6..e58e365 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java @@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer; @@ -43,7 +43,7 @@ public abstract class InteractionWiredEffect extends InteractionWired { } } - public abstract boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException; + public abstract boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException; public int getDelay() { return this.delay; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java index 8bef931..6c8be89 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java @@ -13,16 +13,21 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -@Slf4j public class InteractionWiredHighscore extends HabboItem { + private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWiredHighscore.class); + public WiredHighscoreScoreType scoreType; public WiredHighscoreClearType clearType; + private List data; + public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); @@ -35,7 +40,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.reloadData(); @@ -53,7 +58,7 @@ public class InteractionWiredHighscore extends HabboItem { this.scoreType = WiredHighscoreScoreType.valueOf(name); this.clearType = WiredHighscoreClearType.values()[ctype]; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.reloadData(); @@ -88,7 +93,7 @@ public class InteractionWiredHighscore extends HabboItem { this.setExtradata(Math.abs(state - 1) + ""); room.updateItem(this); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } if(client != null && !(objects.length >= 2 && objects[1] instanceof WiredEffectType)) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java index c0bbaab..91fb8c0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -44,7 +45,7 @@ public abstract class InteractionWiredTrigger extends InteractionWired { public abstract WiredTriggerType getType(); - public abstract boolean saveData(ClientMessage packet); + public abstract boolean saveData(WiredSettings settings); protected int getDelay() { return this.delay; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java index da906a9..bb868c6 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java @@ -15,14 +15,18 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.threading.runnables.games.GameTimer; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; -@Slf4j 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; private int timeNow = 0; private boolean isRunning = false; @@ -91,7 +95,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { } }).toArray(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -123,7 +127,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable { room.addGame(game); game.initialise(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSuper.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSuper.java deleted file mode 100644 index 46084d9..0000000 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSuper.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.eu.habbo.habbohotel.items.interactions.wired; - -import com.eu.habbo.Emulator; -import com.eu.habbo.habbohotel.items.ItemManager; -import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; -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.highscores.WiredHighscoreDataEntry; -import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; -import gnu.trove.set.hash.THashSet; - -import java.util.Collections; -import java.util.List; - -// Mikee: Lazy, sorry. -// Mikee: Yeah, duplicate code, sorry. -public class WiredSuper { - - public static void addPoint(final RoomUnit roomUnit, final Room room, final int scoreToAdd) { - final Habbo habbo = room.getHabbo(roomUnit); - - if (habbo == null) { - return; - } - - final ItemManager itemManager = Emulator.getGameEnvironment().getItemManager(); - final WiredHighscoreManager wiredHighscoreManager = itemManager.getHighscoreManager(); - final THashSet wiredHighscores = room.getRoomSpecialTypes().getWiredHighscores(); - final List userIds = Collections.singletonList(habbo.getHabboInfo().getId()); - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - final int itemId = highscore.getId(); - final WiredHighscoreDataEntry entry = new WiredHighscoreDataEntry(itemId, userIds, scoreToAdd, true, Emulator.getIntUnixTimestamp()); - - wiredHighscoreManager.addOrUpdateHighscoreData(entry); - } - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - highscore.reloadData(); - - room.updateItem(highscore); - } - } - - public static void setPoint(final RoomUnit roomUnit, final Room room, final int scoreToAdd) { - final Habbo habbo = room.getHabbo(roomUnit); - - if (habbo == null) { - return; - } - - final ItemManager itemManager = Emulator.getGameEnvironment().getItemManager(); - final WiredHighscoreManager wiredHighscoreManager = itemManager.getHighscoreManager(); - final THashSet wiredHighscores = room.getRoomSpecialTypes().getWiredHighscores(); - final List userIds = Collections.singletonList(habbo.getHabboInfo().getId()); - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - final int itemId = highscore.getId(); - final WiredHighscoreDataEntry entry = new WiredHighscoreDataEntry(itemId, userIds, scoreToAdd, true, Emulator.getIntUnixTimestamp()); - - wiredHighscoreManager.setHighscoreData(entry); - } - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - highscore.reloadData(); - - room.updateItem(highscore); - } - } - - public static boolean noTotalClassement(RoomUnit roomUnit, Room room) { - final Habbo habbo = room.getHabbo(roomUnit); - - if (habbo == null) { - return false; - } - - final ItemManager itemManager = Emulator.getGameEnvironment().getItemManager(); - final WiredHighscoreManager wiredHighscoreManager = itemManager.getHighscoreManager(); - final THashSet wiredHighscores = room.getRoomSpecialTypes().getWiredHighscores(); - final List userIds = Collections.singletonList(habbo.getHabboInfo().getId()); - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - final WiredHighscoreDataEntry entry = wiredHighscoreManager.getHighscoreRow(highscore.getId(), userIds); - - if (entry != null) { - return false; - } - } - - return true; - } - - public static boolean totalPointEqual(RoomUnit roomUnit, Room room, int score) { - final Habbo habbo = room.getHabbo(roomUnit); - - if (habbo == null) { - return false; - } - - final ItemManager itemManager = Emulator.getGameEnvironment().getItemManager(); - final WiredHighscoreManager wiredHighscoreManager = itemManager.getHighscoreManager(); - final THashSet wiredHighscores = room.getRoomSpecialTypes().getWiredHighscores(); - final List userIds = Collections.singletonList(habbo.getHabboInfo().getId()); - - for (final InteractionWiredHighscore highscore : wiredHighscores) { - final WiredHighscoreDataEntry entry = wiredHighscoreManager.getHighscoreRow(highscore.getId(), userIds); - - if (entry != null && entry.getScore() == score) { - return true; - } - } - - return false; - } -} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java index d4b9296..11f1276 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java @@ -3,12 +3,13 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import java.sql.ResultSet; import java.sql.SQLException; @@ -50,10 +51,10 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.startDate = packet.readInt(); - this.endDate = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.startDate = settings.getIntParams()[0]; + this.endDate = settings.getIntParams()[1]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java index ddce19a..22ec093 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -136,15 +137,12 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; - this.all = packet.readInt() == 1; + this.all = settings.getIntParams()[0] == 1; - packet.readString(); - - count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -153,7 +151,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java index a0d0708..6a2a70a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -24,8 +25,6 @@ import java.util.stream.Collectors; public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO; - - protected boolean all; protected THashSet items; public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { @@ -41,7 +40,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { @Override public void onPickUp() { this.items.clear(); - this.all = false; } @Override @@ -67,7 +65,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { public String getWiredData() { this.refresh(); return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @@ -79,7 +76,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { if (wiredData.startsWith("{")) { JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class); - this.all = data.all; for(int id : data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -92,17 +88,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { String[] data = wiredData.split(":"); if (data.length >= 1) { - this.all = (data[0].equals("1")); - if (data.length == 2) { - String[] items = data[1].split(";"); + String[] items = data[1].split(";"); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); - if (item != null) - this.items.add(item); - } + if (item != null) + this.items.add(item); } } } @@ -127,8 +120,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); + message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -136,13 +128,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; - packet.readString(); - - count = packet.readInt(); if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -151,7 +139,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); @@ -182,11 +170,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition { } static class JsonData { - boolean all; List itemIds; - public JsonData(boolean all, List itemIds) { - this.all = all; + public JsonData(List itemIds) { this.itemIds = itemIds; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java index 47c42d6..9330457 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -117,11 +118,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -130,7 +128,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java index cc01ba7..5d4133d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -69,7 +70,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java index d5e93e2..df8e210 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -86,11 +87,10 @@ public class WiredConditionHabboCount extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.lowerLimit = packet.readInt(); - this.upperLimit = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.lowerLimit = settings.getIntParams()[0]; + this.upperLimit = settings.getIntParams()[1]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java index 7e1580f..5f9f5b1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -76,10 +77,9 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.effectId = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.effectId = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java index 0d351e9..d60dded 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -51,10 +52,9 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.handItem = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.handItem = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java index b4f0df9..8d2b3db 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -88,10 +89,8 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.badge = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.badge = settings.getStringParam(); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java index b40ee5e..f4db5bb 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -81,11 +82,9 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.cycles = packet.readInt(); - + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.cycles = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java index 76ece81..cd185da 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -69,28 +70,24 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) { - int count; - packet.readInt(); - - this.state = packet.readInt() == 1; - this.direction = packet.readInt() == 1; - this.position = packet.readInt() == 1; - - packet.readString(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 3) return false; + this.state = settings.getIntParams()[0] == 1; + this.direction = settings.getIntParams()[1] == 1; + this.position = settings.getIntParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return true; - count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.settings.clear(); for (int i = 0; i < count; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem item = room.getHabboItem(itemId); if (item != null) diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java index 0be6ba1..83bd300 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -81,11 +82,9 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.cycles = packet.readInt(); - + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.cycles = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java index 279f61b..b09314c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -137,14 +138,11 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.all = settings.getIntParams()[0] == 1; - this.all = packet.readInt() == 1; - - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -153,7 +151,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java index 87f3bc9..9409ebe 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; @@ -24,8 +25,7 @@ import java.util.stream.Collectors; public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO; - - protected boolean all; + protected THashSet items; public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException { @@ -41,7 +41,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { @Override public void onPickUp() { this.items.clear(); - this.all = false; } @Override @@ -67,7 +66,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { public String getWiredData() { this.refresh(); return WiredHandler.getGsonBuilder().create().toJson(new JsonData( - this.all, this.items.stream().map(HabboItem::getId).collect(Collectors.toList()) )); } @@ -79,7 +77,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { if (wiredData.startsWith("{")) { WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class); - this.all = data.all; for(int id : data.itemIds) { HabboItem item = room.getHabboItem(id); @@ -92,17 +89,13 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { String[] data = wiredData.split(":"); if (data.length >= 1) { - this.all = (data[0].equals("1")); + String[] items = data[1].split(";"); - if (data.length == 2) { - String[] items = data[1].split(";"); + for (String s : items) { + HabboItem item = room.getHabboItem(Integer.parseInt(s)); - for (String s : items) { - HabboItem item = room.getHabboItem(Integer.parseInt(s)); - - if (item != null) - this.items.add(item); - } + if (item != null) + this.items.add(item); } } } @@ -127,8 +120,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getId()); message.appendString(""); - message.appendInt(1); - message.appendInt(this.all ? 1 : 0); + message.appendInt(0); message.appendInt(0); message.appendInt(this.getType().code); message.appendInt(0); @@ -136,12 +128,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -150,7 +138,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) this.items.add(item); @@ -181,11 +169,9 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition { } static class JsonData { - boolean all; List itemIds; - public JsonData(boolean all, List itemIds) { - this.all = all; + public JsonData(List itemIds) { this.itemIds = itemIds; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java index 30c9ea5..595eee3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -117,11 +118,8 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -130,7 +128,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java index 3075c4f..7f1d6ca 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -85,11 +86,10 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.lowerLimit = packet.readInt(); - this.upperLimit = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 2) return false; + this.lowerLimit = settings.getIntParams()[0]; + this.upperLimit = settings.getIntParams()[1]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java index ae1c20b..3f1a733 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredConditionType; @@ -76,10 +77,9 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.effectId = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.effectId = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java index 6df96d6..cf84c10 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -89,10 +90,8 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.badge = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.badge = settings.getStringParam(); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java index 520f28b..d7dbfbc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -69,7 +70,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java index b805c7b..0f9d6c9 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -89,10 +90,9 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.teamColor = GameTeamColors.values()[packet.readInt()]; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java index 027db81..b8376c0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -91,10 +92,9 @@ public class WiredConditionTeamMember extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.teamColor = GameTeamColors.values()[packet.readInt()]; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java index 61e3fd7..0afdf18 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java @@ -3,6 +3,7 @@ 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.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -118,11 +119,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + public boolean saveData(WiredSettings settings) { + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false; this.items.clear(); @@ -131,7 +129,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition { if (room != null) { for (int i = 0; i < count; i++) { - HabboItem item = room.getHabboItem(packet.readInt()); + HabboItem item = room.getHabboItem(settings.getFurniIds()[i]); if (item != null) { this.items.add(item); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java index f0a5b3f..24a2888 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java @@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; -import com.google.gson.Gson; import java.sql.ResultSet; import java.sql.SQLException; @@ -49,11 +48,9 @@ public class WiredEffectBotClothes extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String dataString = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String dataString = settings.getStringParam(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java index ee1b28b..b46d041 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java @@ -6,12 +6,12 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; 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 com.eu.habbo.habbohotel.wired.WiredHandler; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.procedure.TObjectProcedure; @@ -70,17 +70,18 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); + + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String botName = packet.readString().replace("\t", ""); + String botName = settings.getStringParam().replace("\t", ""); botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); - packet.readInt(); - int delay = packet.readInt(); + + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java index 27fc788..5b380d3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -13,7 +14,6 @@ import com.eu.habbo.habbohotel.users.Habbo; 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.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem; @@ -74,17 +74,17 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing item id"); - int itemId = packet.readInt(); + int itemId = settings.getIntParams()[0]; if(itemId < 0) itemId = 0; - String botName = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + String botName = settings.getStringParam(); + + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java index 735b0f3..79fae2c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java @@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; 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 com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; @@ -52,15 +52,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid"); + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = packet.readString(); + String dataString = settings.getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) @@ -71,8 +70,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - packet.readInt(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java index 8fede69..ad0c876 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java @@ -6,13 +6,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; 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 com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredTriggerType; -import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import gnu.trove.procedure.TObjectProcedure; @@ -73,15 +73,14 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - int mode = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing mode"); + int mode = settings.getIntParams()[0]; if(mode != 0 && mode != 1) throw new WiredSaveException("Mode is invalid"); - String dataString = packet.readString(); + String dataString = settings.getStringParam(); String splitBy = "\t"; if(!dataString.contains(splitBy)) throw new WiredSaveException("Malformed data string"); @@ -91,8 +90,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect { if (data.length != 2) throw new WiredSaveException("Malformed data string. Invalid data length"); - packet.readInt(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java index 07bbac6..822934a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -114,10 +115,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String botName = packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String botName = settings.getStringParam(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -126,7 +126,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -135,7 +135,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java index 73906c8..b4b9d26 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -67,10 +68,9 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String botName = packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String botName = settings.getStringParam(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -79,7 +79,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -88,7 +88,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java index 0ce892d..7ee3859 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.*; @@ -210,9 +211,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int startDirectionInt = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); + + int startDirectionInt = settings.getIntParams()[0]; if(startDirectionInt < 0 || startDirectionInt > 7 || (startDirectionInt % 2) != 0) { throw new WiredSaveException("Start direction is invalid"); @@ -220,15 +222,13 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionInt); - int blockedActionInt = packet.readInt(); + int blockedActionInt = settings.getIntParams()[1]; if(blockedActionInt < 0 || blockedActionInt > 6) { throw new WiredSaveException("Blocked action is invalid"); } - packet.readString(); - - int itemsCount = packet.readInt(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -237,7 +237,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { THashMap newItems = new THashMap<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -246,7 +246,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect { newItems.put(it, new WiredChangeDirectionSetting(it.getId(), it.getRotation(), startDirection)); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java index 4d21822..6dafe83 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -67,17 +68,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.amount = Integer.parseInt(packet.readString()); + this.amount = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java index 0bd6216..d228c75 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewHofPoints.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -66,16 +67,14 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.amount = Integer.valueOf(packet.readString()); + this.amount = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java index 4a3b966..91b7846 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -67,17 +68,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { try { - this.respects = Integer.valueOf(packet.readString()); + this.respects = Integer.parseInt(settings.getStringParam()); } catch (Exception e) { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java index f4c3a2b..3c8fb88 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; @@ -15,6 +16,7 @@ import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; @@ -174,16 +176,16 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { if (gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) { - int argsLength = packet.readInt(); - this.rewardTime = packet.readInt(); - this.uniqueRewards = packet.readInt() == 1; - this.limit = packet.readInt(); - this.limitationInterval = packet.readInt(); + if(settings.getIntParams().length < 4) throw new WiredSaveException("Invalid data"); + this.rewardTime = settings.getIntParams()[0]; + this.uniqueRewards = settings.getIntParams()[1] == 1; + this.limit = settings.getIntParams()[2]; + this.limitationInterval = settings.getIntParams()[3]; this.given = 0; - String data = packet.readString(); + String data = settings.getStringParam(); String[] items = data.split(";"); @@ -204,8 +206,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect { return false; } - packet.readInt(); - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); WiredHandler.dropRewards(this.getId()); return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java index 6632c2e..293515c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScore.java @@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -172,23 +173,20 @@ public class WiredEffectGiveScore extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data"); - int score = packet.readInt(); + int score = settings.getIntParams()[0]; if(score < 1 || score > 100) throw new WiredSaveException("Score is invalid"); - int timesPerGame = packet.readInt(); + int timesPerGame = settings.getIntParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - packet.readString(); - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java index dcbc148..a439a66 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.GameTeam; import com.eu.habbo.habbohotel.games.GameTeamColors; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -121,28 +122,25 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); - int points = packet.readInt(); + int points = settings.getIntParams()[0]; if(points < 1 || points > 100) throw new WiredSaveException("Points is invalid"); - int timesPerGame = packet.readInt(); + int timesPerGame = settings.getIntParams()[1]; if(timesPerGame < 1 || timesPerGame > 10) throw new WiredSaveException("Times per game is invalid"); - int team = packet.readInt(); + int team = settings.getIntParams()[2]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - packet.readString(); - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java index 8d36700..28bd7c4 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectJoinTeam.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -134,16 +135,15 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - int team = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); + + int team = settings.getIntParams()[0]; if(team < 1 || team > 4) throw new WiredSaveException("Team is invalid"); - packet.readInt(); - packet.readString(); - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java index e0f2ecd..a75f2e3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; @@ -148,11 +149,9 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - String message = packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String message = settings.getStringParam(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java index deff061..74830cf 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLeaveTeam.java @@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -116,11 +117,8 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - packet.readInt(); - int delay = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java index bb615d8..8d74e31 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; @@ -175,21 +176,18 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - boolean setState = packet.readInt() == 1; - boolean setDirection = packet.readInt() == 1; - boolean setPosition = packet.readInt() == 1; - - packet.readString(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data"); + boolean setState = settings.getIntParams()[0] == 1; + boolean setDirection = settings.getIntParams()[1] == 1; + boolean setPosition = settings.getIntParams()[2] == 1; Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) throw new WiredSaveException("Trying to save wired in unloaded room"); - int itemsCount = packet.readInt(); + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -198,7 +196,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int List newSettings = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -207,7 +205,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY())); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java index 76fe1ed..9f016a9 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -178,10 +179,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -190,7 +189,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -199,7 +198,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java index 3b9367e..4118fd0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -12,6 +13,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; @@ -39,7 +41,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) @@ -48,18 +50,16 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect { this.items.clear(); this.indexOffset.clear(); - packet.readInt(); + if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); + this.direction = settings.getIntParams()[0]; + this.spacing = settings.getIntParams()[1]; - this.direction = packet.readInt(); - this.spacing = packet.readInt(); - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java index c069dc9..89f56d3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; @@ -314,11 +315,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -327,7 +325,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -336,7 +334,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java index 5928e67..fd24af0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java @@ -5,12 +5,14 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import gnu.trove.set.hash.THashSet; import org.slf4j.Logger; @@ -185,28 +187,26 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()); if (room == null) return false; - packet.readInt(); + if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data"); - this.direction = packet.readInt(); - this.rotation = packet.readInt(); + this.direction = settings.getIntParams()[0]; + this.rotation = settings.getIntParams()[1]; - packet.readString(); - - int count = packet.readInt(); + int count = settings.getFurniIds().length; if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false; this.items.clear(); for (int i = 0; i < count; i++) { - this.items.add(room.getHabboItem(packet.readInt())); + this.items.add(room.getHabboItem(settings.getFurniIds()[i])); } - this.setDelay(packet.readInt()); + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java index 3978801..ed3639a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomChatMessage; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; @@ -13,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ServerMessage; +import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; import java.sql.ResultSet; @@ -49,12 +51,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - this.length = packet.readInt(); - this.message = packet.readString(); - packet.readInt(); - this.setDelay(packet.readInt()); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data"); + + this.length = settings.getIntParams()[0]; + this.message = settings.getStringParam(); + + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java index 583e4f6..826b8d3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredEffectType; @@ -67,13 +68,8 @@ public class WiredEffectResetTimers extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) { - packet.readInt(); - packet.readString(); - packet.readInt(); - this.delay = packet.readInt(); - this.setDelay(this.delay); - + public boolean saveData(WiredSettings settings, GameClient gameClient) { + this.setDelay(settings.getDelay()); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java index 304703f..cf6197a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTileState; @@ -130,11 +131,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -143,7 +141,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -152,7 +150,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java index d3d5ab6..7a3a0e1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java @@ -6,7 +6,9 @@ import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.*; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard; +import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; +import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiPuck; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTeleporter; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; @@ -15,6 +17,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -33,7 +36,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; public class WiredEffectToggleFurni extends InteractionWiredEffect { @@ -41,7 +43,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE; - private final CopyOnWriteArraySet items; + private final THashSet items; private static final List> FORBIDDEN_TYPES = new ArrayList>() { { @@ -85,12 +87,12 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { public WiredEffectToggleFurni(ResultSet set, Item baseItem) throws SQLException { super(set, baseItem); - this.items = new CopyOnWriteArraySet<>(); + this.items = new THashSet<>(); } public WiredEffectToggleFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { super(id, userId, item, extradata, limitedStack, limitedSells); - this.items = new CopyOnWriteArraySet<>(); + this.items = new THashSet<>(); } @Override @@ -141,11 +143,8 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -154,7 +153,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -163,7 +162,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java index 4fbd920..d5e6092 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java @@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -137,11 +138,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -150,7 +148,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -159,7 +157,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java index db37872..4f50f57 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -85,11 +86,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - packet.readString(); - - int itemsCount = packet.readInt(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + int itemsCount = settings.getFurniIds().length; if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) { throw new WiredSaveException("Too many furni selected"); @@ -98,7 +96,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { List newItems = new ArrayList<>(); for (int i = 0; i < itemsCount; i++) { - int itemId = packet.readInt(); + int itemId = settings.getFurniIds()[i]; HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId); if(it == null) @@ -107,7 +105,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect { newItems.add(it); } - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java index 56d6f35..79a7ba5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java @@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; 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.wired.WiredChangeDirectionSetting; 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.ClientMessage; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.wired.WiredSaveException; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer; @@ -70,19 +69,15 @@ public class WiredEffectWhisper extends InteractionWiredEffect { } @Override - public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException { - packet.readInt(); - - String message = packet.readString(); + public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException { + String message = settings.getStringParam(); if(gameClient.getHabbo() == null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) { message = Emulator.getGameEnvironment().getWordFilter().filter(message, null); message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100))); } - packet.readInt(); - - int delay = packet.readInt(); + int delay = settings.getDelay(); if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20)) throw new WiredSaveException("Delay too long"); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java index ebdef5f..8f859fd 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java @@ -10,13 +10,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class WiredBlob extends InteractionDefault { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredBlob.class); enum WiredBlobState { ACTIVE("0"), @@ -105,14 +106,14 @@ public class WiredBlob extends InteractionDefault { String[] params = this.getBaseItem().getCustomParams().split(","); if (params.length != 2) { - log.error("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) { - log.error("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/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java index f636464..6075672 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtSetTime.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -110,9 +111,9 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.executeTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.executeTime = settings.getIntParams()[0] * 500; this.resetTimer(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java index 751d21c..7fdf0a2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerAtTimeLong.java @@ -4,6 +4,7 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -109,10 +110,9 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.executeTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.executeTime = settings.getIntParams()[0] * 500; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java index 596fbc8..3de2e34 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -97,17 +98,15 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.botName = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.botName = settings.getStringParam(); this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java index 0e7b22f..0023fb6 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedHabbo.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -48,10 +49,8 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.botName = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.botName = settings.getStringParam(); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java index 4e44660..a40bf2e 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerCollision.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -65,7 +66,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java index f97f332..5d315e5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerFurniStateToggled.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -135,16 +136,13 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java index abb8417..55ff097 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameEnds.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -83,7 +84,7 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java index 5631cb4..89c9a65 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredTriggerType; @@ -83,7 +84,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { + public boolean saveData(WiredSettings settings) { return true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java index 9a1400b..d93a1ba 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboEntersRoom.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -85,9 +86,8 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.username = packet.readString(); + public boolean saveData(WiredSettings settings) { + this.username = settings.getStringParam(); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java index f3b90ae..d0bdd63 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysKeyword.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.Habbo; @@ -93,10 +94,10 @@ public class WiredTriggerHabboSaysKeyword extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.ownerOnly = packet.readInt() == 1; - this.key = packet.readString(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.ownerOnly = settings.getIntParams()[0] == 1; + this.key = settings.getStringParam(); return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java index 64e9dae..10b458b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -128,16 +129,13 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java index 257f23b..d24be48 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java @@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.users.HabboItem; @@ -82,16 +83,13 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - packet.readString(); - + public boolean saveData(WiredSettings settings) { this.items.clear(); - int count = packet.readInt(); + int count = settings.getFurniIds().length; for (int i = 0; i < count; i++) { - this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt())); + this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i])); } return true; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java index e7ad614..d7e6af0 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeater.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -109,10 +110,9 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.repeatTime = packet.readInt() * 500; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.repeatTime = settings.getIntParams()[0] * 500; this.counter = 0; if (this.repeatTime < 500) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java index 1480122..0723ba1 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.ICycleable; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; @@ -107,10 +108,9 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - - this.repeatTime = packet.readInt() * 5000; + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.repeatTime = settings.getIntParams()[0] * 5000; this.counter = 0; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java index 1f558d8..463e5ba 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers; import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.wired.WiredHandler; @@ -85,9 +86,9 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger { } @Override - public boolean saveData(ClientMessage packet) { - packet.readInt(); - this.score = packet.readInt(); + public boolean saveData(WiredSettings settings) { + if(settings.getIntParams().length < 1) return false; + this.score = settings.getIntParams()[0]; return true; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java index 5008963..a081bfc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java @@ -1,13 +1,16 @@ package com.eu.habbo.habbohotel.messenger; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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; @@ -32,7 +35,7 @@ public class Message implements Runnable { statement.setInt(4, this.timestamp); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java index a297ffa..fa4603c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java @@ -11,7 +11,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -19,8 +21,10 @@ import java.sql.SQLException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -@Slf4j 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; @@ -42,7 +46,7 @@ public class Messenger { statement.setInt(4, userOne); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -56,7 +60,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return users; } @@ -91,7 +95,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -108,7 +112,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -120,7 +124,7 @@ public class Messenger { statement.setInt(2, userFrom); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -139,7 +143,7 @@ public class Messenger { count = set.getInt("count"); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return count; @@ -163,7 +167,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return map; } @@ -213,7 +217,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -237,7 +241,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return buddy; @@ -252,7 +256,7 @@ public class Messenger { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -311,7 +315,7 @@ public class Messenger { statement.setInt(1, userTo); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -323,7 +327,7 @@ public class Messenger { statement.setInt(3, userFrom); return statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return 0; @@ -345,7 +349,7 @@ public class Messenger { statement.setInt(3, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Habbo habboTo = Emulator.getGameServer().getGameClientManager().getHabbo(userTo); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java index 9447e8e..d879d00 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java @@ -7,14 +7,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class MessengerBuddy implements Runnable, ISerialize { + private static final Logger LOGGER = LoggerFactory.getLogger(MessengerBuddy.class); + private int id; private String username; private HabboGender gender = HabboGender.M; @@ -46,7 +49,7 @@ public class MessengerBuddy implements Runnable, ISerialize { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -59,7 +62,7 @@ public class MessengerBuddy implements Runnable, ISerialize { this.userOne = 0; this.online = set.getInt("online"); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -154,7 +157,7 @@ public class MessengerBuddy implements Runnable, ISerialize { statement.setInt(3, this.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java index 26be296..3c8517d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java @@ -1,15 +1,18 @@ package com.eu.habbo.habbohotel.modtool; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; -@Slf4j 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; @@ -64,7 +67,7 @@ public class ModToolBan implements Runnable { statement.setInt(9, this.cfhTopic); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 73764c0..3b8e5b3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -21,15 +21,18 @@ import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; import io.netty.channel.Channel; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.net.InetSocketAddress; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Map; -@Slf4j public class ModToolManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolManager.class); + private final TIntObjectMap category; private final THashMap> presets; private final THashMap tickets; @@ -42,7 +45,7 @@ public class ModToolManager { this.tickets = new THashMap<>(); this.cfhCategories = new TIntObjectHashMap<>(); this.loadModTool(); - log.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) { @@ -59,9 +62,9 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -79,7 +82,7 @@ public class ModToolManager { this.loadTickets(connection); this.loadCfhCategories(connection); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -98,7 +101,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -109,7 +112,7 @@ public class ModToolManager { this.presets.get(set.getString("type")).add(set.getString("preset")); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -121,7 +124,7 @@ public class ModToolManager { this.tickets.put(set.getInt("id"), new ModToolIssue(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -147,7 +150,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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -197,7 +200,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -214,7 +217,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -234,7 +237,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatLogs; @@ -271,7 +274,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return chatlogs; @@ -289,7 +292,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return roomVisits; @@ -347,7 +350,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return roomVisits; @@ -377,7 +380,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return null; @@ -504,7 +507,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return ban; @@ -533,7 +536,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return banned; } @@ -556,7 +559,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -570,7 +573,7 @@ public class ModToolManager { statement.execute(); return statement.getUpdateCount() > 0; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; @@ -675,7 +678,7 @@ public class ModToolManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return total; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java index bbe58af..3960d07 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java @@ -4,7 +4,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -12,8 +14,9 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; -@Slf4j public class ModToolSanctions { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolSanctions.class); + private final THashMap> sanctionHashmap; private final THashMap sanctionLevelsHashmap; @@ -23,7 +26,7 @@ public class ModToolSanctions { this.sanctionLevelsHashmap = new THashMap<>(); this.loadModSanctions(); - log.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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -68,7 +71,7 @@ public class ModToolSanctions { } } } catch (SQLException e) { - log.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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -98,7 +101,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -109,7 +112,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -120,7 +123,7 @@ public class ModToolSanctions { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java index 66248c5..68168d6 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java @@ -9,8 +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 lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.ResultSet; @@ -19,8 +19,8 @@ import java.sql.Statement; import java.text.Normalizer; import java.util.regex.Pattern; -@Slf4j 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. @@ -33,7 +33,7 @@ public class WordFilter { public WordFilter() { long start = System.currentTimeMillis(); this.reload(); - log.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); + LOGGER.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)"); } private static String stripDiacritics(String str) { @@ -58,7 +58,7 @@ public class WordFilter { try { word = new WordFilterWord(set); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); continue; } @@ -71,7 +71,7 @@ public class WordFilter { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -150,7 +150,7 @@ public class WordFilter { if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) continue; } - filteredMessage = filteredMessage.replaceAll("(?i)" + Pattern.quote(word.key), word.replacement); + filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement); foundShit = true; if (habbo != null && word.muteTime > 0) { @@ -184,7 +184,7 @@ public class WordFilter { continue; } - message = message.replaceAll("(?i)" + Pattern.quote(word.key), word.replacement); + message = message.replace(word.key, word.replacement); roomChatMessage.filtered = true; } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java index df9304e..5c16598 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java @@ -4,7 +4,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Method; import java.sql.Connection; import java.sql.ResultSet; @@ -16,8 +18,10 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -@Slf4j 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; @@ -34,7 +38,7 @@ public class NavigatorManager { this.filters.put(NavigatorUserFilter.name, new NavigatorUserFilter()); this.filters.put(NavigatorFavoriteFilter.name, new NavigatorFavoriteFilter()); - log.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadNavigator() { @@ -47,7 +51,7 @@ public class NavigatorManager { this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) { @@ -60,12 +64,12 @@ public class NavigatorManager { if (room != null) { category.addRoom(room); } else { - log.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id")); + LOGGER.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id")); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -81,7 +85,7 @@ public class NavigatorManager { field = clazz.getDeclaredMethod(s); clazz = field.getReturnType(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -89,7 +93,7 @@ public class NavigatorManager { try { field = clazz.getDeclaredMethod(set.getString("field")); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); continue; } } @@ -99,11 +103,11 @@ public class NavigatorManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } List staffPromotedRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsStaffPromoted(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java index ceac7fd..957b329 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java @@ -6,14 +6,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Set; -@Slf4j public class PermissionsManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManager.class); + private final TIntObjectHashMap ranks; private final TIntIntHashMap enables; private final THashMap> badges; @@ -26,7 +29,7 @@ public class PermissionsManager { this.reload(); - log.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void reload() { @@ -57,7 +60,7 @@ public class PermissionsManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -70,7 +73,7 @@ public class PermissionsManager { this.enables.put(set.getInt("effect_id"), set.getInt("min_rank")); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java index 3b520aa..b488f96 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java @@ -4,14 +4,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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 { @@ -48,7 +51,7 @@ public class GnomePet extends Pet implements IPetLook { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java index 26094ad..666fa8d 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java @@ -1,14 +1,17 @@ package com.eu.habbo.habbohotel.pets; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class HorsePet extends RideablePet { + private static final Logger LOGGER = LoggerFactory.getLogger(HorsePet.class); + private int hairColor; private int hairStyle; @@ -41,7 +44,7 @@ public class HorsePet extends RideablePet { statement.setInt(6, super.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } super.run(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java index 1828ecd..c362cf5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java @@ -13,7 +13,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -22,8 +24,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; -@Slf4j 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)); @@ -139,7 +142,7 @@ public class MonsterplantPet extends Pet implements IPetLook { statement.setInt(13, this.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index 6f9b976..afd7e03 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -14,14 +14,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.Calendar; import java.util.Map; import java.util.TimeZone; -@Slf4j public class Pet implements ISerialize, Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class); + public int levelThirst; public int levelHunger; public boolean needsUpdate = false; @@ -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) { - log.error("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) { - log.warn("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = false; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java index 109d7ce..8294707 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java @@ -19,15 +19,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.ArrayList; import java.util.Collection; import java.util.Map; -@Slf4j public class PetManager { public static int MAXIMUM_PET_INVENTORY_SIZE = 25; + 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() { @@ -81,7 +83,7 @@ public class PetManager { reloadPetData(); - log.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static int getLevel(int experience) { @@ -152,8 +154,8 @@ public class PetManager { this.loadPetCommands(connection); this.loadPetBreeding(connection); } catch (SQLException e) { - log.error("Caught SQL exception", e); - log.error("Pet Manager -> Failed to load!"); + LOGGER.error("Caught SQL exception", e); + LOGGER.error("Pet Manager -> Failed to load!"); } } @@ -168,7 +170,7 @@ public class PetManager { this.petRaces.get(set.getInt("race")).add(new PetRace(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -178,7 +180,7 @@ public class PetManager { this.petData.put(set.getInt("pet_type"), new PetData(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.loadPetItems(connection); @@ -218,7 +220,7 @@ public class PetManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -232,10 +234,10 @@ public class PetManager { if (petVocalsType != null) { this.petData.get(set.getInt("pet_id")).petVocals.get(petVocalsType).add(new PetVocal(set.getString("message"))); } else { - log.error("Unknown pet vocal type " + set.getString("type")); + LOGGER.error("Unknown pet vocal type " + set.getString("type")); } } else { - log.error("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()))) @@ -245,7 +247,7 @@ public class PetManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -256,7 +258,7 @@ public class PetManager { commandsList.put(set.getInt("command_id"), new PetCommand(set, this.petActions.get(set.getInt("command_id")))); } } catch (SQLException e) { - log.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")) { @@ -268,7 +270,7 @@ public class PetManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -278,7 +280,7 @@ public class PetManager { this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id")); } } catch (SQLException e) { - log.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")) { @@ -295,13 +297,13 @@ public class PetManager { this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } public THashSet getBreeds(String petName) { if (!petName.startsWith("a0 pet")) { - log.error("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; } @@ -309,7 +311,7 @@ public class PetManager { int petId = Integer.valueOf(petName.split("t")[1]); return this.petRaces.get(petId); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -347,7 +349,7 @@ public class PetManager { return this.petData.get(type); } else { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - log.error("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(); @@ -359,13 +361,13 @@ public class PetManager { if (set.next()) { PetData petData = new PetData(set); this.petData.put(type, petData); - log.error("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -512,7 +514,7 @@ public class PetManager { statement.setInt(1, pet.getId()); return statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java index c35acf1..8e2d78a 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java @@ -3,11 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; -@Slf4j public class PollManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PollManager.class); + private final THashMap activePolls = new THashMap<>(); public PollManager() { @@ -24,7 +27,7 @@ public class PollManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; } @@ -64,7 +67,7 @@ public class PollManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java index f1285fd..3ca0650 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java @@ -1,14 +1,17 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class CustomRoomLayout extends RoomLayout implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(CustomRoomLayout.class); + private final int roomId; private boolean needsUpdate; @@ -31,7 +34,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable { statement.setInt(5, this.roomId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 73d5d17..e98dd69 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -20,11 +20,13 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.Interaction import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField; import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole; -import com.eu.habbo.habbohotel.items.interactions.pets.*; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetBreedingNest; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetDrink; +import com.eu.habbo.habbohotel.items.interactions.pets.InteractionPetFood; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.permissions.Permission; -import com.eu.habbo.habbohotel.pets.HorsePet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.pets.RideablePet; @@ -49,7 +51,6 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; 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.PluginManager; import com.eu.habbo.plugin.events.furniture.*; import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent; import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent; @@ -64,10 +65,13 @@ import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.procedure.TIntObjectProcedure; +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.Connection; @@ -75,25 +79,37 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; -import java.util.concurrent.atomic.AtomicReference; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; -@Slf4j public class Room implements Comparable, ISerialize, Runnable { - public static final Comparator SORT_SCORE = (o1, o2) -> o2.getScore() - o1.getScore(); - public static final Comparator SORT_ID = (o1, o2) -> o2.getId() - o1.getId(); + private static final Logger LOGGER = LoggerFactory.getLogger(Room.class); + + public static final Comparator SORT_SCORE = (o1, o2) -> { + + if (!(o1 instanceof Room && o2 instanceof Room)) + return 0; + + return ((Room) o2).getScore() - ((Room) o1).getScore(); + }; + public static final Comparator SORT_ID = (o1, o2) -> { + + if (!(o1 instanceof Room && o2 instanceof Room)) + return 0; + + return ((Room) o2).getId() - ((Room) o1).getId(); + }; private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>(); //Configuration. Loaded from database & updated accordingly. public static boolean HABBO_CHAT_DELAY = false; public static int MAXIMUM_BOTS = 10; public static int MAXIMUM_PETS = 10; - public static int MAXIMUM_FURNI = 3000; + public static int MAXIMUM_FURNI = 2500; public static int MAXIMUM_POSTITNOTES = 200; public static int HAND_ITEM_TIME = 10; public static int IDLE_CYCLES = 240; @@ -101,7 +117,7 @@ public class Room implements Comparable, ISerialize, Runnable { public static String PREFIX_FORMAT = "[%prefix%] "; public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1; public static boolean MUTEAREA_CAN_WHISPER = false; - public static final double MAXIMUM_FURNI_HEIGHT = 40d; + public static double MAXIMUM_FURNI_HEIGHT = 40d; static { for (int i = 1; i <= 3; i++) { @@ -132,8 +148,8 @@ public class Room implements Comparable, ISerialize, Runnable { //Use appropriately. Could potentially cause memory leaks when used incorrectly. public volatile boolean preventUnloading = false; public volatile boolean preventUncaching = false; - public final ConcurrentHashMap.KeySetView scheduledComposers = ConcurrentHashMap.newKeySet(); - public ConcurrentHashMap.KeySetView scheduledTasks = ConcurrentHashMap.newKeySet(); + public ConcurrentSet scheduledComposers = new ConcurrentSet<>(); + public ConcurrentSet scheduledTasks = new ConcurrentSet<>(); public String wordQuiz = ""; public int noVotes = 0; public int yesVotes = 0; @@ -146,7 +162,7 @@ public class Room implements Comparable, ISerialize, Runnable { private String description; private RoomLayout layout; private boolean overrideModel; - private final String layoutName; + private String layoutName; private String password; private RoomState state; private int usersMax; @@ -158,7 +174,7 @@ public class Room implements Comparable, ISerialize, Runnable { private int wallSize; private int wallHeight; private int floorSize; - private int guildId; + private int guild; private String tags; private volatile boolean publicRoom; private volatile boolean staffPromotedRoom; @@ -199,8 +215,6 @@ public class Room implements Comparable, ISerialize, Runnable { private long cycleTimestamp; public Map repeatersLastTick = new HashMap<>(); - - public Room(ResultSet set) throws SQLException { this.id = set.getInt("id"); this.ownerId = set.getInt("owner_id"); @@ -234,7 +248,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.kickOption = set.getInt("who_can_kick"); this.banOption = set.getInt("who_can_ban"); this.pollId = set.getInt("poll_id"); - this.guildId = set.getInt("guild_id"); + this.guild = set.getInt("guild_id"); this.rollerSpeed = set.getInt("roller_speed"); this.overrideModel = set.getString("override_model").equals("1"); this.layoutName = set.getString("model"); @@ -260,7 +274,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.loadBans(connection); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.tradeMode = set.getInt("trade_mode"); @@ -304,21 +318,61 @@ public class Room implements Comparable, ISerialize, Runnable { } this.roomSpecialTypes = new RoomSpecialTypes(); - this.loadLayout(); - this.loadRights(connection); - this.loadItems(connection); - this.loadHeightmap(); - this.loadBots(connection); - this.loadPets(connection); - this.loadWordFilter(connection); - this.loadWiredData(connection); + + try { + this.loadLayout(); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadRights(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadItems(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadHeightmap(); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadBots(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadPets(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadWordFilter(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + + try { + this.loadWiredData(connection); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } this.idleCycles = 0; this.loaded = true; this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.traxManager = new TraxManager(this); @@ -341,35 +395,27 @@ public class Room implements Comparable, ISerialize, Runnable { } private synchronized void loadLayout() { - try { - if (this.layout == null) { - if (this.overrideModel) { - this.layout = Emulator.getGameEnvironment().getRoomManager().loadCustomLayout(this); - } else { - this.layout = Emulator.getGameEnvironment().getRoomManager().loadLayout(this.layoutName, this); - } + if (this.layout == null) { + if (this.overrideModel) { + this.layout = Emulator.getGameEnvironment().getRoomManager().loadCustomLayout(this); + } else { + this.layout = Emulator.getGameEnvironment().getRoomManager().loadLayout(this.layoutName, this); } - } catch (Exception e) { - log.error("Caught exception", e); } } private synchronized void loadHeightmap() { - try { - if (this.layout != null) { - for (short x = 0; x < this.layout.getMapSizeX(); x++) { - for (short y = 0; y < this.layout.getMapSizeY(); y++) { - RoomTile tile = this.layout.getTile(x, y); - if (tile != null) { - this.updateTile(tile); - } + if (this.layout != null) { + for (short x = 0; x < this.layout.getMapSizeX(); x++) { + for (short y = 0; y < this.layout.getMapSizeY(); y++) { + RoomTile tile = this.layout.getTile(x, y); + if (tile != null) { + this.updateTile(tile); } } - } else { - log.error("Unknown Room Layout for Room (ID: {})", this.id); } - } catch (Exception e) { - log.error("Caught exception", e); + } else { + LOGGER.error("Unknown Room Layout for Room (ID: {})", this.id); } } @@ -384,13 +430,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); - } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught SQL exception", e); } if (this.itemCount() > Room.MAXIMUM_FURNI) { - log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); + LOGGER.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI); } } @@ -403,18 +447,18 @@ public class Room implements Comparable, ISerialize, Runnable { try { HabboItem item = this.getHabboItem(set.getInt("id")); - if (item instanceof InteractionWired interactionWired) { - interactionWired.loadWiredData(set, this); + if (item instanceof InteractionWired) { + ((InteractionWired) item).loadWiredData(set, this); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -432,8 +476,7 @@ public class Room implements Comparable, ISerialize, Runnable { b.setRoomUnit(new RoomUnit()); b.getRoomUnit().setPathFinderRoom(this); b.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { - b.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); + if (b.getRoomUnit().getCurrentLocation() == null) { b.getRoomUnit().setLocation(this.getLayout().getDoorTile()); b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); } else { @@ -443,7 +486,7 @@ public class Room implements Comparable, ISerialize, Runnable { } b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT); b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); - + //b.getRoomUnit().setCanWalk(set.getBoolean("freeroam")); b.getRoomUnit().setInRoom(true); this.giveEffect(b.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE); this.addBot(b); @@ -451,44 +494,42 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); - } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught SQL exception", e); } } private synchronized void loadPets(Connection connection) { - this.currentPets.clear(); try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) { statement.setInt(1, this.id); try (ResultSet set = statement.executeQuery()) { while (set.next()) { + try { + Pet pet = PetManager.loadPet(set); + pet.setRoom(this); + pet.setRoomUnit(new RoomUnit()); + pet.getRoomUnit().setPathFinderRoom(this); + pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); + if (pet.getRoomUnit().getCurrentLocation() == null) { + pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); + pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); + } else { + pet.getRoomUnit().setZ(set.getDouble("z")); + pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); + } + pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); + pet.getRoomUnit().setCanWalk(true); + this.addPet(pet); - Pet pet = PetManager.loadPet(set); - pet.setRoom(this); - pet.setRoomUnit(new RoomUnit()); - pet.getRoomUnit().setPathFinderRoom(this); - pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y"))); - if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) { - pet.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight()); - pet.getRoomUnit().setLocation(this.getLayout().getDoorTile()); - pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection())); - } else { - pet.getRoomUnit().setZ(set.getDouble("z")); - pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]); + this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); } - pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET); - pet.getRoomUnit().setCanWalk(true); - this.addPet(pet); - this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name")); } } } catch (SQLException e) { - log.error("Caught SQL exception", e); - } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -503,7 +544,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -516,9 +557,6 @@ public class Room implements Comparable, ISerialize, Runnable { public void updateTiles(THashSet tiles) { for (RoomTile tile : tiles) { - if(tile == null) { - continue; - } this.tileCache.remove(tile); tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false)); tile.setState(this.calculateTileState(tile)); @@ -536,7 +574,8 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomTileState.INVALID; RoomTileState result = RoomTileState.OPEN; - + //HabboItem highestItem = null; + //HabboItem lowestChair = this.getLowestChair(tile); THashSet items = this.getItemsAt(tile); if (items == null) return RoomTileState.INVALID; @@ -550,12 +589,34 @@ public class Room implements Comparable, ISerialize, Runnable { return RoomTileState.LAY; } + /*if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item)) + continue; + + highestItem = item;*/ + if(tallestItem != null && tallestItem.getZ() + Item.getCurrentHeight(tallestItem) > item.getZ() + Item.getCurrentHeight(item)) continue; result = this.checkStateForItem(item, tile); tallestItem = item; + + /*if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) { + continue; + } + + if (lowestItem == null || lowestItem.getZ() < item.getZ()) { + lowestItem = item; + + result = this.checkStateForItem(lowestItem, tile); + } else if (lowestItem.getZ() == item.getZ()) { + if (result == RoomTileState.OPEN) { + result = this.checkStateForItem(item, tile); + } + }*/ } + + //if (lowestChair != null) return RoomTileState.SIT; + return result; } @@ -564,9 +625,13 @@ public class Room implements Comparable, ISerialize, Runnable { if (item.isWalkable()) { result = RoomTileState.OPEN; - } else if (item.getBaseItem().allowSit()) { + } + + if (item.getBaseItem().allowSit()) { result = RoomTileState.SIT; - } else if (item.getBaseItem().allowLay()) { + } + + if (item.getBaseItem().allowLay()) { result = RoomTileState.LAY; } @@ -586,9 +651,10 @@ public class Room implements Comparable, ISerialize, Runnable { boolean walkable = this.layout.tileWalkable(x, y); RoomTile tile = this.getLayout().getTile(x, y); - if ((walkable && tile != null) && (tile.hasUnits() && !this.allowWalkthrough)) { - walkable = false; - + if (walkable && tile != null) { + if (tile.hasUnits() && !this.allowWalkthrough) { + walkable = false; + } } return walkable; @@ -630,10 +696,10 @@ public class Room implements Comparable, ISerialize, Runnable { } this.sendComposer(new UpdateStackHeightComposer(this, updatedTiles).compose()); this.updateTiles(updatedTiles); - updatedTiles.forEach(tile -> { + for (RoomTile tile : updatedTiles) { this.updateHabbosAt(tile.x, tile.y); this.updateBotsAt(tile.x, tile.y); - }); + } } else if (item.getBaseItem().getType() == FurnitureType.WALL) { this.sendComposer(new RemoveWallItemComposer(item).compose()); } @@ -692,9 +758,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.updateHabbosAt(x, y, this.getHabbosAt(x, y)); } - public void updateHabbosAt(short x, short y, List habbos) { + public void updateHabbosAt(short x, short y, THashSet habbos) { HabboItem item = this.getTopItemAt(x, y); + THashSet roomUnits = new THashSet<>(); for (Habbo habbo : habbos) { double oldZ = habbo.getRoomUnit().getZ(); @@ -723,19 +790,21 @@ public class Room implements Comparable, ISerialize, Runnable { if(habbo.getRoomUnit().getCurrentLocation().is(x, y) && (oldZ != z || updated || oldRotation != habbo.getRoomUnit().getBodyRotation())) { habbo.getRoomUnit().statusUpdate(true); + //roomUnits.add(habbo.getRoomUnit()); } } + + /*if (!roomUnits.isEmpty()) { + this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose()); + }*/ } public void updateBotsAt(short x, short y) { - if(this.layout == null) { - return; - } HabboItem topItem = this.getTopItemAt(x, y); THashSet roomUnits = new THashSet<>(); - this.getBotsAt(this.layout.getTile(x, y)).forEach(bot -> { + for (Bot bot : this.getBotsAt(this.layout.getTile(x, y))) { if (topItem != null) { if (topItem.getBaseItem().allowSit()) { bot.getRoomUnit().setZ(topItem.getZ()); @@ -752,8 +821,9 @@ public class Room implements Comparable, ISerialize, Runnable { bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); } + roomUnits.add(bot.getRoomUnit()); - }); + } if (!roomUnits.isEmpty()) { this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose()); @@ -890,7 +960,7 @@ public class Room implements Comparable, ISerialize, Runnable { botIterator.value().needsUpdate(true); Emulator.getThreading().run(botIterator.value()); } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -898,7 +968,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.currentBots.clear(); this.currentPets.clear(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -910,7 +980,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.preLoaded = true; this.layout = null; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -919,8 +989,8 @@ public class Room implements Comparable, ISerialize, Runnable { @Override public int compareTo(Room o) { - if (o.getUserCountWithoutInvisibleHabbos() != this.getUserCountWithoutInvisibleHabbos()) { - return o.getUserCountWithoutInvisibleHabbos() - this.getUserCountWithoutInvisibleHabbos(); + if (o.getUserCount() != this.getUserCount()) { + return o.getCurrentHabbos().size() - this.getCurrentHabbos().size(); } return this.id - o.id; @@ -938,7 +1008,7 @@ public class Room implements Comparable, ISerialize, Runnable { message.appendString(this.ownerName); } message.appendInt(this.state.getState()); - message.appendInt(this.getUserCountWithoutInvisibleHabbos()); + message.appendInt(this.getUserCount()); message.appendInt(this.usersMax); message.appendString(this.description); message.appendInt(0); @@ -993,13 +1063,15 @@ public class Room implements Comparable, ISerialize, Runnable { @Override public void run() { + long millis = System.currentTimeMillis(); + synchronized (this.loadLock) { if (this.loaded) { try { Emulator.getThreading().run( Room.this::cycle); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -1028,7 +1100,7 @@ public class Room implements Comparable, ISerialize, Runnable { int id = 1; for (RoomMoodlightData data : this.moodlightData.valueCollection()) { data.setId(id); - moodLightData.append(data).append(";"); + moodLightData.append(data.toString()).append(";"); id++; } @@ -1047,7 +1119,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(26, this.kickOption); statement.setInt(27, this.banOption); statement.setInt(28, this.pollId); - statement.setInt(29, this.guildId); + statement.setInt(29, this.guild); statement.setInt(30, this.rollerSpeed); statement.setString(31, this.overrideModel ? "1" : "0"); statement.setString(32, this.staffPromotedRoom ? "1" : "0"); @@ -1062,7 +1134,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.executeUpdate(); this.needsUpdate = false; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -1073,7 +1145,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, this.id); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -1090,8 +1162,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.tileCache.clear(); if (loaded) { if (!this.scheduledTasks.isEmpty()) { - ConcurrentHashMap.KeySetView tasks = this.scheduledTasks; - this.scheduledTasks = ConcurrentHashMap.newKeySet(); + ConcurrentSet tasks = this.scheduledTasks; + this.scheduledTasks = new ConcurrentSet<>(); for (Runnable runnable : tasks) { Emulator.getThreading().run(runnable); @@ -1117,11 +1189,9 @@ public class Room implements Comparable, ISerialize, Runnable { foundRightHolder[0] = habbo.getRoomUnit().getRightsLevel() != RoomRightLevels.NONE; } - /* Habbo doesn't remove the handitem anymore, checked on February 25 2023 - if (habbo.getRoomUnit().getHandItem() > 0 && millis - habbo.getRoomUnit().getHandItemTimestamp() > (Room.HAND_ITEM_TIME * 1000L)) { + if (habbo.getRoomUnit().getHandItem() > 0 && millis - habbo.getRoomUnit().getHandItemTimestamp() > (Room.HAND_ITEM_TIME * 1000)) { this.giveHandItem(habbo, 0); } - */ if (habbo.getRoomUnit().getEffectId() > 0 && millis / 1000 > habbo.getRoomUnit().getEffectEndTimestamp()) { this.giveEffect(habbo, 0, -1); @@ -1161,7 +1231,9 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting") && this.ownerId != habbo.getHabboInfo().getId()) { + if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting")) { + //Check if the user isn't the owner id + if (this.ownerId != habbo.getHabboInfo().getId()) { //Check if the time already have 1 minute (120 / 2 = 60s) if (habbo.getRoomUnit().getTimeInRoom() >= 120) { AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting")); @@ -1170,7 +1242,7 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().increaseTimeInRoom(); } } - + } if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().mutedBubbleTracker = false; @@ -1220,19 +1292,20 @@ public class Room implements Comparable, ISerialize, Runnable { } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } } - if (!this.currentPets.isEmpty() && this.allowBotsWalk) { + if (!this.currentPets.isEmpty()) { + if (this.allowBotsWalk) { TIntObjectIterator petIterator = this.currentPets.iterator(); for (int i = this.currentPets.size(); i-- > 0; ) { try { petIterator.advance(); } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -1253,6 +1326,7 @@ public class Room implements Comparable, ISerialize, Runnable { updatedUnit.add(pet.getRoomUnit()); } } + } } if (this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed) { @@ -1283,6 +1357,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } + // itemsOnRoller.addAll(this.getItemsAt(rollerTile)); itemsOnRoller.remove(roller); if (!rollerTile.hasUnits() && itemsOnRoller.isEmpty()) @@ -1308,10 +1383,15 @@ public class Room implements Comparable, ISerialize, Runnable { THashSet itemsNewTile = new THashSet<>(); itemsNewTile.addAll(getItemsAt(tileInFront)); itemsNewTile.removeAll(itemsOnRoller); - - itemsOnRoller.removeIf(item -> item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())); - - HabboItem topItem = Room.this.getTopItemAt(tileInFront.x, tileInFront.y); + + List toRemove = new ArrayList<>(); + for (HabboItem item : itemsOnRoller) { + if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId())) { + toRemove.add(item); + } + } + itemsOnRoller.removeAll(toRemove); + HabboItem topItem = Room.this.getTopItemAt(tileInFront.x, tileInFront.y); boolean allowUsers = true; boolean allowFurniture = true; @@ -1363,21 +1443,19 @@ public class Room implements Comparable, ISerialize, Runnable { if (unit.getRoomUnitType() == RoomUnitType.PET) { Pet pet = this.getPet(unit); if (pet instanceof RideablePet && ((RideablePet) pet).getRider() != null) { - break; + unitsOnTile.remove(unit); } } } + HabboItem nextTileChair = this.getTallestChair(tileInFront); + THashSet usersRolledThisTile = new THashSet<>(); for (RoomUnit unit : unitsOnTile) { if (rolledUnitIds.contains(unit.getId())) continue; - if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; - - if (unit.getRoomUnitType() == RoomUnitType.PET) { - break; - } + if(usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break; if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable())) continue; @@ -1385,10 +1463,11 @@ public class Room implements Comparable, ISerialize, Runnable { if (unit.hasStatus(RoomUnitStatus.MOVE)) continue; - double newZ = unit.getZ() + zOffset; + RoomTile tile = tileInFront.copy(); + tile.setStackHeight(unit.getZ() + zOffset); if (roomUserRolledEvent != null && unit.getRoomUnitType() == RoomUnitType.USER) { - roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tileInFront); + roomUserRolledEvent = new UserRolledEvent(getHabbo(unit), roller, tile); Emulator.getPluginManager().fireEvent(roomUserRolledEvent); if (roomUserRolledEvent.isCancelled()) @@ -1403,10 +1482,10 @@ public class Room implements Comparable, ISerialize, Runnable { RideablePet riding = rollingHabbo.getHabboInfo().getRiding(); if (riding != null) { RoomUnit ridingUnit = riding.getRoomUnit(); - newZ = ridingUnit.getZ() + zOffset; + tile.setStackHeight(ridingUnit.getZ() + zOffset); rolledUnitIds.add(ridingUnit.getId()); updatedUnit.remove(ridingUnit); - messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentLocation(), ridingUnit.getZ(), tileInFront, newZ, room)); + messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentLocation(), ridingUnit.getZ(), tile, tile.getStackHeight(), room)); isRiding = true; } } @@ -1415,7 +1494,8 @@ public class Room implements Comparable, ISerialize, Runnable { usersRolledThisTile.add(unit.getId()); rolledUnitIds.add(unit.getId()); updatedUnit.remove(unit); - messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tileInFront, newZ + (isRiding ? 1 : 0), room)); + messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, tile.getStackHeight() + (isRiding ? 1 : 0), room)); + if (itemsOnRoller.isEmpty()) { HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y); @@ -1425,7 +1505,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOn(unit, room, new Object[] { rollerTile, tileInFront }); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } }, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); @@ -1447,35 +1527,29 @@ public class Room implements Comparable, ISerialize, Runnable { if (allowFurniture || !stackContainsRoller || InteractionRoller.NO_RULES) { Event furnitureRolledEvent = null; - PluginManager pluginManager = Emulator.getPluginManager(); // Store the plugin manager - if (pluginManager.isRegistered(FurnitureRolledEvent.class, true)) { + if (Emulator.getPluginManager().isRegistered(FurnitureRolledEvent.class, true)) { furnitureRolledEvent = new FurnitureRolledEvent(null, null, null); } if (newRoller == null || topItem == newRoller) { List sortedItems = new ArrayList<>(itemsOnRoller); - sortedItems.sort((o1, o2) -> Double.compare(o2.getZ(), o1.getZ())); + sortedItems.sort((o1, o2) -> o1.getZ() > o2.getZ() ? -1 : 1); for (HabboItem item : sortedItems) { - if ((item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) && (item != roller)) { - if (furnitureRolledEvent != null) { - furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront); - pluginManager.fireEvent(furnitureRolledEvent); + if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) { + if (item != roller) { + if (furnitureRolledEvent != null) { + furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront); + Emulator.getPluginManager().fireEvent(furnitureRolledEvent); - if (furnitureRolledEvent.isCancelled()) { - continue; + if (furnitureRolledEvent.isCancelled()) + continue; } + + messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, room)); + rollerFurniIds.add(item.getId()); } - - final double currentZOffset = zOffset; - int delay = (getRollerSpeed() == 0) ? 250 : InteractionRoller.DELAY; // Calculate delay once - - Emulator.getThreading().run(() -> { - this.sendComposer(new FloorItemOnRollerComposer(item, roller, tileInFront, currentZOffset, room).compose()); - }, delay); - - rollerFurniIds.add(item.getId()); } } } @@ -1492,10 +1566,14 @@ public class Room implements Comparable, ISerialize, Runnable { return true; }); + int currentTime = (int) (this.cycleTimestamp / 1000); for (HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class)) { - if (pyramid instanceof InteractionPyramid interactionPyramid && interactionPyramid.getNextChange() < currentTime) { - interactionPyramid.change(this); + if (pyramid instanceof InteractionPyramid) { + + if (((InteractionPyramid) pyramid).getNextChange() < currentTime) { + ((InteractionPyramid) pyramid).change(this); + } } } } else { @@ -1518,12 +1596,19 @@ public class Room implements Comparable, ISerialize, Runnable { synchronized (this.habboQueue) { if (!this.habboQueue.isEmpty() && !foundRightHolder[0]) { - this.habboQueue.forEachEntry((a, b) -> { - if (b.isOnline() && b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { - b.getClient().sendResponse(new RoomAccessDeniedComposer("")); + this.habboQueue.forEachEntry(new TIntObjectProcedure() { + @Override + public boolean execute(int a, Habbo b) { + if (b.isOnline()) { + if (b.getHabboInfo().getRoomQueueId() == Room.this.getId()) { + b.getClient().sendResponse(new RoomAccessDeniedComposer("")); + } + } + + return true; } - return true; }); + this.habboQueue.clear(); } } @@ -1568,7 +1653,7 @@ public class Room implements Comparable, ISerialize, Runnable { } else if (thisTile.state == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate)) { this.dance(unit, DanceType.NONE); //int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z; - unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + ""); + unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + ""); unit.setZ(topItem.getZ()); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); unit.sitUpdate = false; @@ -1587,7 +1672,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { if (!unit.hasStatus(RoomUnitStatus.LAY)) { - unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) + ""); + unit.setStatus(RoomUnitStatus.LAY, Item.getCurrentHeight(topItem) * 1.0D + ""); unit.setRotation(RoomUserRotation.values()[topItem.getRotation() % 4]); if (topItem.getRotation() == 0 || topItem.getRotation() == 4) { @@ -1641,7 +1726,7 @@ public class Room implements Comparable, ISerialize, Runnable { } if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); if (guild != null) { guild.setRoomName(name); @@ -1796,20 +1881,20 @@ public class Room implements Comparable, ISerialize, Runnable { } public int getGuildId() { - return this.guildId; + return this.guild; } public boolean hasGuild() { - return this.guildId != 0; + return this.guild != 0; } - public void setGuildId(int guildId) { - this.guildId = guildId; + public void setGuild(int guild) { + this.guild = guild; } public String getGuildName() { if (this.hasGuild()) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); if (guild != null) { return guild.getName(); @@ -1943,6 +2028,10 @@ public class Room implements Comparable, ISerialize, Runnable { this.chatDistance = chatDistance; } + public void removeAllPets() { + removeAllPets(-1); + } + /** * Removes all pets from the room except if the owner id is excludeUserId * @@ -1959,7 +2048,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -2087,7 +2176,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(10, this.promotion.getCategory()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = true; @@ -2128,7 +2217,7 @@ public class Room implements Comparable, ISerialize, Runnable { game = gameType.getDeclaredConstructor(Room.class).newInstance(this); this.addGame(game); } catch (Exception e) { - log.error("Error getting game " + gameType.getName(), e); + LOGGER.error("Error getting game " + gameType.getName(), e); } } @@ -2142,18 +2231,6 @@ public class Room implements Comparable, ISerialize, Runnable { public int getUserCount() { return this.currentHabbos.size(); } - - /** - * Get all users but without the players that are invisible. - * - * @return the amount of visible players. - */ - public int getUserCountWithoutInvisibleHabbos() { - return (int) this.currentHabbos.values() - .stream() - .filter((habbo -> !habbo.getHabboInfo().isInvisibleInRooms())) - .count(); - } public ConcurrentHashMap getCurrentHabbos() { return this.currentHabbos; @@ -2205,7 +2282,7 @@ public class Room implements Comparable, ISerialize, Runnable { return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null; } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return true; @@ -2278,7 +2355,7 @@ public class Room implements Comparable, ISerialize, Runnable { if (habbo != null) { this.furniOwnerNames.put(item.getUserId(), habbo.getUsername()); } else { - log.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); + LOGGER.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId()); } } } @@ -2297,8 +2374,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addCondition((InteractionWiredCondition) item); } else if (item instanceof InteractionWiredExtra) { this.roomSpecialTypes.addExtra((InteractionWiredExtra) item); - } else if (item instanceof InteractionWiredHighscore) { - this.roomSpecialTypes.addHighscore((InteractionWiredHighscore) item); } else if (item instanceof InteractionBattleBanzaiTeleporter) { this.roomSpecialTypes.addBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item); } else if (item instanceof InteractionRoller) { @@ -2345,6 +2420,8 @@ public class Room implements Comparable, ISerialize, Runnable { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionBlackHole) { this.roomSpecialTypes.addUndefined(item); + } else if (item instanceof InteractionWiredHighscore) { + this.roomSpecialTypes.addUndefined(item); } else if (item instanceof InteractionStickyPole) { this.roomSpecialTypes.addUndefined(item); } else if (item instanceof WiredBlob) { @@ -2519,8 +2596,12 @@ public class Room implements Comparable, ISerialize, Runnable { if (iterator.value().getBaseItem().getType() == FurnitureType.FLOOR) items.add(iterator.value()); + } + + return items; + } public THashSet getWallItems() { @@ -2533,14 +2614,32 @@ public class Room implements Comparable, ISerialize, Runnable { } catch (Exception e) { break; } + if (iterator.value().getBaseItem().getType() == FurnitureType.WALL) items.add(iterator.value()); } + return items; + } - public List getPostItNotes() { - return roomItems.valueCollection().stream().filter(i -> i.getBaseItem().getInteractionType().getType() == InteractionPostIt.class).toList(); + public THashSet getPostItNotes() { + THashSet items = new THashSet<>(); + TIntObjectIterator iterator = this.roomItems.iterator(); + + for (int i = this.roomItems.size(); i-- > 0; ) { + try { + iterator.advance(); + } catch (Exception e) { + break; + } + + if (iterator.value().getBaseItem().getInteractionType().getType() == InteractionPostIt.class) + items.add(iterator.value()); + } + + return items; + } public void addHabbo(Habbo habbo) { @@ -2548,10 +2647,7 @@ public class Room implements Comparable, ISerialize, Runnable { habbo.getRoomUnit().setId(this.unitCounter); this.currentHabbos.put(habbo.getHabboInfo().getId(), habbo); this.unitCounter++; - // don't update the db if the user is invisible - if (!habbo.getHabboInfo().isInvisibleInRooms()) { - this.updateDatabaseUserCount(); - } + this.updateDatabaseUserCount(); } } @@ -2593,14 +2689,15 @@ public class Room implements Comparable, ISerialize, Runnable { try { item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } - if (habbo.getHabboInfo().getCurrentGame() != null && this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) { - this.getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); - + if (habbo.getHabboInfo().getCurrentGame() != null) { + if (this.getGame(habbo.getHabboInfo().getCurrentGame()) != null) { + this.getGame(habbo.getHabboInfo().getCurrentGame()).removeHabbo(habbo); + } } RoomTrade trade = this.getActiveTradeForHabbo(habbo); @@ -2649,7 +2746,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { iterator.advance(); } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2663,28 +2760,63 @@ public class Room implements Comparable, ISerialize, Runnable { public Bot getBotByRoomUnitId(int id) { synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getRoomUnit().getId() == id).findFirst().orElse(null); + TIntObjectIterator iterator = this.currentBots.iterator(); + + for (int i = this.currentBots.size(); i-- > 0; ) { + try { + iterator.advance(); + } catch (NoSuchElementException e) { + LOGGER.error("Caught exception", e); + break; + } + + if (iterator.value().getRoomUnit().getId() == id) + return iterator.value(); + } } + + return null; } public List getBots(String name) { + List bots = new ArrayList<>(); + synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getName().equalsIgnoreCase(name)).toList(); + TIntObjectIterator iterator = this.currentBots.iterator(); + + for (int i = this.currentBots.size(); i-- > 0; ) { + try { + iterator.advance(); + } catch (NoSuchElementException e) { + LOGGER.error("Caught exception", e); + break; + } + + if (iterator.value().getName().equalsIgnoreCase(name)) + bots.add(iterator.value()); + } } + + return bots; } public boolean hasBotsAt(final int x, final int y) { final boolean[] result = {false}; synchronized (this.currentBots) { - this.currentBots.forEachValue(object -> { - if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { - result[0] = true; - return false; + this.currentBots.forEachValue(new TObjectProcedure() { + @Override + public boolean execute(Bot object) { + if (object.getRoomUnit().getX() == x && object.getRoomUnit().getY() == y) { + result[0] = true; + return false; + } + + return true; } - return true; }); } + return result[0]; } @@ -2693,7 +2825,21 @@ public class Room implements Comparable, ISerialize, Runnable { } public Pet getPet(RoomUnit roomUnit) { - return currentPets.valueCollection().stream().filter(p -> p.getRoomUnit() == roomUnit).findFirst().orElse(null); + TIntObjectIterator petIterator = this.currentPets.iterator(); + + for (int i = this.currentPets.size(); i-- > 0; ) { + try { + petIterator.advance(); + } catch (NoSuchElementException e) { + LOGGER.error("Caught exception", e); + break; + } + + if (petIterator.value().getRoomUnit() == roomUnit) + return petIterator.value(); + } + + return null; } public boolean removeBot(Bot bot) { @@ -2749,7 +2895,11 @@ public class Room implements Comparable, ISerialize, Runnable { } public boolean hasHabbosAt(int x, int y) { - return getHabbos().stream().anyMatch(h -> h.getRoomUnit().getX() == x && h.getRoomUnit().getY() == y); + for (Habbo habbo : this.getHabbos()) { + if (habbo.getRoomUnit().getX() == x && habbo.getRoomUnit().getY() == y) + return true; + } + return false; } public boolean hasPetsAt(int x, int y) { @@ -2760,7 +2910,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { petIterator.advance(); } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } @@ -2772,24 +2922,40 @@ public class Room implements Comparable, ISerialize, Runnable { return false; } - public List getBotsAt(RoomTile tile) { + public THashSet getBotsAt(RoomTile tile) { + THashSet bots = new THashSet<>(); synchronized (this.currentBots) { - return currentBots.valueCollection().stream().filter(b -> b.getRoomUnit().getCurrentLocation().equals(tile)).toList(); + TIntObjectIterator botIterator = this.currentBots.iterator(); + + for (int i = this.currentBots.size(); i-- > 0; ) { + try { + botIterator.advance(); + + if (botIterator.value().getRoomUnit().getCurrentLocation().equals(tile)) { + bots.add(botIterator.value()); + } + } catch (Exception e) { + break; + } + } } + + return bots; } - public List getHabbosAt(short x, short y) { - if(this.layout == null) { - return new ArrayList<>(); - } + public THashSet getHabbosAt(short x, short y) { return this.getHabbosAt(this.layout.getTile(x, y)); } - public List getHabbosAt(RoomTile tile) { - if(this.layout == null) { - return new ArrayList<>(); + public THashSet getHabbosAt(RoomTile tile) { + THashSet habbos = new THashSet<>(); + + for (Habbo habbo : this.getHabbos()) { + if (habbo.getRoomUnit().getCurrentLocation().equals(tile)) + habbos.add(habbo); } - return getHabbos().stream().filter(h -> h.getRoomUnit().getCurrentLocation().equals(tile)).toList(); + + return habbos; } public THashSet getHabbosAndBotsAt(short x, short y) { @@ -2799,8 +2965,14 @@ public class Room implements Comparable, ISerialize, Runnable { public THashSet getHabbosAndBotsAt(RoomTile tile) { THashSet list = new THashSet<>(); - list.addAll(getBotsAt(tile).stream().map(Bot::getRoomUnit).toList()); - list.addAll(getHabbosAt(tile).stream().map(Habbo::getRoomUnit).toList()); + for (Bot bot : this.getBotsAt(tile)) { + list.add(bot.getRoomUnit()); + } + + for(Habbo habbo : this.getHabbosAt(tile)) + { + list.add(habbo.getRoomUnit()); + } return list; } @@ -2912,7 +3084,7 @@ public class Room implements Comparable, ISerialize, Runnable { try { doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{}); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -2932,16 +3104,23 @@ public class Room implements Comparable, ISerialize, Runnable { if (!habbo.getHabboStats().allowTalk()) return; + if (habbo.getRoomUnit().isInvisible() && Emulator.getConfig().getBoolean("invisible.prevent.chat", false)) { + if (!CommandHandler.handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { + habbo.whisper(Emulator.getTexts().getValue("invisible.prevent.chat.error")); + } + + return; + } + if (habbo.getHabboInfo().getCurrentRoom() != this) return; long millis = System.currentTimeMillis(); - - if (HABBO_CHAT_DELAY && millis - habbo.getHabboStats().lastChat < 750) { - return; - + if (HABBO_CHAT_DELAY) { + if (millis - habbo.getHabboStats().lastChat < 750) { + return; + } } - habbo.getHabboStats().lastChat = millis; if (roomChatMessage != null && Emulator.getConfig().getBoolean("easter_eggs.enabled") && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { habbo.getHabboStats().chatCounter.addAndGet(1); @@ -2952,8 +3131,10 @@ public class Room implements Comparable, ISerialize, Runnable { UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.TALKED, false); Emulator.getPluginManager().fireEvent(event); - if (!event.isCancelled() && !event.idle) { - this.unIdle(habbo); + if (!event.isCancelled()) { + if (!event.idle) { + this.unIdle(habbo); + } } this.sendComposer(new RoomUserTypingComposer(habbo.getRoomUnit(), false).compose()); @@ -2969,9 +3150,11 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!this.wordFilterWords.isEmpty() && !habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) { - for (String string : this.wordFilterWords) { - roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); + if (!this.wordFilterWords.isEmpty()) { + if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) { + for (String string : this.wordFilterWords) { + roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba")); + } } } @@ -2986,32 +3169,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FLOOD)) { - final int chatCounter = habbo.getHabboStats().chatCounter.addAndGet(1); - - if (chatCounter > 3) { - final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); - final boolean hasRights = this.hasRights(habbo); - - if (floodRights || !hasRights) { - this.floodMuteHabbo(habbo, muteTime); - return; - - /*if (this.chatProtection == 0) { - this.floodMuteHabbo(habbo, muteTime); - return; - } else if (this.chatProtection == 1 && chatCounter > 4) { - this.floodMuteHabbo(habbo, muteTime); - return; - } else if (this.chatProtection == 2 && chatCounter > 5) { - this.floodMuteHabbo(habbo, muteTime); - return; - }*/ - } - } - } - - if (chatType != RoomChatType.WHISPER) { + if (chatType != RoomChatType.WHISPER) { if (CommandHandler.handleCommand(habbo.getClient(), roomChatMessage.getUnfilteredMessage())) { WiredHandler.handle(WiredTriggerType.SAY_COMMAND, habbo.getRoomUnit(), habbo.getHabboInfo().getCurrentRoom(), new Object[]{roomChatMessage.getMessage()}); roomChatMessage.isCommand = true; @@ -3026,6 +3184,28 @@ public class Room implements Comparable, ISerialize, Runnable { } } + if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FLOOD)) { + final int chatCounter = habbo.getHabboStats().chatCounter.addAndGet(1); + + if (chatCounter > 3) { + final boolean floodRights = Emulator.getConfig().getBoolean("flood.with.rights"); + final boolean hasRights = this.hasRights(habbo); + + if (floodRights || !hasRights) { + if (this.chatProtection == 0) { + this.floodMuteHabbo(habbo, muteTime); + return; + } else if (this.chatProtection == 1 && chatCounter > 4) { + this.floodMuteHabbo(habbo, muteTime); + return; + } else if (this.chatProtection == 2 && chatCounter > 5) { + this.floodMuteHabbo(habbo, muteTime); + return; + } + } + } + } + ServerMessage prefixMessage = null; if (Emulator.getPluginManager().isRegistered(UsernameTalkEvent.class, true)) { @@ -3134,7 +3314,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.onUserSay(roomChatMessage); } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } } @@ -3166,7 +3346,7 @@ public class Room implements Comparable, ISerialize, Runnable { break; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -3207,7 +3387,14 @@ public class Room implements Comparable, ISerialize, Runnable { if (item.getBaseItem().getType() != FurnitureType.FLOOR) continue; - boolean found = lockedTiles.stream().anyMatch(tile -> tile.x == item.getX() && tile.y == item.getY()); + boolean found = false; + for (RoomTile tile : lockedTiles) { + if (tile.x == item.getX() && + tile.y == item.getY()) { + found = true; + break; + } + } if (!found) { if (item.getRotation() == 0 || item.getRotation() == 4) { @@ -3239,9 +3426,6 @@ public class Room implements Comparable, ISerialize, Runnable { @Deprecated public THashSet getItemsAt(int x, int y) { - if (this.getLayout() == null) { - return null; - } RoomTile tile = this.getLayout().getTile((short) x, (short) y); if (tile != null) { @@ -3394,11 +3578,23 @@ public class Room implements Comparable, ISerialize, Runnable { public double getTopHeightAt(int x, int y) { HabboItem item = this.getTopItemAt(x, y); - if (item != null) { - return (item.getZ() + Item.getCurrentHeight(item) - (item.getBaseItem().allowSit() ? 1 : 0)); - } else { + if (item != null) + return (item.getZ() + Item.getCurrentHeight(item)); + else return this.layout.getHeightAtSquare(x, y); + } + + @Deprecated + public HabboItem getLowestChair(int x, int y) { + if (this.layout == null) return null; + + RoomTile tile = this.layout.getTile((short) x, (short) y); + + if (tile != null) { + return this.getLowestChair(tile); } + + return null; } public HabboItem getLowestChair(RoomTile tile) { @@ -3471,6 +3667,12 @@ public class Room implements Comparable, ISerialize, Runnable { height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); } + /*HabboItem lowestChair = this.getLowestChair(x, y); + if (lowestChair != null && lowestChair != exclude) { + canStack = true; + height = lowestChair.getZ(); + }*/ + if (calculateHeightmap) { return (canStack ? height * 256.0D : Short.MAX_VALUE); } @@ -3592,7 +3794,7 @@ public class Room implements Comparable, ISerialize, Runnable { public Habbo getHabbo(String username) { for (Habbo habbo : this.getHabbos()) { - if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username) && !habbo.getHabboInfo().isInvisibleInRooms()) + if (habbo.getHabboInfo().getUsername().equalsIgnoreCase(username)) return habbo; } return null; @@ -3606,27 +3808,6 @@ public class Room implements Comparable, ISerialize, Runnable { return null; } - public HorsePet getHabboHorse(final RoomUnit roomUnit) { - final AtomicReference result = new AtomicReference<>(); - - this.currentPets.forEachEntry((i, pet) -> { - if (!(pet instanceof HorsePet)) { - return true; - } - - final HorsePet horsePet = (HorsePet) pet; - - if (horsePet.getRider() == null || horsePet.getRider().getRoomUnit() != roomUnit) { - return true; - } - - result.set((HorsePet) pet); - return false; - }); - - return result.get(); - } - public Habbo getHabbo(int userId) { return this.currentHabbos.get(userId); } @@ -3684,7 +3865,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3703,13 +3884,13 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } public RoomRightLevels getGuildRightLevel(Habbo habbo) { - if (this.guildId > 0 && habbo.getHabboStats().hasGuild(this.guildId)) { - Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId); + if (this.guild > 0 && habbo.getHabboStats().hasGuild(this.guild)) { + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guild); if (Emulator.getGameEnvironment().getGuildManager().getOnlyAdmins(guild).get(habbo.getHabboInfo().getId()) != null) return RoomRightLevels.GUILD_ADMIN; @@ -3754,7 +3935,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3791,7 +3972,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3814,7 +3995,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setInt(1, this.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.refreshRightsInRoom(); @@ -3874,7 +4055,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -3938,21 +4119,12 @@ public class Room implements Comparable, ISerialize, Runnable { } public void giveEffect(Habbo habbo, int effectId, int duration) { - if (habbo != null && habbo.getRoomUnit() != null && this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { - this.giveEffect(habbo.getRoomUnit(), effectId, duration, false); + if (this.currentHabbos.containsKey(habbo.getHabboInfo().getId())) { + this.giveEffect(habbo.getRoomUnit(), effectId, duration); } } public void giveEffect(RoomUnit roomUnit, int effectId, int duration) { - this.giveEffect(roomUnit, effectId, duration, false); - } - - public void giveEffect(RoomUnit roomUnit, int effectId, int duration, boolean ignoreChecks) { - if (roomUnit == null || roomUnit.getRoom() == null) return; - - Habbo habbo = roomUnit.getRoom().getHabbo(roomUnit); - - if (roomUnit.getRoomUnitType() == RoomUnitType.USER && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) { return; } if (duration == -1 || duration == Integer.MAX_VALUE) { duration = Integer.MAX_VALUE; } else { @@ -3975,15 +4147,16 @@ public class Room implements Comparable, ISerialize, Runnable { } public void updateItem(HabboItem item) { - if (!this.isLoaded()) { - return; - } - if (item != null && item.getRoomId() == this.id && item.getBaseItem() != null) { - if (item.getBaseItem().getType() == FurnitureType.FLOOR) { - this.sendComposer(new FloorItemUpdateComposer(item).compose()); - this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - } else if (item.getBaseItem().getType() == FurnitureType.WALL) { - this.sendComposer(new WallItemUpdateComposer(item).compose()); + if (this.isLoaded()) { + if (item != null && item.getRoomId() == this.id) { + if (item.getBaseItem() != null) { + if (item.getBaseItem().getType() == FurnitureType.FLOOR) { + this.sendComposer(new FloorItemUpdateComposer(item).compose()); + this.updateTiles(this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); + } else if (item.getBaseItem().getType() == FurnitureType.WALL) { + this.sendComposer(new WallItemUpdateComposer(item).compose()); + } + } } } } @@ -4136,11 +4309,14 @@ public class Room implements Comparable, ISerialize, Runnable { public void refreshGuildRightsInRoom() { for (Habbo habbo : this.getHabbos()) { - if ((habbo.getHabboInfo().getCurrentRoom() == this && habbo.getHabboInfo().getId() != this.ownerId) - && (!(habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_MOVEROTATE)))) + if (habbo.getHabboInfo().getCurrentRoom() == this) { + if (habbo.getHabboInfo().getId() != this.ownerId) { + if (!(habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_MOVEROTATE))) this.refreshRightsForHabbo(habbo); + } } } + } public void idle(Habbo habbo) { habbo.getRoomUnit().setIdle(); @@ -4189,7 +4365,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -4206,7 +4382,7 @@ public class Room implements Comparable, ISerialize, Runnable { statement.setString(2, word); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -4268,7 +4444,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.hideWired = hideWired; if (this.hideWired) { - + ServerMessage response = null; for (HabboItem item : this.roomSpecialTypes.getTriggers()) { this.sendComposer(new RemoveFloorItemComposer(item).compose()); } @@ -4472,7 +4648,7 @@ public class Room implements Comparable, ISerialize, Runnable { boolean magicTile = item instanceof InteractionStackHelper; - Optional stackHelper = this.getItemsAt(tile).stream().filter(InteractionStackHelper.class::isInstance).findAny(); + Optional stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny(); //Check if can be placed at new position THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); @@ -4480,17 +4656,12 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem topItem = this.getTopItemAt(occupiedTiles, null); - if ((!stackHelper.isPresent() && !pluginHelper) || item.getBaseItem().getInteractionType().getType() == InteractionWater.class) { + if (!stackHelper.isPresent() && !pluginHelper) { if (oldLocation != tile) { for (RoomTile t : occupiedTiles) { HabboItem tileTopItem = this.getTopItemAt(t.x, t.y); - if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || - !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack() || - (tileTopItem.getBaseItem().getInteractionType().getType() == InteractionWater.class && (item.getBaseItem().getInteractionType().getType() != InteractionWaterItem.class || - item.getBaseItem().getInteractionType().getType() == InteractionWater.class))) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)) || - stackHelper.isPresent() && item.getBaseItem().getInteractionType().getType() == InteractionWater.class)) { + if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID)))) return FurnitureMovementError.CANT_STACK; - } if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit() && !item.getBaseItem().allowLay())) { if (checkForUnits) { @@ -4512,10 +4683,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - THashSet oldOccupiedTiles = new THashSet<>(); - if(oldLocation != null) { - oldOccupiedTiles.addAll(this.layout.getTilesAt(oldLocation, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); - } + THashSet oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); int oldRotation = item.getRotation(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java index 8cb79b7..3765175 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomBan.java @@ -1,16 +1,18 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class RoomBan { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomBan.class); + public final int roomId; public final int userId; public final String username; @@ -38,7 +40,7 @@ public class RoomBan { statement.setInt(3, this.endTimestamp); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -49,7 +51,7 @@ public class RoomBan { statement.setInt(2, this.userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java index d90d83a..27fbec4 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java @@ -8,17 +8,19 @@ import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.incoming.MessageHandler; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Arrays; import java.util.List; -@Slf4j public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomChatMessage.class); private static final String QUERY = "INSERT INTO chatlogs_room (user_from_id, user_to_id, message, timestamp, room_id) VALUES (?, ?, ?, ?, ?)"; + private static final List chatColors = Arrays.asList("@red@", "@cyan@", "@blue@", "@green@", "@purple@"); public static int MAXIMUM_LENGTH = 100; //Configuration. Loaded from database & updated accordingly. @@ -35,11 +37,10 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { private RoomChatMessageBubbles bubble; private Habbo targetHabbo; private byte emotion; - private String RoomChatColour; //Added ChatColor - + private String RoomChatColour; + ; //Added ChatColor public RoomChatMessage(MessageHandler message) { - if (message.packet.getMessageId() == Incoming.RoomUserWhisperEvent) { String data = message.packet.readString(); this.targetHabbo = message.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(data.split(" ")[0]); @@ -47,14 +48,13 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { } else { this.message = message.packet.readString(); } - try { this.bubble = RoomChatMessageBubbles.getBubble(message.packet.readInt()); } catch (Exception e) { this.bubble = RoomChatMessageBubbles.NORMAL; } - this.RoomChatColour = message.packet.readString(); // Added for Room Chat Colour + this.RoomChatColour = message.packet.readString(); if (!message.client.getHabbo().hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { @@ -141,7 +141,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { try { this.message = this.message.substring(0, RoomChatMessage.MAXIMUM_LENGTH - 1); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -178,8 +178,6 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { @Override public void serialize(ServerMessage message) { - - if (this.habbo != null && this.bubble.isOverridable()) { if (!this.habbo.hasPermission(Permission.ACC_ANYCHATCOLOR)) { for (Integer i : RoomChatMessage.BANNED_BUBBLES) { @@ -203,11 +201,10 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { message.appendInt(this.getEmotion()); message.appendInt(this.getBubble().getType()); message.appendInt(0); - message.appendString(this.RoomChatColour); //Added packet for Room Chat Color + message.appendString(this.RoomChatColour); //Added packet for room chat message.appendInt(this.getMessage().length()); - } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -230,7 +227,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { if (muteTime > 0) { this.habbo.mute(muteTime, false); } else { - log.error("Invalid hotel.wordfilter.automute defined in emulator_settings ({}).", muteTime); + LOGGER.error("Invalid hotel.wordfilter.automute defined in emulator_settings ({}).", muteTime); } } @@ -264,4 +261,4 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable { statement.addBatch(); } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java index befeea8..31b7e90 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessageBubbles.java @@ -46,15 +46,7 @@ public enum RoomChatMessageBubbles { UNKNOWN_42(42, "", true, false), UNKNOWN_43(43, "", true, false), UNKNOWN_44(44, "", true, false), - UNKNOWN_45(45, "", true, false), - UNKNOWN_46(46, "", true, false), - UNKNOWN_47(47, "", true, false), - UNKNOWN_48(48, "", true, false), - UNKNOWN_49(49, "", true, false), - UNKNOWN_50(50, "", true, false), - UNKNOWN_51(51, "", true, false), - UNKNOWN_52(52, "", true, false), - UNKNOWN_53(53, "", true, false); + UNKNOWN_45(45, "", true, false); private final int type; private final String permission; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 2c488d1..7459e42 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -2,7 +2,8 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.sql.ResultSet; @@ -12,8 +13,8 @@ import java.util.Deque; import java.util.LinkedList; import java.util.List; -@Slf4j 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; @@ -44,7 +45,7 @@ public class RoomLayout { this.parse(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -280,6 +281,7 @@ public class RoomLayout { if (System.currentTimeMillis() - startMillis > Emulator.getConfig().getInt("pathfinder.execution_time.milli", 25) && Emulator.getConfig().getBoolean("pathfinder.max_execution_time.enabled", false)) { return null; } + RoomTile current = this.lowestFInOpen(openList); if (current.x == newTile.x && current.y == newTile.y) { return this.calcPath(this.findTile(openList, oldTile.x, oldTile.y), current); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 3947d21..3bf26bc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -48,20 +48,23 @@ import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; +import com.eu.habbo.plugin.events.users.UsernameTalkEvent; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -@Slf4j 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; @@ -91,7 +94,7 @@ public class RoomManager { registerGameType(IceTagGame.class); registerGameType(RollerskateGame.class); - log.info("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Room Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public void loadRoomModels() { @@ -101,7 +104,7 @@ public class RoomManager { this.mapNames.add(set.getString("name")); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -115,7 +118,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return layout; @@ -129,7 +132,7 @@ public class RoomManager { this.roomCategories.put(set.getInt("id"), new RoomCategory(set)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -145,14 +148,14 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } public THashMap> findRooms(NavigatorFilterField filterField, String value, int category, boolean showInvisible) { THashMap> rooms = new THashMap<>(); String query = filterField.databaseQuery + " AND rooms.state NOT LIKE " + (showInvisible ? "''" : "'invisible'") + (category >= 0 ? "AND rooms.category = '" + category + "'" : "") + " ORDER BY rooms.users, rooms.id DESC LIMIT " + (page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + "" + ((page * NavigatorManager.MAXIMUM_RESULTS_PER_PAGE) + NavigatorManager.MAXIMUM_RESULTS_PER_PAGE); - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) { statement.setString(1, (filterField.comparator == NavigatorFilterComparator.EQUALS ? value : "%" + value + "%")); try (ResultSet set = statement.executeQuery()) { while (set.next()) { @@ -171,7 +174,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -278,7 +281,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -323,7 +326,7 @@ public class RoomManager { this.activeRooms.put(room.getId(), room); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return room; @@ -348,7 +351,7 @@ public class RoomManager { room = this.loadRoom(set.getInt(1)); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return room; @@ -373,7 +376,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -423,7 +426,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return layout; @@ -457,7 +460,7 @@ public class RoomManager { statement.setInt(2, room.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -627,7 +630,7 @@ public class RoomManager { return; } - if (room.getUserCountWithoutInvisibleHabbos() >= room.getUsersMax() && !habbo.hasPermission(Permission.ACC_FULLROOMS) && !room.hasRights(habbo)) { + if (room.getUserCount() >= room.getUsersMax() && !habbo.hasPermission(Permission.ACC_FULLROOMS) && !room.hasRights(habbo)) { habbo.getClient().sendResponse(new RoomEnterErrorComposer(RoomEnterErrorComposer.ROOM_ERROR_GUESTROOM_FULL)); return; } @@ -716,6 +719,7 @@ public class RoomManager { habbo.getRoomUnit().setPathFinderRoom(room); habbo.getRoomUnit().resetIdleTimer(); + habbo.getRoomUnit().setInvisible(false); room.addHabbo(habbo); List habbos = new ArrayList<>(); @@ -730,19 +734,16 @@ public class RoomManager { visibleHabbos = event.visibleHabbos; } - // - if (!habbo.getHabboInfo().isInvisibleInRooms()) { - for (Habbo habboToSendEnter : habbosToSendEnter) { - GameClient client = habboToSendEnter.getClient(); - if (client != null) { - client.sendResponse(new RoomUsersComposer(habbo).compose()); - client.sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); - } + for (Habbo habboToSendEnter : habbosToSendEnter) { + GameClient client = habboToSendEnter.getClient(); + if (client != null) { + client.sendResponse(new RoomUsersComposer(habbo).compose()); + client.sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); } } for (Habbo h : visibleHabbos) { - if (!h.getHabboInfo().isInvisibleInRooms()) { + if (!h.getRoomUnit().isInvisible()) { habbos.add(h); } } @@ -934,7 +935,7 @@ public class RoomManager { if (!habbo.getHabboStats().visitedRoom(room.getId())) habbo.getHabboStats().addVisitRoom(room.getId()); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -987,7 +988,7 @@ public class RoomManager { statement.setInt(3, room.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -1023,7 +1024,7 @@ public class RoomManager { ArrayList rooms = new ArrayList<>(); for (Room room : this.activeRooms.values()) { - if (room.getUserCountWithoutInvisibleHabbos() > 0) { + if (room.getUserCount() > 0) { if (!room.isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB) rooms.add(room); } } @@ -1059,7 +1060,7 @@ public class RoomManager { Map> rooms = new HashMap<>(); for (Room room : this.activeRooms.values()) { - if (!room.isPublicRoom() && room.getUserCount() > 0) { /* Changed do not show rooms that are empty */ + if (!room.isPublicRoom()) { if (!rooms.containsKey(room.getCategory())) { rooms.put(room.getCategory(), new ArrayList<>()); } @@ -1116,7 +1117,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1176,7 +1177,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1242,7 +1243,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1288,7 +1289,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } Collections.sort(rooms); @@ -1311,7 +1312,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1325,10 +1326,6 @@ public class RoomManager { if (friend == null || friend.getHabboInfo() == null) continue; - if (friend.getHabboInfo().isInvisibleInRooms()) { - continue; - } - Room room = friend.getHabboInfo().getCurrentRoom(); if (room != null && !rooms.contains(room) && room.hasRights(habbo)) rooms.add(room); @@ -1357,7 +1354,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1379,7 +1376,7 @@ public class RoomManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return rooms; @@ -1483,7 +1480,7 @@ public class RoomManager { this.activeRooms.clear(); - log.info("Room Manager -> Disposed!"); + LOGGER.info("Room Manager -> Disposed!"); } public CustomRoomLayout insertCustomLayout(Room room, String map, int doorX, int doorY, int doorDirection) { @@ -1500,7 +1497,7 @@ public class RoomManager { statement.setString(10, map); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return this.loadCustomLayout(room); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java index 992db7f..f24e111 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomPromotion.java @@ -1,15 +1,16 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class RoomPromotion { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomPromotion.class); private final Room room; public boolean needsUpdate; private String title; @@ -45,7 +46,7 @@ public class RoomPromotion { statement.setInt(4, this.room.getId()); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.needsUpdate = false; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java index ff9667d..8a1a179 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomSpecialTypes.java @@ -44,7 +44,6 @@ public class RoomSpecialTypes { private final THashMap> wiredEffects; private final THashMap> wiredConditions; private final THashMap wiredExtras; - private final THashMap wiredHighscore; private final THashMap gameScoreboards; private final THashMap gameGates; @@ -66,7 +65,6 @@ public class RoomSpecialTypes { this.wiredEffects = new THashMap<>(0); this.wiredConditions = new THashMap<>(0); this.wiredExtras = new THashMap<>(0); - this.wiredHighscore = new THashMap<>(0); this.gameScoreboards = new THashMap<>(0); this.gameGates = new THashMap<>(0); @@ -461,24 +459,6 @@ public class RoomSpecialTypes { } } - public void addHighscore(InteractionWiredHighscore highscore) { - synchronized (this.wiredHighscore) { - this.wiredHighscore.put(highscore.getId(), highscore); - } - } - - public THashSet getWiredHighscores() { - synchronized (this.wiredHighscore) { - THashSet highscores = new THashSet<>(); - - for (Map.Entry map : this.wiredHighscore.entrySet()) { - highscores.add(map.getValue()); - } - - return highscores; - } - } - public boolean hasExtraType(short x, short y, Class type) { synchronized (this.wiredExtras) { for (Map.Entry map : this.wiredExtras.entrySet()) { @@ -491,6 +471,7 @@ public class RoomSpecialTypes { return false; } + public InteractionGameScoreboard getGameScorebord(int itemId) { return this.gameScoreboards.get(itemId); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java index c79e0fb..3fb4d46 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java @@ -12,14 +12,15 @@ import com.eu.habbo.plugin.events.furniture.FurnitureRedeemedEvent; import com.eu.habbo.plugin.events.trading.TradeConfirmEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.*; import java.util.ArrayList; import java.util.List; -@Slf4j 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; @@ -216,7 +217,7 @@ public class RoomTrade { statement.executeBatch(); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } THashSet itemsUserOne = new THashSet<>(userOne.getItems()); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 233c131..972030b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -715,6 +715,14 @@ public class RoomUnit { this.rightsLevel = rightsLevel; } + public boolean isInvisible() { + return this.invisible; + } + + public void setInvisible(boolean invisible) { + this.invisible = invisible; + } + public Room getRoom() { return room; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index e719bdf..ff0b143 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -18,7 +18,8 @@ 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 gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -28,10 +29,11 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -@Slf4j public class TraxManager implements Disposable { public static int NORMAL_JUKEBOX_LIMIT = 10; public static int LARGE_JUKEBOX_LIMIT = 20; + + private static final Logger LOGGER = LoggerFactory.getLogger(TraxManager.class); private final Room room; private InteractionJukeBox jukeBox; private final List songs = new ArrayList<>(0); @@ -85,7 +87,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return null; @@ -117,7 +119,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -128,7 +130,7 @@ public class TraxManager implements Disposable { statement.setInt(2, song_id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -142,7 +144,7 @@ public class TraxManager implements Disposable { statement_1.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -160,7 +162,7 @@ public class TraxManager implements Disposable { statement_1.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -262,7 +264,7 @@ public class TraxManager implements Disposable { statement.setInt(2, musicDisc.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } @@ -347,7 +349,7 @@ public class TraxManager implements Disposable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index dff68de..ddccb55 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -22,7 +22,6 @@ 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 lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,9 +31,10 @@ import java.sql.ResultSet; import java.util.*; import java.util.stream.Collectors; -@Slf4j 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; @@ -124,9 +124,7 @@ public class Habbo implements Runnable { SocketAddress address = this.client.getChannel().remoteAddress(); ip = ((InetSocketAddress) address).getAddress().getHostAddress(); ProxyIP = "- no proxy server used"; - } - else - { + } else { SocketAddress address = this.client.getChannel().remoteAddress(); ProxyIP = ((InetSocketAddress) address).getAddress().getHostAddress(); } @@ -156,12 +154,14 @@ public class Habbo implements Runnable { return false; } + this.habboInfo.setMachineID(this.client.getMachineId()); this.isOnline(true); + this.messenger.connectionChanged(this, true, false); Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); - log.info("{} logged in from IP {} using proxyserver {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin(), ProxyIP); - log.info("{} client MachineId = {}", this.habboInfo.getUsername(), this.client.getMachineId()); + LOGGER.info("{} logged in from IP {} using proxyserver {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin(), ProxyIP); + LOGGER.info("{} client MachineId = {}", this.habboInfo.getUsername(), this.client.getMachineId()); return true; } @@ -188,7 +188,7 @@ public class Habbo implements Runnable { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { @@ -204,13 +204,13 @@ public class Habbo implements Runnable { this.habboStats.dispose(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return; } finally { Emulator.getGameEnvironment().getRoomManager().unloadRoomsForHabbo(this); Emulator.getGameEnvironment().getHabboManager().removeHabbo(this); } - log.info("{} disconnected.", this.habboInfo.getUsername()); + LOGGER.info("{} disconnected.", this.habboInfo.getUsername()); this.client = null; } @@ -421,7 +421,7 @@ public class Habbo implements Runnable { public void mute(int seconds, boolean isFlood) { if (seconds <= 0) { - log.warn("Tried to mute user for {} seconds, which is invalid.", seconds); + LOGGER.warn("Tried to mute user for {} seconds, which is invalid.", seconds); return; } @@ -471,6 +471,7 @@ public class Habbo implements Runnable { newLog.put(ltdLog.getKey(), filteredTimestamps); } } + this.habboStats.ltdPurchaseLog = newLog; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java index 2db0cff..5903cdc 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboBadge.java @@ -1,11 +1,13 @@ package com.eu.habbo.habbohotel.users; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; -@Slf4j public class HabboBadge implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboBadge.class); private int id; private String code; private int slot; @@ -78,7 +80,7 @@ public class HabboBadge implements Runnable { this.needsUpdate = false; } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java index cda9ac3..8c16663 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java @@ -15,13 +15,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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.ArrayList; import java.util.List; -@Slf4j public class HabboInfo implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(HabboInfo.class); + public boolean firstVisit = false; private String username; private String motto; @@ -53,7 +57,7 @@ public class HabboInfo implements Runnable { private String machineID; private List savedSearches = new ArrayList<>(); private List messengerCategories = new ArrayList<>(); - private Boolean isInvisibleInRooms = false; + public HabboInfo(ResultSet set) { try { this.id = set.getInt("id"); @@ -68,8 +72,8 @@ public class HabboInfo implements Runnable { this.rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(set.getInt("rank")); if (this.rank == null) { - log.error("No existing rank found with id " + set.getInt("rank") + ". Make sure an entry in the permissions table exists."); - log.warn(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); } @@ -81,7 +85,7 @@ public class HabboInfo implements Runnable { this.online = false; this.currentRoom = null; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.loadCurrencies(); @@ -100,7 +104,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -116,14 +120,14 @@ public class HabboInfo implements Runnable { statement.setInt(4, b); statement.addBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return true; } }); statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -138,7 +142,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -163,7 +167,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -174,7 +178,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, search.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -189,7 +193,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -213,7 +217,7 @@ public class HabboInfo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -224,7 +228,7 @@ public class HabboInfo implements Runnable { statement.setInt(1, category.getId()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -549,7 +553,7 @@ public class HabboInfo implements Runnable { statement.setInt(13, this.id); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -565,12 +569,4 @@ public class HabboInfo implements Runnable { return HabboStats.load(this); } - - public Boolean isInvisibleInRooms() { - return this.isInvisibleInRooms; - } - - public void toggleInvisibility() { - this.isInvisibleInRooms = !this.isInvisibleInRooms; - } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java index 1b42330..7eaf048 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java @@ -5,10 +5,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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; @@ -25,37 +28,37 @@ public class HabboInventory { try { this.badgesComponent = new BadgesComponent(this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.botsComponent = new BotsComponent(this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.effectsComponent = new EffectsComponent(this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.itemsComponent = new ItemsComponent(this, this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.petsComponent = new PetsComponent(this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } try { this.wardrobeComponent = new WardrobeComponent(this.habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } this.items = MarketPlace.getOwnOffers(this.habbo); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java index 5d6f596..31f98ca 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java @@ -21,7 +21,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.awt.*; import java.sql.Connection; import java.sql.PreparedStatement; @@ -30,9 +32,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -@Slf4j + 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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -266,15 +270,15 @@ public abstract class HabboItem implements Runnable, IEventTriggers { statement.setInt(10, this.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); - log.error("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java index 4bff088..e8bf5f3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java @@ -13,7 +13,9 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -24,10 +26,13 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -@Slf4j 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; private final ConcurrentHashMap onlineHabbos; @@ -36,7 +41,7 @@ public class HabboManager { this.onlineHabbos = new ConcurrentHashMap<>(); - log.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); + LOGGER.info("Habbo Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); } public static HabboInfo getOfflineHabboInfo(int id) { @@ -49,7 +54,7 @@ public class HabboManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return info; @@ -67,7 +72,7 @@ public class HabboManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return info; @@ -110,7 +115,7 @@ public class HabboManager { } statement.close(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } habbo = this.cloneCheck(userId); @@ -125,6 +130,7 @@ public class HabboManager { return null; } + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE auth_ticket = ? LIMIT 1")) { statement.setString(1, sso); @@ -137,22 +143,20 @@ public class HabboManager { } if (!Emulator.debugging) { - - try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE id = ? LIMIT 1")) { - stmt.setString(1, ""); - stmt.setInt(2, habbo.getHabboInfo().getId()); - stmt.execute(); - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } + try (PreparedStatement stmt = connection.prepareStatement("UPDATE users SET auth_ticket = ? WHERE id = ? LIMIT 1")) { + stmt.setString(1, ""); + stmt.setInt(2, habbo.getHabboInfo().getId()); + stmt.execute(); + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } } } } - } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (Exception ex) { - log.error("Caught exception", ex); + LOGGER.error("Caught exception", ex); } return habbo; @@ -193,7 +197,7 @@ public class HabboManager { // - log.info("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return habboInfo; @@ -229,7 +233,7 @@ public class HabboManager { } } } catch (SQLException e) { - log.error("Caught SQL exception", 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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -300,7 +304,7 @@ public class HabboManager { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java index 26b8958..36c1c97 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboNavigatorWindowSettings.java @@ -4,15 +4,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -@Slf4j 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; @@ -54,7 +56,7 @@ public class HabboNavigatorWindowSettings { statement.setString(4, displayMode.name().toLowerCase()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.displayModes.put(category, new HabboNavigatorPersonalDisplayMode(listMode, displayMode)); @@ -115,7 +117,7 @@ public class HabboNavigatorWindowSettings { statement.execute(); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 8a1f9bb..29ef2a2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -19,14 +19,18 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.set.hash.THashSet; import gnu.trove.stack.array.TIntArrayStack; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Constructor; import java.sql.*; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; -@Slf4j 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; @@ -98,7 +102,7 @@ public class HabboStats implements Runnable { public THashSet subscriptions; private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException { - this.cache = new THashMap<>(10000); + this.cache = new THashMap<>(1000); this.achievementProgress = new THashMap<>(0); this.achievementCache = new THashMap<>(0); this.recentPurchases = new THashMap<>(0); @@ -253,7 +257,7 @@ public class HabboStats implements Runnable { statement.setInt(1, habboInfo.getId()); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return load(habboInfo); @@ -312,7 +316,7 @@ public class HabboStats implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return stats; @@ -396,7 +400,7 @@ public class HabboStats implements Runnable { this.navigatorWindowSettings.save(connection); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -519,12 +523,12 @@ public class HabboStats implements Runnable { return sub; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -607,7 +611,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.favoriteRooms.add(roomId); @@ -621,7 +625,7 @@ public class HabboStats implements Runnable { statement.setInt(2, roomId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -651,7 +655,7 @@ public class HabboStats implements Runnable { statement.setInt(2, id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.secretRecipes.add(id); @@ -756,7 +760,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -773,7 +777,7 @@ public class HabboStats implements Runnable { statement.setInt(2, userId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java index 9ea6991..e359175 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/cache/HabboOfferPurchase.java @@ -2,14 +2,16 @@ package com.eu.habbo.habbohotel.users.cache; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class HabboOfferPurchase { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboOfferPurchase.class); private final int userId; private final int offerId; private int state; @@ -39,7 +41,7 @@ public class HabboOfferPurchase { statement.setInt(2, offerId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return null; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java index 9565465..4e47065 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/clothingvalidation/ClothingValidationManager.java @@ -4,14 +4,16 @@ import com.eu.habbo.habbohotel.users.Habbo; import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.TIntHashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.regex.Pattern; -@Slf4j public class ClothingValidationManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ClothingValidationManager.class); + public static String FIGUREDATA_URL = ""; public static boolean VALIDATE_ON_HC_EXPIRE = false; public static boolean VALIDATE_ON_LOGIN = false; @@ -36,7 +38,7 @@ public class ClothingValidationManager { VALIDATE_ON_MIMIC = false; VALIDATE_ON_MANNEQUIN = false; VALIDATE_ON_FBALLGATE = false; - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -202,7 +204,7 @@ public class ClothingValidationManager { } } catch (Exception e) { //habbo.alert(e.getMessage()); - log.error("Error in clothing validation", e); + LOGGER.error("Error in clothing validation", e); } }); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java index c109e3c..49f3013 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BadgesComponent.java @@ -5,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,8 +16,8 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Set; -@Slf4j public class BadgesComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(BadgesComponent.class); private final THashSet badges = new THashSet<>(); @@ -54,7 +55,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return badgesList; @@ -81,7 +82,7 @@ public class BadgesComponent { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return badgesList; } @@ -99,7 +100,7 @@ public class BadgesComponent { statement.setString(2, badge); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java index d2cd0bd..cf9097b 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/BotsComponent.java @@ -4,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -12,8 +13,9 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; -@Slf4j public class BotsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(BotsComponent.class); + private final THashMap bots = new THashMap<>(); public BotsComponent(Habbo habbo) { @@ -33,7 +35,7 @@ public class BotsComponent { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java index 00fe828..99bff77 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java @@ -6,14 +6,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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) { - log.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) { - log.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) { - log.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) { - log.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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java index 8d2e14e..613868c 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/ItemsComponent.java @@ -15,17 +15,22 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.NoSuchElementException; -@Slf4j public class ItemsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(ItemsComponent.class); + private final TIntObjectMap items = TCollections.synchronizedMap(new TIntObjectHashMap<>()); + private final HabboInventory inventory; + public ItemsComponent(HabboInventory inventory, Habbo habbo) { this.inventory = inventory; this.items.putAll(loadItems(habbo)); @@ -45,15 +50,15 @@ public class ItemsComponent { if (item != null) { itemsList.put(set.getInt("id"), item); } else { - log.error("Failed to load HabboItem: " + set.getInt("id")); + LOGGER.error("Failed to load HabboItem: " + set.getInt("id")); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return itemsList; @@ -149,7 +154,7 @@ public class ItemsComponent { TIntObjectIterator items = this.items.iterator(); if (items == null) { - log.error("Items is NULL!"); + LOGGER.error("Items is NULL!"); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java index 222b896..cd96329 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/PetsComponent.java @@ -8,7 +8,9 @@ import gnu.trove.TCollections; import gnu.trove.iterator.TIntObjectIterator; import gnu.trove.map.TIntObjectMap; import gnu.trove.map.hash.TIntObjectHashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -16,8 +18,8 @@ import java.sql.SQLException; import java.util.NoSuchElementException; import java.util.Set; -@Slf4j public class PetsComponent { + private static final Logger LOGGER = LoggerFactory.getLogger(PetsComponent.class); private final TIntObjectMap pets = TCollections.synchronizedMap(new TIntObjectHashMap<>()); public PetsComponent(Habbo habbo) { @@ -35,7 +37,7 @@ public class PetsComponent { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java index 6f041d3..cd806c2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/inventory/WardrobeComponent.java @@ -7,7 +7,8 @@ import gnu.trove.TIntCollection; import gnu.trove.map.hash.THashMap; import gnu.trove.set.TIntSet; import gnu.trove.set.hash.TIntHashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,9 +16,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.regex.Pattern; -@Slf4j public class WardrobeComponent { - + private static final Logger LOGGER = LoggerFactory.getLogger(WardrobeComponent.class); private final THashMap looks; private final TIntSet clothing; private final TIntSet clothingSets; @@ -54,7 +54,7 @@ public class WardrobeComponent { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -82,7 +82,7 @@ public class WardrobeComponent { this.looks.clear(); } -public class WardrobeItem implements Runnable { + public class WardrobeItem implements Runnable { private int slotId; private HabboGender gender; private Habbo habbo; @@ -165,7 +165,7 @@ public class WardrobeItem implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java index 12fab80..08fba03 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/Subscription.java @@ -1,13 +1,14 @@ package com.eu.habbo.habbohotel.users.subscriptions; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j +/** + * @author Beny + */ public class Subscription { public static final String HABBO_CLUB = "HABBO_CLUB"; @@ -78,7 +79,7 @@ public class Subscription { statement.executeUpdate(); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + SubscriptionManager.LOGGER.error("Caught SQL exception", e); } } @@ -96,7 +97,7 @@ public class Subscription { statement.executeUpdate(); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + SubscriptionManager.LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java index d8770b6..defd6e3 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java @@ -15,7 +15,8 @@ import com.eu.habbo.messages.outgoing.generic.PickMonthlyClubGiftNotificationCom import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer; import com.eu.habbo.messages.outgoing.users.*; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -26,8 +27,11 @@ import java.util.Date; import java.util.Map; import java.util.TreeMap; -@Slf4j +/** + * @author Beny + */ public class SubscriptionHabboClub extends Subscription { + private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionHabboClub.class); public static boolean HC_PAYDAY_ENABLED = false; public static int HC_PAYDAY_NEXT_DATE = Integer.MAX_VALUE; // yyyy-MM-dd HH:mm:ss @@ -226,7 +230,7 @@ public class SubscriptionHabboClub extends Subscription { } } catch (SQLException e) { - log.error("Caught SQL exception", e); + SubscriptionManager.LOGGER.error("Caught SQL exception", e); } creditRewardForMonthlySpent = (int) Math.floor(totalCreditsSpent * HC_PAYDAY_KICKBACK_PERCENTAGE); @@ -275,7 +279,7 @@ public class SubscriptionHabboClub extends Subscription { stats.lastHCPayday = timestampNow; Emulator.getThreading().run(stats); } catch (Exception e) { - log.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); + SubscriptionManager.LOGGER.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); } } } @@ -299,7 +303,7 @@ public class SubscriptionHabboClub extends Subscription { } } catch (SQLException e) { - log.error("Caught SQL exception", e); + SubscriptionManager.LOGGER.error("Caught SQL exception", e); } isExecuting = false; } @@ -336,13 +340,13 @@ public class SubscriptionHabboClub extends Subscription { } } } catch (Exception e) { - log.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); + SubscriptionManager.LOGGER.error("Exception processing HC payday for user #" + set.getInt("user_id"), e); } } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + SubscriptionManager.LOGGER.error("Caught SQL exception", e); } } @@ -394,7 +398,7 @@ public class SubscriptionHabboClub extends Subscription { pointCurrency = Integer.parseInt(currency); } catch (NumberFormatException ex) { - log.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); + LOGGER.error("Couldn't convert the type point currency {} on HC PayDay. The number must be a integer and positive.", pointCurrency); } if (pointCurrency >= 0) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java index 071128e..b39d9d5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionManager.java @@ -3,7 +3,8 @@ package com.eu.habbo.habbohotel.users.subscriptions; import com.eu.habbo.Emulator; import gnu.trove.map.hash.THashMap; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -12,9 +13,13 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j +/** + * @author Beny + */ public class SubscriptionManager { + public static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionManager.class); + public THashMap> types; public SubscriptionManager() { @@ -39,7 +44,7 @@ public class SubscriptionManager { public Class getSubscriptionClass(String type) { if(!this.types.containsKey(type)) { - log.debug("Can't find subscription class: {}", type); + LOGGER.debug("Can't find subscription class: {}", type); return Subscription.class; } @@ -66,17 +71,17 @@ public class SubscriptionManager { subscriptions.add(subscription); } } catch (IllegalAccessException e) { - log.error("IllegalAccessException", e); + LOGGER.error("IllegalAccessException", e); } catch (InstantiationException e) { - log.error("InstantiationException", e); + LOGGER.error("InstantiationException", e); } catch (InvocationTargetException e) { - log.error("InvocationTargetException", e); + LOGGER.error("InvocationTargetException", e); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } catch (NoSuchMethodException e) { - log.error("Caught NoSuchMethodException", e); + LOGGER.error("Caught NoSuchMethodException", e); } return subscriptions; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java index 0d474e6..9f18a44 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionScheduler.java @@ -4,13 +4,18 @@ import com.eu.habbo.Emulator; import com.eu.habbo.core.Scheduler; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.plugin.events.users.subscriptions.UserSubscriptionExpiredEvent; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; -@Slf4j +/** + * @author Beny + */ public class SubscriptionScheduler extends Scheduler { + private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionScheduler.class); + public SubscriptionScheduler() { super(Emulator.getConfig().getInt("subscriptions.scheduler.interval", 10)); this.reloadConfig(); @@ -50,7 +55,7 @@ public class SubscriptionScheduler extends Scheduler { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java index bb48b94..955cf26 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/WiredHandler.java @@ -29,7 +29,8 @@ import com.eu.habbo.plugin.events.furniture.wired.WiredStackTriggeredEvent; import com.eu.habbo.plugin.events.users.UserWiredRewardReceived; import com.google.gson.GsonBuilder; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -39,8 +40,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -@Slf4j 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; @@ -237,7 +239,7 @@ public class WiredHandler { if (!effect.execute(roomUnit, room, stuff)) return; effect.setCooldown(millis); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } effect.activateBox(room, roomUnit, millis); @@ -279,7 +281,7 @@ public class WiredHandler { statement.setInt(1, wiredId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } @@ -294,7 +296,7 @@ public class WiredHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (reward.badge) { @@ -451,7 +453,7 @@ public class WiredHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return false; diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java index 4cf262c..e063d05 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java @@ -9,7 +9,7 @@ import java.util.stream.Collectors; public class WiredHighscoreDataEntry { private final int itemId; private final List userIds; - private int score; + private final int score; private final boolean isWin; private final int timestamp; @@ -41,10 +41,6 @@ public class WiredHighscoreDataEntry { return score; } - public void setScore(int score) { - this.score = score; - } - public boolean isWin() { return isWin; } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 8e19ff6..d1769ac 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -1,7 +1,11 @@ package com.eu.habbo.habbohotel.wired.highscores; import com.eu.habbo.Emulator; -import lombok.extern.slf4j.Slf4j; +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; import java.sql.ResultSet; @@ -10,11 +14,14 @@ import java.time.*; import java.time.temporal.TemporalAdjusters; import java.time.temporal.WeekFields; import java.util.*; +import java.util.concurrent.ScheduledFuture; import java.util.stream.Collectors; import java.util.stream.Stream; -@Slf4j public class WiredHighscoreManager { + private static final Logger LOGGER = LoggerFactory.getLogger(WiredHighscoreManager.class); + + private final HashMap> data = new HashMap<>(); private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en"); private final static String country = (System.getProperty("user.country") != null ? System.getProperty("user.country") : "US"); @@ -23,11 +30,59 @@ public class WiredHighscoreManager { private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1); private final static ZoneId zoneId = ZoneId.systemDefault(); + public static ScheduledFuture midnightUpdater = null; + public void load() { - log.info("Highscore Manager -> Loaded"); + long millis = System.currentTimeMillis(); + + this.data.clear(); + this.loadHighscoreData(); + + LOGGER.info("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)"); + } + + @EventHandler + public static void onEmulatorLoaded(EmulatorLoadedEvent event) { + if (midnightUpdater != null) { + midnightUpdater.cancel(true); + } + + midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), WiredHighscoreMidnightUpdater.getNextUpdaterRun()); + } + + public void dispose() { + if (midnightUpdater != null) { + midnightUpdater.cancel(true); + } + + this.data.clear(); + } + + private void loadHighscoreData() { + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_highscore_data")) { + try (ResultSet set = statement.executeQuery()) { + while (set.next()) { + WiredHighscoreDataEntry entry = new WiredHighscoreDataEntry(set); + + if (!this.data.containsKey(entry.getItemId())) { + this.data.put(entry.getItemId(), new ArrayList<>()); + } + + this.data.get(entry.getItemId()).add(entry); + } + } + } catch (SQLException e) { + LOGGER.error("Caught SQL exception", e); + } } public void addHighscoreData(WiredHighscoreDataEntry entry) { + if (!this.data.containsKey(entry.getItemId())) { + this.data.put(entry.getItemId(), new ArrayList<>()); + } + + this.data.get(entry.getItemId()).add(entry); + try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `items_highscore_data` (`item_id`, `user_ids`, `score`, `is_win`, `timestamp`) VALUES (?, ?, ?, ?, ?)")) { statement.setInt(1, entry.getItemId()); statement.setString(2, String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList()))); @@ -37,115 +92,14 @@ public class WiredHighscoreManager { statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } - public void addOrUpdateHighscoreData(WiredHighscoreDataEntry entry) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - final String userIds = String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList())); - - // Select existing - try (PreparedStatement selectScore = connection.prepareStatement("SELECT `id` FROM `items_highscore_data` WHERE `item_id` = ? AND `user_ids` = ? LIMIT 1")) { - selectScore.setInt(1, entry.getItemId()); - selectScore.setString(2, userIds); - - try (final ResultSet scoreResult = selectScore.executeQuery()) { - if (scoreResult.next()) { - // Update - try (PreparedStatement statement = connection.prepareStatement("UPDATE `items_highscore_data` SET `score` = `score` + ? WHERE `id` = ?")) { - statement.setInt(1, entry.getScore()); - statement.setInt(2, scoreResult.getInt("id")); - statement.execute(); - } - } else { - // Insert - addHighscoreData(entry); - } - } - } - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - } - - public void setHighscoreData(WiredHighscoreDataEntry entry) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - final String userIds = String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList())); - - // Select existing - try (PreparedStatement selectScore = connection.prepareStatement("SELECT `id` FROM `items_highscore_data` WHERE `item_id` = ? AND `user_ids` = ? LIMIT 1")) { - selectScore.setInt(1, entry.getItemId()); - selectScore.setString(2, userIds); - - try (final ResultSet scoreResult = selectScore.executeQuery()) { - if (scoreResult.next()) { - // Set - try (PreparedStatement statement = connection.prepareStatement("UPDATE `items_highscore_data` SET `score` = ? WHERE `id` = ?")) { - statement.setInt(1, entry.getScore()); - statement.setInt(2, scoreResult.getInt("id")); - statement.execute(); - } - } else { - // Insert - addHighscoreData(entry); - } - } - } - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - } - - private List loadHighscoreData(final int itemId) { - final List result = new ArrayList<>(); - - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); - PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_highscore_data WHERE `item_id` = ?")) { - statement.setInt(1, itemId); - - try (final ResultSet set = statement.executeQuery()) { - while (set.next()) { - result.add(new WiredHighscoreDataEntry(set)); - } - } - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - - return result; - } - - public WiredHighscoreDataEntry getHighscoreRow(final int itemId, final List userIds) { - try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) { - final String userIdsStr = String.join(",", userIds.stream().map(Object::toString).collect(Collectors.toList())); - - // Select existing - try (PreparedStatement selectScore = connection.prepareStatement("SELECT * FROM `items_highscore_data` WHERE `item_id` = ? AND `user_ids` = ? LIMIT 1")) { - selectScore.setInt(1, itemId); - selectScore.setString(2, userIdsStr); - - try (final ResultSet scoreResult = selectScore.executeQuery()) { - if (scoreResult.next()) { - return new WiredHighscoreDataEntry(scoreResult); - } - } - } - } catch (SQLException e) { - log.error("Caught SQL exception", e); - } - - return null; - } - public List getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) { - final List highscoreData = this.loadHighscoreData(itemId); + if (!this.data.containsKey(itemId)) return null; - if (highscoreData.size() == 0) { - return null; - } - - Stream highscores = new ArrayList<>(highscoreData).stream() + Stream highscores = new ArrayList<>(this.data.get(itemId)).stream() .filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin())) .map(entry -> new WiredHighscoreRow( entry.getUserIds().stream() @@ -155,10 +109,7 @@ public class WiredHighscoreManager { )); if (scoreType == WiredHighscoreScoreType.CLASSIC) { - return highscores - .filter(Objects::nonNull) // Filter out any null rows (in case of null usernames) - .sorted(WiredHighscoreRow::compareTo) - .collect(Collectors.toList()); + return highscores.sorted(WiredHighscoreRow::compareTo).collect(Collectors.toList()); } if (scoreType == WiredHighscoreScoreType.PERTEAM) { @@ -203,6 +154,18 @@ public class WiredHighscoreManager { return false; } + public HashMap> getData() { + return this.data; + } + + public List getEntriesForItemId(int itemId) { + return this.data.get(itemId); + } + + public void setEntriesForItemId(int itemId, List entries) { + this.data.put(itemId, entries); + } + private long getTodayStartTimestamp() { return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond(); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java new file mode 100644 index 0000000..7b60b22 --- /dev/null +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java @@ -0,0 +1,35 @@ +package com.eu.habbo.habbohotel.wired.highscores; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.HabboItem; +import gnu.trove.set.hash.THashSet; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.List; + +public class WiredHighscoreMidnightUpdater implements Runnable { + @Override + public void run() { + List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms(); + + for (Room room : rooms) { + if (room == null || room.getRoomSpecialTypes() == null) continue; + + THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class); + for (HabboItem item : items) { + ((InteractionWiredHighscore) item).reloadData(); + room.updateItem(item); + } + } + + WiredHighscoreManager.midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), getNextUpdaterRun()); + } + + public static int getNextUpdaterRun() { + return Math.toIntExact(LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).atZone(ZoneId.systemDefault()).toEpochSecond() - Emulator.getIntUnixTimestamp()) + 5; + } +} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java b/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java index 123fe9a..fdc3c99 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -35,9 +35,9 @@ import com.eu.habbo.messages.incoming.helper.RequestTalentTrackEvent; import com.eu.habbo.messages.incoming.hotelview.*; import com.eu.habbo.messages.incoming.inventory.RequestInventoryBadgesEvent; import com.eu.habbo.messages.incoming.inventory.RequestInventoryBotsEvent; +import com.eu.habbo.messages.incoming.inventory.RequestInventoryItemsDelete; import com.eu.habbo.messages.incoming.inventory.RequestInventoryItemsEvent; import com.eu.habbo.messages.incoming.inventory.RequestInventoryPetsEvent; -import com.eu.habbo.messages.incoming.inventory.RequestInventoryItemsDelete; import com.eu.habbo.messages.incoming.modtool.*; import com.eu.habbo.messages.incoming.navigator.*; import com.eu.habbo.messages.incoming.polls.AnswerPollEvent; @@ -72,12 +72,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.List; -@Slf4j 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; @@ -173,7 +177,7 @@ public class PacketManager { if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) { if (DEBUG_SHOW_PACKETS) { - log.warn("Client packet {} requires an authenticated session.", packet.getMessageId()); + LOGGER.warn("Client packet {} requires an authenticated session.", packet.getMessageId()); } return; @@ -184,7 +188,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) { - log.warn("Client packet {} was ratelimited.", packet.getMessageId()); + LOGGER.warn("Client packet {} was ratelimited.", packet.getMessageId()); } return; @@ -194,7 +198,7 @@ public class PacketManager { } if (logList.contains(packet.getMessageId()) && client.getHabbo() != null) { - log.info("User {} sent packet {} with body {}", 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; @@ -211,7 +215,7 @@ public class PacketManager { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -283,7 +287,6 @@ public class PacketManager { this.registerHandler(Incoming.AcceptFriendRequest, AcceptFriendRequestEvent.class); this.registerHandler(Incoming.DeclineFriendRequest, DeclineFriendRequestEvent.class); this.registerHandler(Incoming.FriendPrivateMessageEvent, FriendPrivateMessageEvent.class); - this.registerHandler(Incoming.FriendListUpdateEvent, FriendListUpdateEvent.class); this.registerHandler(Incoming.RequestFriendRequestEvent, RequestFriendRequestsEvent.class); this.registerHandler(Incoming.StalkFriendEvent, StalkFriendEvent.class); this.registerHandler(Incoming.RequestInitFriendsEvent, RequestInitFriendsEvent.class); @@ -310,7 +313,6 @@ public class PacketManager { this.registerHandler(Incoming.SaveIgnoreRoomInvitesEvent, SaveIgnoreRoomInvitesEvent.class); this.registerHandler(Incoming.SavePreferOldChatEvent, SavePreferOldChatEvent.class); this.registerHandler(Incoming.ActivateEffectEvent, ActivateEffectEvent.class); - this.registerHandler(Incoming.PerformanceLogMessageEvent, PerformanceLogMessageEvent.class); this.registerHandler(Incoming.EnableEffectEvent, EnableEffectEvent.class); this.registerHandler(Incoming.UserActivityEvent, UserActivityEvent.class); this.registerHandler(Incoming.UserNuxEvent, UserNuxEvent.class); @@ -365,10 +367,10 @@ public class PacketManager { private void registerInventory() throws Exception { this.registerHandler(Incoming.RequestInventoryBadgesEvent, RequestInventoryBadgesEvent.class); this.registerHandler(Incoming.RequestInventoryBotsEvent, RequestInventoryBotsEvent.class); + this.registerHandler(Incoming.RequestInventoryItemsDelete, RequestInventoryItemsDelete.class); this.registerHandler(Incoming.RequestInventoryItemsEvent, RequestInventoryItemsEvent.class); this.registerHandler(Incoming.HotelViewInventoryEvent, RequestInventoryItemsEvent.class); this.registerHandler(Incoming.RequestInventoryPetsEvent, RequestInventoryPetsEvent.class); - this.registerHandler(Incoming.RequestInventoryItemsDelete, RequestInventoryItemsDelete.class); } void registerRooms() throws Exception { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/PacketNames.java b/Emulator/src/main/java/com/eu/habbo/messages/PacketNames.java index d493c15..4fa159e 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/PacketNames.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/PacketNames.java @@ -2,13 +2,17 @@ package com.eu.habbo.messages; import com.eu.habbo.messages.incoming.Incoming; import com.eu.habbo.messages.outgoing.Outgoing; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; -@Slf4j public class PacketNames { + + private static final Logger LOGGER = LoggerFactory.getLogger(PacketNames.class); + private final HashMap incoming; private final HashMap outgoing; @@ -38,14 +42,14 @@ public class PacketNames { int packetId = field.getInt(null); if (packetId > 0) { if (target.containsKey(packetId)) { - log.warn("Duplicate packet id found {} for {}.", packetId, clazz.getSimpleName()); + LOGGER.warn("Duplicate packet id found {} for {}.", packetId, clazz.getSimpleName()); continue; } target.put(packetId, field.getName()); } } catch (IllegalAccessException e) { - log.error("Failed to read field integer.", e); + LOGGER.error("Failed to read field integer.", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java index 2bc223f..294b1fd 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/Incoming.java @@ -23,7 +23,6 @@ public class Incoming { public static final int TradeAcceptEvent = 3863; public static final int RequestCatalogModeEvent = 1195; public static final int RequestUserCreditsEvent = 273; - public static final int FriendListUpdateEvent = 1419; public static final int FriendPrivateMessageEvent = 3567; public static final int CloseDiceEvent = 1533; public static final int RoomUserRemoveRightsEvent = 2064; @@ -140,7 +139,6 @@ public class Incoming { public static final int RequestAchievementsEvent = 219; public static final int GuildChangeColorsEvent = 1764; public static final int RequestInventoryBadgesEvent = 2769; - public static final int RequestInventoryItemsDelete = 10018; public static final int HotelViewInventoryEvent = 3500; public static final int RequestPetBreedsEvent = 1756; @@ -376,6 +374,7 @@ public class Incoming { public static final int GuildForumThreadUpdateEvent = 3045; public static final int GuildForumMarkAsReadEvent = 1855; + public static final int UNKNOWN_SNOWSTORM_6000 = 6000; public static final int UNKNOWN_SNOWSTORM_6001 = 6001; public static final int UNKNOWN_SNOWSTORM_6002 = 6002; @@ -403,6 +402,4 @@ public class Incoming { public static final int UNKNOWN_SNOWSTORM_6024 = 6024; public static final int UNKNOWN_SNOWSTORM_6025 = 6025; public static final int SnowStormUserPickSnowballEvent = 6026; - - public static final int PerformanceLogMessageEvent = 2743; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java index 7f1c085..9d63b55 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/camera/CameraPublishToWebEvent.java @@ -6,14 +6,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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; @@ -53,10 +54,11 @@ public class CameraPublishToWebEvent extends MessageHandler { isOk = true; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } + this.client.sendResponse(new CameraPublishWaitMessageComposer(isOk, cooldownLeft, isOk ? this.client.getHabbo().getHabboInfo().getPhotoURL() : "")); } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java index 2ea3fe3..454b517 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogBuyItemAsGiftEvent.java @@ -26,7 +26,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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -34,8 +35,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; -@Slf4j public class CatalogBuyItemAsGiftEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogBuyItemAsGiftEvent.class); @Override public void handle() throws Exception { @@ -117,7 +118,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { userId = habbo.getHabboInfo().getId(); @@ -293,7 +294,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { try { guildId = Integer.parseInt(extraData); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -365,7 +366,7 @@ public class CatalogBuyItemAsGiftEvent extends MessageHandler { this.client.sendResponse(new PurchaseOKComposer(item)); } catch (Exception e) { - log.error("Exception caught", e); + LOGGER.error("Exception caught", e); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); } } finally { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSelectClubGiftEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSelectClubGiftEvent.java index 16b4816..e4d6794 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSelectClubGiftEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/CatalogSelectClubGiftEvent.java @@ -9,24 +9,26 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.users.ClubGiftReceivedComposer; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class CatalogSelectClubGiftEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogSelectClubGiftEvent.class); + @Override public void handle() throws Exception { String itemName = this.packet.readString(); if(itemName.isEmpty()) { - log.error("itemName is empty"); + LOGGER.error("itemName is empty"); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } if(this.client.getHabbo().getHabboStats().getRemainingClubGifts() < 1) { - log.error("User has no remaining club gifts"); + LOGGER.error("User has no remaining club gifts"); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -34,7 +36,7 @@ public class CatalogSelectClubGiftEvent extends MessageHandler { CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().getCatalogPageByLayout(CatalogPageLayouts.club_gift.name().toLowerCase()); if(page == null) { - log.error("Catalog page not found"); + LOGGER.error("Catalog page not found"); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -42,7 +44,7 @@ public class CatalogSelectClubGiftEvent extends MessageHandler { CatalogItem catalogItem = page.getCatalogItems().valueCollection().stream().filter(x -> x.getName().equalsIgnoreCase(itemName)).findAny().orElse(null); if(catalogItem == null) { - log.error("Catalog item not found"); + LOGGER.error("Catalog item not found"); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -54,7 +56,7 @@ public class CatalogSelectClubGiftEvent extends MessageHandler { catch (NumberFormatException ignored) { } if(daysRequired > (int) Math.floor(this.client.getHabbo().getHabboStats().getPastTimeAsClub() / 86400.0)) { - log.error("Not been member for long enough"); + LOGGER.error("Not been member for long enough"); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java index b3ec58d..f63df2b 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/catalog/marketplace/SellItemEvent.java @@ -7,11 +7,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; - -@Slf4j public class SellItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SellItemEvent.class); @Override public void handle() throws Exception { @@ -30,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); - log.info(message); + LOGGER.info(message); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } @@ -38,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); - log.info(message); + LOGGER.info(message); this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR)); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java index 0056cdb..c2c90ed 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java @@ -15,8 +15,8 @@ import gnu.trove.set.hash.THashSet; import java.util.*; public class FloorPlanEditorSaveEvent extends MessageHandler { - public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 100; - public static int MAXIMUM_FLOORPLAN_SIZE = 100 * 100; + public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64; + public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64; @Override public void handle() throws Exception { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java index 9132698..d3f461b 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/AcceptFriendRequestEvent.java @@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.friends.FriendRequestErrorComposer; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -15,8 +16,8 @@ import java.sql.SQLException; import static com.eu.habbo.habbohotel.users.HabboManager.getOfflineHabboInfo; -@Slf4j public class AcceptFriendRequestEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AcceptFriendRequestEvent.class); @Override public void handle() throws Exception { @@ -53,7 +54,7 @@ public class AcceptFriendRequestEvent extends MessageHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java index ec42bde..c582d2a 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FindNewFriendsEvent.java @@ -22,7 +22,7 @@ public class FindNewFriendsEvent extends MessageHandler { if (!rooms.isEmpty()) { Room room = rooms.get(0); - if (room.getUserCountWithoutInvisibleHabbos() > 0) { + if (room.getUserCount() > 0) { this.client.sendResponse(new ForwardToRoomComposer(room.getId())); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendListUpdateEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendListUpdateEvent.java deleted file mode 100644 index 9cf31ef..0000000 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendListUpdateEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.eu.habbo.messages.incoming.friends; - -import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.friends.MessengerInitComposer; - -public class FriendListUpdateEvent extends MessageHandler { - @Override - public void handle() throws Exception { - this.client.sendResponse(new MessengerInitComposer(this.client.getHabbo())); - } -} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java index 7663d9f..95b363d 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/FriendRequestEvent.java @@ -8,15 +8,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class FriendRequestEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(FriendRequestEvent.class); @Override public void handle() throws Exception { @@ -39,7 +41,7 @@ public class FriendRequestEvent extends MessageHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); return; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java index af3cf0c..88cb761 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/friends/StalkFriendEvent.java @@ -34,7 +34,7 @@ public class StalkFriendEvent extends MessageHandler { return; } - if (habbo.getHabboInfo().getCurrentRoom() == null || habbo.getHabboInfo().isInvisibleInRooms()) { + if (habbo.getHabboInfo().getCurrentRoom() == null) { this.client.sendResponse(new StalkErrorComposer(StalkErrorComposer.FRIEND_NOT_IN_ROOM)); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java index 95cdebf..b2675d2 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guardians/GuardianVoteEvent.java @@ -4,10 +4,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class GuardianVoteEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(GuardianVoteEvent.class); @Override public void handle() throws Exception { @@ -25,7 +26,7 @@ public class GuardianVoteEvent extends MessageHandler { } else if (voteType == 2) { type = GuardianVoteType.AWFULLY; } else { - log.error("Uknown vote type: " + voteType); + LOGGER.error("Uknown vote type: " + voteType); } ticket.vote(this.client.getHabbo(), type); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java index 19a0309..574987f 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildBuyEvent.java @@ -13,10 +13,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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RequestGuildBuyEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestGuildBuyEvent.class); + @Override public void handle() throws Exception { String name = this.packet.readString(); @@ -86,7 +88,7 @@ public class RequestGuildBuyEvent extends MessageHandler { } Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge, colorOne, colorTwo); - r.setGuildId(guild.getId()); + r.setGuild(guild.getId()); r.removeAllRights(); r.setNeedsUpdate(true); @@ -108,7 +110,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); - log.info(message); + LOGGER.info(message); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java index bc5eea6..991b7a7 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumListEvent.java @@ -6,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -14,8 +15,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Set; -@Slf4j public class GuildForumListEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(GuildForumListEvent.class); @Override public void handle() throws Exception { @@ -63,7 +64,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } @@ -87,7 +88,7 @@ public class GuildForumListEvent extends MessageHandler { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.client.sendResponse(new ConnectionErrorComposer(500)); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java index 69d13a6..57ab3ad 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java @@ -2,10 +2,14 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @NoAuthMessage public class MachineIDEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(MachineIDEvent.class); + private static final int HASH_LENGTH = 64; @Override @@ -13,9 +17,13 @@ public class MachineIDEvent extends MessageHandler { String storedMachineId = this.packet.readString(); String clientFingerprint = this.packet.readString(); String capabilities = this.packet.readString(); + if (storedMachineId.length() > HASH_LENGTH) { storedMachineId = storedMachineId.substring(0, HASH_LENGTH); } + this.client.setMachineId(storedMachineId); + + LOGGER.debug("Setting client MachineId to {}", storedMachineId); } -} +} \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java index 6327b69..e9ea57e 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java @@ -3,19 +3,11 @@ package com.eu.habbo.messages.incoming.handshake; import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.incoming.MessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - @NoAuthMessage public class ReleaseVersionEvent extends MessageHandler { - public static boolean isReady = false; - private static final Logger LOGGER = LoggerFactory.getLogger(SecureLoginEvent.class); - - @Override + @Override public void handle() throws Exception { - - // niet per se nodig - this.client.finishedReleaseEvent(); + this.packet.readString(); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java index 14f523c..7a048f2 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java @@ -36,15 +36,18 @@ import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent; import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent; import com.eu.habbo.plugin.events.users.UserLoginEvent; import gnu.trove.map.hash.THashMap; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Date; @NoAuthMessage -@Slf4j public class SecureLoginEvent extends MessageHandler { - + private static final Logger LOGGER = LoggerFactory.getLogger(SecureLoginEvent.class); + + + @Override public void handle() throws Exception { if (!this.client.getChannel().isOpen()) { @@ -52,17 +55,12 @@ public class SecureLoginEvent extends MessageHandler { return; } - if (!this.client.didFinishReleaseEvent()) { - Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - return; - } - if (!Emulator.isReady) return; if (Emulator.getConfig().getBoolean("encryption.forced", false) && Emulator.getCrypto().isEnabled() && !this.client.isHandshakeFinished()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - log.warn("Encryption is forced and TLS Handshake isn't finished! Closed connection..."); + LOGGER.warn("Encryption is forced and TLS Handshake isn't finished! Closed connection..."); return; } @@ -70,21 +68,20 @@ public class SecureLoginEvent extends MessageHandler { if (Emulator.getPluginManager().fireEvent(new SSOAuthenticationEvent(sso)).isCancelled()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - log.info("SSO Authentication is cancelled by a plugin. Closed connection..."); + LOGGER.info("SSO Authentication is cancelled by a plugin. Closed connection..."); return; } if (sso.isEmpty()) { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - log.debug("Client is trying to connect without SSO ticket! Closed connection..."); + LOGGER.debug("Client is trying to connect without SSO ticket! Closed connection..."); return; } - + if (this.client.getHabbo() == null) { Habbo habbo = Emulator.getGameEnvironment().getHabboManager().loadHabbo(sso); if (habbo != null) { try { - habbo.setClient(this.client); this.client.setHabbo(habbo); if(!this.client.getHabbo().connect()) { @@ -104,7 +101,7 @@ public class SecureLoginEvent extends MessageHandler { Emulator.getThreading().run(habbo); Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); return; } @@ -229,7 +226,7 @@ public class SecureLoginEvent extends MessageHandler { } } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); - log.warn("Someone tried to login with a non-existing SSO token! Closed connection..."); + LOGGER.warn("Someone tried to login with a non-existing SSO token! Closed connection..."); } } else { Emulator.getGameServer().getGameClientManager().disposeClient(this.client); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java index e1bc5e4..16f7fef 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/hotelview/HotelViewDataEvent.java @@ -2,13 +2,17 @@ package com.eu.habbo.messages.incoming.hotelview; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.hotelview.HotelViewDataComposer; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class HotelViewDataEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewDataEvent.class); + + @Override public void handle() { + try { String data = this.packet.readString(); if (data.contains(";")) { @@ -29,7 +33,7 @@ public class HotelViewDataEvent extends MessageHandler { this.client.sendResponse(new HotelViewDataComposer(data, data.split(",")[data.split(",").length - 1])); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsDelete.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsDelete.java index 36724fb..feeeb53 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsDelete.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsDelete.java @@ -8,14 +8,9 @@ import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.RemoveHabboItemComposer; import com.eu.habbo.threading.runnables.QueryDeleteHabboItems; +import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.map.hash.TIntObjectHashMap; -import lombok.extern.slf4j.Slf4j; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -@Slf4j public class RequestInventoryItemsDelete extends MessageHandler { public int getRatelimit() { return 500; @@ -35,29 +30,29 @@ public class RequestInventoryItemsDelete extends MessageHandler { final Habbo habbo = this.client.getHabbo(); if (habbo == null) return; - - List toRemove = IntStream.range(0, Math.abs(amount)) - .mapToObj(i -> habbo.getInventory().getItemsComponent().getAndRemoveHabboItem(item)) - .filter(removeItem -> removeItem != null) - .collect(Collectors.toList()); - - TIntObjectHashMap toRemoveMap = new TIntObjectHashMap<>(); - toRemove.forEach(removeItem -> toRemoveMap.put(removeItem.getId(), removeItem)); - - toRemoveMap.forEachValue(mapHabboItem -> { - habbo.getClient().sendResponse(new RemoveHabboItemComposer(mapHabboItem.getGiftAdjustedId())); + TIntObjectHashMap toRemove = new TIntObjectHashMap(); + for (int i = 0; i < Math.abs(amount); i++) { + HabboItem habboInventoryItem = habbo.getInventory().getItemsComponent().getAndRemoveHabboItem(item); + if (habboInventoryItem != null) + toRemove.put(habboInventoryItem.getId(), habboInventoryItem); + } + toRemove.forEachValue(object -> { + habbo.getClient().sendResponse(new RemoveHabboItemComposer(object.getGiftAdjustedId())); return true; }); - habbo.getClient().sendResponse(new InventoryRefreshComposer()); - Emulator.getThreading().run(new QueryDeleteHabboItems(toRemoveMap)); + Emulator.getThreading().run(new QueryDeleteHabboItems(toRemove)); } private boolean hasFurnitureInInventory(Habbo habbo, Item item, Integer amount) { - long count = habbo.getInventory().getItemsComponent().getItemsAsValueCollection().stream() - .filter(habboItem -> habboItem.getBaseItem().getId() == item.getId()) - .count(); - - return count >= amount; + int count = 0; + for (TObjectHashIterator tObjectHashIterator = habbo.getInventory().getItemsComponent().getItemsAsValueCollection().iterator(); tObjectHashIterator.hasNext(); ) { + HabboItem habboItem = tObjectHashIterator.next(); + if (habboItem.getBaseItem().getId() == item.getId()) + count++; + } + if (count < amount) + return false; + return true; } -} +} \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java index 5a1cc07..7fa6a66 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/inventory/RequestInventoryItemsEvent.java @@ -6,11 +6,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.NoSuchElementException; -@Slf4j 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(); @@ -45,7 +48,7 @@ public class RequestInventoryItemsEvent extends MessageHandler { items.put(iterator.key(), iterator.value()); count++; } catch (NoSuchElementException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); break; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java index 6226ae5..c5e921f 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestCreateRoomEvent.java @@ -7,10 +7,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RequestCreateRoomEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestCreateRoomEvent.class); + + @Override public void handle() throws Exception { String name = this.packet.readString(); @@ -21,14 +24,14 @@ public class RequestCreateRoomEvent extends MessageHandler { int tradeType = this.packet.readInt(); if (!Emulator.getGameEnvironment().getRoomManager().layoutExists(modelName)) { - log.error("[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()) { - log.error("[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/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java index 0e973dd..aaea208 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestDeleteRoomEvent.java @@ -11,15 +11,18 @@ import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; import com.eu.habbo.plugin.events.navigator.NavigatorRoomDeletedEvent; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -@Slf4j 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(); @@ -106,12 +109,12 @@ public class RequestDeleteRoomEvent extends MessageHandler { filter.execute(); } } catch (SQLException e) { - log.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); - log.info(message); + LOGGER.info(message); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java index 4f41cd6..6c527b4 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/navigator/RequestNewNavigatorRoomsEvent.java @@ -8,11 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.*; -@Slf4j 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(); @@ -85,7 +88,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { return; try { - List resultLists2 = (ArrayList)((ArrayList)filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1)).clone(); + List resultLists2 = filter.getResult(this.client.getHabbo(), field, part, category != null ? category.getId() : -1); List resultLists = new ArrayList<>(); for(SearchResultList searchResultList : resultLists2) { List rooms = new ArrayList<>(); @@ -96,7 +99,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { resultLists = toQueryResults(resultLists); this.client.sendResponse(new NewNavigatorSearchResultsComposer(view, query, resultLists)); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } /* @@ -111,7 +114,7 @@ public class RequestNewNavigatorRoomsEvent extends MessageHandler { } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } */ } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java index d331bb3..180b0a2 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/AnswerPollEvent.java @@ -6,14 +6,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class AnswerPollEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(AnswerPollEvent.class); @Override public void handle() throws Exception { @@ -46,7 +47,7 @@ public class AnswerPollEvent extends MessageHandler { statement.setString(4, answer.toString()); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (poll.lastQuestionId == questionId) { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java index 75cf05a..a38b5a0 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/polls/CancelPollEvent.java @@ -3,14 +3,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class CancelPollEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CancelPollEvent.class); @Override public void handle() throws Exception { @@ -27,7 +28,7 @@ public class CancelPollEvent extends MessageHandler { statement.setString(4, ""); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java index 5032065..a45eeb8 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomSettingsSaveEvent.java @@ -7,10 +7,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomSettingsSaveEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomSettingsSaveEvent.class); @Override public void handle() throws Exception { @@ -101,7 +102,7 @@ public class RoomSettingsSaveEvent extends MessageHandler { } ScripterManager.scripterDetected(this.client, message); - log.info(message); + LOGGER.info(message); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java index c4e9c2c..894e83c 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightSaveSettingsEvent.java @@ -21,7 +21,7 @@ public class MoodLightSaveSettingsEvent extends MessageHandler { public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (!(room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getGuildId() <= 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) return; int id = this.packet.readInt(); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java index 00b1d96..4f2e8eb 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/MoodLightTurnOnEvent.java @@ -13,7 +13,7 @@ public class MoodLightTurnOnEvent extends MessageHandler { public void handle() throws Exception { Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if (!(room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) + if ((room.getGuildId() > 0 && room.getGuildRightLevel(this.client.getHabbo()).isLessThan(RoomRightLevels.GUILD_RIGHTS)) && !room.hasRights(this.client.getHabbo())) return; for (HabboItem moodLight : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java index d2aeda4..a2bb552 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/PostItSaveDataEvent.java @@ -12,7 +12,7 @@ import java.util.Arrays; import java.util.List; public class PostItSaveDataEvent extends MessageHandler { - private static List COLORS = Arrays.asList("9CCEFF", "FF9CFF", "9CFF9C", "FFFF33", "FF9C9D", "FFCD9C", "C3B1E1", "DBDEFB", "FFFFFF", "282828"); + private static List COLORS = Arrays.asList("9CCEFF", "FF9CFF", "9CFF9C", "FFFF33"); @Override public void handle() throws Exception { diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java index ee38587..2d489be 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemClothingEvent.java @@ -12,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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(); @@ -46,7 +49,7 @@ public class RedeemClothingEvent extends MessageHandler { statement.setInt(2, clothing.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.client.getHabbo().getInventory().getWardrobeComponent().getClothing().add(clothing.id); @@ -58,7 +61,7 @@ public class RedeemClothingEvent extends MessageHandler { this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FIGURESET_OWNED_ALREADY.key)); } } else { - log.error("[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/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java index 4135293..096c158 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RedeemItemEvent.java @@ -11,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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(); @@ -28,13 +30,13 @@ public class RedeemItemEvent extends MessageHandler { boolean furnitureRedeemEventRegistered = Emulator.getPluginManager().isRegistered(FurnitureRedeemedEvent.class, true); FurnitureRedeemedEvent furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), 0, FurnitureRedeemedEvent.CREDITS); - if (item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_") || item.getBaseItem().getName().startsWith("nft_credit_")) { + if (item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) { if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) { int credits; try { credits = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - log.error("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; } @@ -45,22 +47,11 @@ public class RedeemItemEvent extends MessageHandler { try { pixels = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - log.error("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; } furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), pixels, FurnitureRedeemedEvent.PIXELS); - } else if (item.getBaseItem().getName().startsWith("nft_credit_")) { - int points; - - try { - points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); - } catch (Exception e) { - log.error("Failed to parse redeemable points furniture: " + item.getBaseItem().getName() + ". Must be in format of ntf_credit_."); - return; - } - furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), points, FurnitureRedeemedEvent.NFT); - } else if (item.getBaseItem().getName().startsWith("DF_")) { int pointsType; int points; @@ -68,25 +59,25 @@ public class RedeemItemEvent extends MessageHandler { try { pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); } catch (Exception e) { - log.error("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) { - log.error("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; } furniRedeemEvent = new FurnitureRedeemedEvent(item, this.client.getHabbo(), points, pointsType); - }else if (item.getBaseItem().getName().startsWith("CF_diamond_")) { + } else if (item.getBaseItem().getName().startsWith("CF_diamond_")) { int points; try { points = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); } catch (Exception e) { - log.error("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/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java index a5465df..9f39389 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/SavePostItStickyPoleEvent.java @@ -7,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.time.LocalDate; -@Slf4j 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(); @@ -29,7 +30,7 @@ public class SavePostItStickyPoleEvent extends MessageHandler { CommandHandler.handleCommand(this.client, command); } } else { - log.info("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/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java index 0770e1e..50376ae 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java @@ -15,10 +15,11 @@ import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.events.furniture.FurniturePickedUpEvent; import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class ToggleFloorItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(ToggleFloorItemEvent.class); @Override public void handle() throws Exception { @@ -132,7 +133,7 @@ public class ToggleFloorItemEvent extends MessageHandler { this.client.getHabbo().getRoomUnit().setGoalLocation(this.client.getHabbo().getRoomUnit().getCurrentLocation()); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java index 4dc0b88..85a357f 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/UseRandomStateItemEvent.java @@ -4,10 +4,12 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class UseRandomStateItemEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(UseRandomStateItemEvent.class); + @Override public void handle() throws Exception { try { @@ -24,7 +26,7 @@ public class UseRandomStateItemEvent extends MessageHandler { InteractionRandomState randomStateItem = (InteractionRandomState)item; randomStateItem.onRandomStateClick(this.client, room); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java index 7b04f1a..a5468d5 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxRequestPlayListEvent.java @@ -1,6 +1,5 @@ package com.eu.habbo.messages.incoming.rooms.items.jukebox; -import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.TraxManager; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer; @@ -9,13 +8,9 @@ import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxPlayListCompose public class JukeBoxRequestPlayListEvent extends MessageHandler { @Override public void handle() throws Exception { - Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); - if(room == null) { - return; - } - TraxManager traxManager = room.getTraxManager(); + TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager(); this.client.sendResponse(new JukeBoxPlayListComposer(traxManager.getSongs(), traxManager.totalLength())); this.client.sendResponse(new JukeBoxMySongsComposer(traxManager.myList(this.client.getHabbo()))); - room.getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo()); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java index 9f855bd..15f9206 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeRequestPlaylists.java @@ -7,13 +7,13 @@ 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 lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; -@Slf4j public class YoutubeRequestPlaylists extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeRequestPlaylists.class); @Override public void handle() throws Exception { @@ -28,7 +28,7 @@ public class YoutubeRequestPlaylists extends MessageHandler { ArrayList playlists = Emulator.getGameEnvironment().getItemManager().getYoutubeManager().getPlaylistsForItemId(item.getBaseItem().getId()); if (playlists == null) { - log.error("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/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java index e900667..2b87a45 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/CompostMonsterplantEvent.java @@ -8,14 +8,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class CompostMonsterplantEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(CompostMonsterplantEvent.class); @Override public void handle() throws Exception { @@ -45,7 +46,7 @@ public class CompostMonsterplantEvent extends MessageHandler { statement.setInt(1, pet.getId()); statement.executeUpdate(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java index 06344f9..9c36827 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/HorseRemoveSaddleEvent.java @@ -10,14 +10,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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(); @@ -37,12 +40,12 @@ public class HorseRemoveSaddleEvent extends MessageHandler { if (set.next()) { saddleItemId = set.getInt("id"); } else { - log.error("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) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java index ac0d85a..1c0e4fb 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserShoutEvent.java @@ -6,10 +6,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomUserShoutEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserShoutEvent.class); @Override public void handle() throws Exception { @@ -37,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); - log.info(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java index c1f365d..2201fb4 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserTalkEvent.java @@ -7,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomUserTalkEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserTalkEvent.class); + @Override public void handle() throws Exception { @@ -38,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); - log.info(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 45f28b6..859be04 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -12,10 +12,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomUserWalkEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserWalkEvent.class); @Override public int getRatelimit() { @@ -157,7 +158,7 @@ public class RoomUserWalkEvent extends MessageHandler { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java index 3250102..b153138 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWhisperEvent.java @@ -6,10 +6,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomUserWhisperEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUserWhisperEvent.class); @Override public void handle() throws Exception { @@ -34,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); - log.info(reportMessage); + LOGGER.info(reportMessage); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java index 4caa359..03e0214 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/ConfirmChangeNameEvent.java @@ -10,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -18,8 +19,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -@Slf4j public class ConfirmChangeNameEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfirmChangeNameEvent.class); public static final List changingUsernames = new ArrayList<>(2); @@ -83,7 +84,7 @@ public class ConfirmChangeNameEvent extends MessageHandler { statement.setInt(4, Emulator.getIntUnixTimestamp()); statement.execute(); } catch (SQLException e) { - log.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/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/PerformanceLogMessageEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/PerformanceLogMessageEvent.java deleted file mode 100644 index 9002c35..0000000 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/PerformanceLogMessageEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.eu.habbo.messages.incoming.users; - -import com.eu.habbo.Emulator; -import com.eu.habbo.messages.incoming.MessageHandler; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class PerformanceLogMessageEvent extends MessageHandler { - - @Override - public void handle() throws Exception { - int timer = this.packet.readInt(); // kind of time since start of client - String externalInterface = this.packet.readString(); // available ExternalInterface - String flashVersion = this.packet.readString(); // _flashVersion - String userOs = this.packet.readString(); // user OS - String unknown1 = this.packet.readString(); // always an empty string, not assigned by client - boolean debuggerState = this.packet.readBoolean(); // _SafeStr_8266 Capabilities.isDebugger, false by default - int totalMemory = this.packet.readInt(); // System.totalMemory, Total Memory in KB - int unknown2 = this.packet.readInt(); // by default set to -1 - int averageUpdateIntervalGarbaged = this.packet.readInt(); // averageUpdateInterval.isGarbageMonitored - int averageUpdateInterval = this.packet.readInt(); // averageUpdateInterval - int slowUpdateLimit = this.packet.readInt(); // exceeded slowUpdateLimit - if (Emulator.debugging) { - log.info("Timer: " + timer + - ", ExternalInterface: " + externalInterface + - ", FlashVersion: " + flashVersion + - ", UserOS: " + userOs + - ", Unknown1 (Empty String): '" + unknown1 + "'" + - ", DebuggerState: " + debuggerState + - ", TotalMemory (KB): " + totalMemory + - ", Unknown2 (Default -1): " + unknown2 + - ", AverageUpdateIntervalGarbaged: " + averageUpdateIntervalGarbaged + - ", AverageUpdateInterval: " + averageUpdateInterval + - ", SlowUpdateLimit: " + slowUpdateLimit); - } - } -} diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java index 4ac06b6..aa55bd8 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/RequestUserDataEvent.java @@ -8,12 +8,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; -@Slf4j public class RequestUserDataEvent extends MessageHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RequestUserDataEvent.class); @Override public void handle() throws Exception { @@ -57,7 +58,7 @@ public class RequestUserDataEvent extends MessageHandler { } else { - log.debug("Attempted to request user data where Habbo was null."); + LOGGER.debug("Attempted to request user data where Habbo was null."); Emulator.getGameServer().getGameClientManager().disposeClient(this.client); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java index d278253..c4c30c5 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/users/UserSaveLookEvent.java @@ -9,10 +9,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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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(); @@ -23,7 +25,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); - log.info(message); + LOGGER.info(message); return; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java index 93972ee..92742f8 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredConditionSaveDataEvent.java @@ -1,12 +1,19 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Optional; + public class WiredConditionSaveDataEvent extends MessageHandler { @Override public void handle() throws Exception { @@ -19,13 +26,35 @@ public class WiredConditionSaveDataEvent extends MessageHandler { InteractionWiredCondition condition = room.getRoomSpecialTypes().getCondition(itemId); if (condition != null) { - if (condition.saveData(this.packet)) { - this.client.sendResponse(new WiredSavedComposer()); - condition.needsUpdate(true); + Optional saveMethod = Arrays.stream(condition.getClass().getMethods()).filter(x -> x.getName().equals("saveData")).findFirst(); - Emulator.getThreading().run(condition); + if(saveMethod.isPresent()) { + if (saveMethod.get().getParameterTypes()[0] == WiredSettings.class) { + WiredSettings settings = InteractionWired.readSettings(this.packet, false); + + if (condition.saveData(settings)) { + this.client.sendResponse(new WiredSavedComposer()); + + condition.needsUpdate(true); + + Emulator.getThreading().run(condition); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that condition")); + } + } else { + if ((boolean) saveMethod.get().invoke(condition, this.packet)) { + this.client.sendResponse(new WiredSavedComposer()); + condition.needsUpdate(true); + Emulator.getThreading().run(condition); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that condition")); + } + } + } else { + this.client.sendResponse(new UpdateFailedComposer("Save method was not found")); } + } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java index fbf5122..e6e46c9 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredEffectSaveDataEvent.java @@ -1,14 +1,19 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; -import com.eu.habbo.messages.outgoing.generic.alerts.GenericErrorMessagesComposer; import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Optional; + public class WiredEffectSaveDataEvent extends MessageHandler { @Override public void handle() throws Exception { @@ -24,11 +29,29 @@ public class WiredEffectSaveDataEvent extends MessageHandler { if (effect == null) throw new WiredSaveException(String.format("Wired effect with item id %s not found in room", itemId)); - if (effect.saveData(this.packet, this.client)) { - this.client.sendResponse(new WiredSavedComposer()); - effect.needsUpdate(true); - Emulator.getThreading().run(effect); + Optional saveMethod = Arrays.stream(effect.getClass().getMethods()).filter(x -> x.getName().equals("saveData")).findFirst(); + + if(saveMethod.isPresent()) { + if(saveMethod.get().getParameterTypes()[0] == WiredSettings.class) { + WiredSettings settings = InteractionWired.readSettings(this.packet, true); + if (effect.saveData(settings, this.client)) { + this.client.sendResponse(new WiredSavedComposer()); + effect.needsUpdate(true); + Emulator.getThreading().run(effect); + } + } + else { + if ((boolean) saveMethod.get().invoke(effect, this.packet, this.client)) { + this.client.sendResponse(new WiredSavedComposer()); + effect.needsUpdate(true); + Emulator.getThreading().run(effect); + } + } + } else { + this.client.sendResponse(new UpdateFailedComposer("Save method was not found")); } + + } catch (WiredSaveException e) { this.client.sendResponse(new UpdateFailedComposer(e.getMessage())); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java index 8f62f60..611de23 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/wired/WiredTriggerSaveDataEvent.java @@ -1,12 +1,19 @@ package com.eu.habbo.messages.incoming.wired; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.items.interactions.InteractionWired; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; +import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer; import com.eu.habbo.messages.outgoing.wired.WiredSavedComposer; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Optional; + public class WiredTriggerSaveDataEvent extends MessageHandler { @Override public void handle() throws Exception { @@ -19,12 +26,34 @@ public class WiredTriggerSaveDataEvent extends MessageHandler { InteractionWiredTrigger trigger = room.getRoomSpecialTypes().getTrigger(itemId); if (trigger != null) { - if (trigger.saveData(this.packet)) { - this.client.sendResponse(new WiredSavedComposer()); - trigger.needsUpdate(true); + Optional saveMethod = Arrays.stream(trigger.getClass().getMethods()).filter(x -> x.getName().equals("saveData")).findFirst(); - Emulator.getThreading().run(trigger); + if(saveMethod.isPresent()) { + if (saveMethod.get().getParameterTypes()[0] == WiredSettings.class) { + WiredSettings settings = InteractionWired.readSettings(this.packet, false); + + if (trigger.saveData(settings)) { + this.client.sendResponse(new WiredSavedComposer()); + + trigger.needsUpdate(true); + + Emulator.getThreading().run(trigger); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that trigger")); + } + } else { + if ((boolean) saveMethod.get().invoke(trigger, this.packet)) { + this.client.sendResponse(new WiredSavedComposer()); + trigger.needsUpdate(true); + Emulator.getThreading().run(trigger); + } else { + this.client.sendResponse(new UpdateFailedComposer("There was an error while saving that trigger")); + } + } + } + else { + this.client.sendResponse(new UpdateFailedComposer("Save method was not found")); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java index e68b4ce..be1660f 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/achievements/AchievementListComposer.java @@ -8,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class AchievementListComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(AchievementListComposer.class); + private final Habbo habbo; public AchievementListComposer(Habbo habbo) { @@ -51,7 +53,7 @@ public class AchievementListComposer extends MessageComposer { this.response.appendString(""); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return this.response; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java index a8f0dd9..829c48b 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/CatalogPagesListComposer.java @@ -7,12 +7,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; -@Slf4j public class CatalogPagesListComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPagesListComposer.class); private final Habbo habbo; private final String mode; @@ -48,7 +49,7 @@ public class CatalogPagesListComposer extends MessageComposer { return this.response; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java index 7e04d75..b02c1c0 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/catalog/marketplace/MarketplaceOwnItemsComposer.java @@ -7,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class MarketplaceOwnItemsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(MarketplaceOwnItemsComposer.class); + private final Habbo habbo; public MarketplaceOwnItemsComposer(Habbo habbo) { @@ -56,7 +58,7 @@ public class MarketplaceOwnItemsComposer extends MessageComposer { this.response.appendInt(0); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java index 47e77c3..287e87c 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java @@ -6,12 +6,15 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Collection; -@Slf4j public class FriendsComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(FriendsComposer.class); + private final int totalPages; private final int pageIndex; private final Collection friends; @@ -49,7 +52,7 @@ public class FriendsComposer extends MessageComposer { } return this.response; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java index 6acd20d..555df4a 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/guilds/forums/GuildForumDataComposer.java @@ -13,15 +13,18 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class GuildForumDataComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(GuildForumDataComposer.class); + public final Guild guild; public Habbo habbo; @@ -75,17 +78,21 @@ public class GuildForumDataComposer extends MessageComposer { newComments = set.getInt(1); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } response.appendInt(guild.getId()); + response.appendString(guild.getName()); response.appendString(guild.getDescription()); response.appendString(guild.getBadge()); + response.appendInt(totalThreads); response.appendInt(0); //Rating + response.appendInt(totalComments); //Total comments response.appendInt(newComments); //Unread comments + response.appendInt(lastComment != null ? lastComment.getThreadId() : -1); response.appendInt(lastComment != null ? lastComment.getUserId() : -1); response.appendString(lastComment != null && lastComment.getHabbo() != null ? lastComment.getHabbo().getHabboInfo().getUsername() : ""); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java index 284d611..e8dbd93 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/inventory/InventoryItemsComposer.java @@ -8,12 +8,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Arrays; import java.util.List; -@Slf4j public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure { + private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); + private final int fragmentNumber; private final int totalFragments; private final TIntObjectMap items; @@ -35,7 +38,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec this.items.forEachEntry(this); return this.response; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java index c009b24..41bce32 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolUserInfoComposer.java @@ -8,12 +8,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; import java.util.ArrayList; -@Slf4j public class ModToolUserInfoComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(ModToolUserInfoComposer.class); + private final ResultSet set; public ModToolUserInfoComposer(ResultSet set) { @@ -34,10 +37,10 @@ public class ModToolUserInfoComposer extends MessageComposer { totalBans = set.getInt("amount"); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.response.appendInt(this.set.getInt("user_id")); @@ -77,7 +80,7 @@ public class ModToolUserInfoComposer extends MessageComposer { return this.response; } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } return null; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java index beda9e0..41682c8 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/navigator/PrivateRoomsComposer.java @@ -4,11 +4,14 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.List; -@Slf4j 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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java index a6d5d64..9da42a6 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java @@ -8,6 +8,8 @@ import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.Outgoing; import gnu.trove.set.hash.THashSet; +import java.util.Objects; + public class UpdateStackHeightComposer extends MessageComposer { private int x; private int y; @@ -34,6 +36,7 @@ public class UpdateStackHeightComposer extends MessageComposer { //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done this.response.init(Outgoing.UpdateStackHeightComposer); if (this.updateTiles != null) { + this.updateTiles.removeIf(Objects::isNull); // prevent overflow. Byte max value is 127 if(this.updateTiles.size() > 127) { RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java index acb7700..cc4d757 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/ProfileFriendsComposer.java @@ -7,14 +7,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; -@Slf4j 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) { - log.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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return this.response; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java index 61ac72f..22b689a 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserCurrencyComposer.java @@ -5,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class UserCurrencyComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(UserCurrencyComposer.class); + private final Habbo habbo; public UserCurrencyComposer(Habbo habbo) { @@ -25,7 +27,7 @@ public class UserCurrencyComposer extends MessageComposer { try { type = Integer.valueOf(s); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return null; } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java index 3b09d64..7a53565 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/users/UserProfileComposer.java @@ -9,8 +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 lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -@Slf4j public class UserProfileComposer extends MessageComposer { + private static final Logger LOGGER = LoggerFactory.getLogger(UserProfileComposer.class); private final HabboInfo habboInfo; private Habbo habbo; @@ -64,7 +64,7 @@ public class UserProfileComposer extends MessageComposer { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } this.response.appendInt(achievementScore); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java index 631f1fc..e7cb6c6 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ChangeUsername.java @@ -6,14 +6,15 @@ import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.subscriptions.Subscription; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class ChangeUsername extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(ChangeUsername.class); public ChangeUsername() { super(ChangeUsername.JSON.class); @@ -58,7 +59,7 @@ public class ChangeUsername extends RCONMessage { catch (Exception e) { this.status = RCONMessage.SYSTEM_ERROR; this.message = "Exception occurred"; - log.error("Exception occurred", e); + LOGGER.error("Exception occurred", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java index d83bb3d..fd16a35 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ExecuteCommand.java @@ -4,10 +4,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class ExecuteCommand extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteCommand.class); + + public ExecuteCommand() { super(JSONExecuteCommand.class); } @@ -26,12 +29,15 @@ public class ExecuteCommand extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveBadge.class); + + public GiveBadge() { super(GiveBadgeJSON.class); } @@ -76,7 +80,7 @@ public class GiveBadge extends RCONMessage { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); this.status = RCONMessage.STATUS_ERROR; this.message = e.getMessage(); } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java index a83840d..60e9326 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveCredits.java @@ -3,13 +3,17 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class GiveCredits extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveCredits.class); + + public GiveCredits() { super(JSONGiveCredits.class); } @@ -27,14 +31,18 @@ public class GiveCredits extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } + this.message = "offline"; } } static class JSONGiveCredits { + public int user_id; + + public int credits; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java index 2ed9f5d..45001f9 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePixels.java @@ -3,15 +3,17 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class GivePixels extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GivePixels.class); + + public GivePixels() { super(JSONGivePixels.class); } @@ -29,7 +31,7 @@ public class GivePixels extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; @@ -37,7 +39,10 @@ public class GivePixels extends RCONMessage { } static class JSONGivePixels { + public int user_id; + + public int pixels; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java index c4b7732..2afff47 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GivePoints.java @@ -3,13 +3,17 @@ package com.eu.habbo.messages.rcon; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j 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; - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; @@ -37,8 +41,13 @@ public class GivePoints extends RCONMessage { } static class JSONGivePoints { + public int user_id; + + public int points; + + public int type; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java index ce2b172..3ffa262 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveRespect.java @@ -4,13 +4,16 @@ import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.outgoing.users.UserDataComposer; import com.google.gson.Gson; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class GiveRespect extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveRespect.class); + public GiveRespect() { super(JSONGiveRespect.class); @@ -34,7 +37,7 @@ public class GiveRespect extends RCONMessage { statement.execute(); } catch (SQLException e) { this.status = RCONMessage.SYSTEM_ERROR; - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; @@ -42,9 +45,16 @@ public class GiveRespect extends RCONMessage { } static class JSONGiveRespect { + public int user_id; + + public int respect_given = 0; + + public int respect_received = 0; + + public int daily_respects = 0; } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java index 5c366cb..41b8166 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/GiveUserClothing.java @@ -7,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class GiveUserClothing extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(GiveUserClothing.class); + public GiveUserClothing() { super(GiveUserClothing.JSONGiveUserClothing.class); } @@ -27,7 +30,7 @@ public class GiveUserClothing extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(IgnoreUser.class); + public IgnoreUser() { super(JSONIgnoreUser.class); } @@ -27,7 +30,7 @@ public class IgnoreUser extends RCONMessage { statement.setInt(2, object.target_id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.message = "offline"; @@ -35,7 +38,9 @@ public class IgnoreUser extends RCONMessage { } static class JSONIgnoreUser { + public int user_id; + public int target_id; } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java index ee93250..8ec3e2e 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/ModifyUserSubscription.java @@ -9,13 +9,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class ModifyUserSubscription extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(ModifyUserSubscription.class); + public ModifyUserSubscription() { super(ModifyUserSubscription.JSON.class); } @@ -87,7 +90,7 @@ public class ModifyUserSubscription extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(MuteUser.class); + public MuteUser() { super(MuteUser.JSON.class); } @@ -32,7 +35,7 @@ public class MuteUser extends RCONMessage { this.status = HABBO_NOT_FOUND; } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } @@ -40,6 +43,8 @@ public class MuteUser extends RCONMessage { static class JSON { public int user_id; + + public int duration; } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/SendGift.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/SendGift.java index d79c0c0..8f64465 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/SendGift.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/SendGift.java @@ -6,15 +6,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j public class SendGift extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(SendGift.class); public SendGift() { super(SendGiftJSON.class); @@ -58,7 +59,7 @@ public class SendGift extends RCONMessage { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } else { username = habbo.getHabboInfo().getUsername(); diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java index 686ab0f..88ce9c2 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/SetMotto.java @@ -4,14 +4,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class SetMotto extends RCONMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(SetMotto.class); public SetMotto() { super(SetMottoJSON.class); @@ -32,7 +33,7 @@ public class SetMotto extends RCONMessage { statement.execute(); } } catch (SQLException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java b/Emulator/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java index 9202b06..7357a76 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/rcon/UpdateUser.java @@ -6,14 +6,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class UpdateUser extends RCONMessage { - + private static final Logger LOGGER = LoggerFactory.getLogger(UpdateUser.class); + public UpdateUser() { super(UpdateUser.JSON.class); } @@ -106,7 +108,7 @@ public class UpdateUser extends RCONMessage { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/Server.java b/Emulator/src/main/java/com/eu/habbo/networking/Server.java index 81269b5..3b6d17f 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/Server.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/Server.java @@ -9,11 +9,15 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.concurrent.TimeUnit; -@Slf4j 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; @@ -51,22 +55,22 @@ public abstract class Server { } if (!channelFuture.isSuccess()) { - log.info("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 { - log.info("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); + LOGGER.info("Started GameServer on " + this.host + ":" + this.port + "@" + this.name); } } public void stop() { - log.info("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(InterruptedException e) { - log.error("Exception during {} shutdown... HARD STOP", this.name, e); + LOGGER.error("Exception during {} shutdown... HARD STOP", this.name, e); } - log.info("GameServer Stopped!"); + LOGGER.info("GameServer Stopped!"); } public ServerBootstrap getServerBootstrap() { diff --git a/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraClient.java b/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraClient.java index d84732d..5635d9c 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraClient.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraClient.java @@ -7,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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; @@ -48,10 +51,10 @@ public class CameraClient { if (CameraClient.channelFuture.isSuccess()) { CameraClient.attemptReconnect = false; CameraClient.channel = channelFuture.channel(); - log.info("Connected to the Camera Server. Attempting to login."); + LOGGER.info("Connected to the Camera Server. Attempting to login."); this.sendMessage(new CameraLoginComposer()); } else { - log.error("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; @@ -72,7 +75,7 @@ public class CameraClient { channel = null; isLoggedIn = false; - log.info("Disconnected from the camera server."); + LOGGER.info("Disconnected from the camera server."); } public void sendMessage(CameraOutgoingMessage outgoingMessage) { diff --git a/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java b/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java index 77af6d7..b0dc058 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/camera/CameraPacketHandler.java @@ -3,11 +3,14 @@ package com.eu.habbo.networking.camera; import com.eu.habbo.networking.camera.messages.incoming.*; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.HashMap; -@Slf4j 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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java b/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java index 5ee261a..a13a509 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraLoginStatusEvent.java @@ -4,10 +4,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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; @@ -25,27 +28,27 @@ public class CameraLoginStatusEvent extends CameraIncomingMessage { int status = this.readInt(); if (status == LOGIN_ERROR) { - log.error("Failed to login to Camera Server: Incorrect Details"); + LOGGER.error("Failed to login to Camera Server: Incorrect Details"); } else if (status == NO_ACCOUNT) { - log.error("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) { - log.error("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) { - log.error("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) { - log.error("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) { - log.error("You don't have a Camera Subscription and therefor cannot use the camera!"); - log.error("Please consider making a donation to keep this project going. The emulator can be used free of charge!"); - log.error("A trial version is available for $2.5. A year subscription is only $10 and a permanent subscription is $25."); - log.error("By donating this subscription you support the development of the emulator you are using :)"); - log.error("Visit http://arcturus.pw/mysubscriptions.php to buy your subscription!"); - log.error("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; - log.info("Succesfully connected to the Arcturus Camera Server!"); + LOGGER.info("Succesfully connected to the Arcturus Camera Server!"); } else { CameraClient.attemptReconnect = false; } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java b/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java index 566c37f..358e8e1 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/camera/messages/incoming/CameraUpdateNotification.java @@ -5,11 +5,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class CameraUpdateNotification extends CameraIncomingMessage { + private static final Logger LOGGER = LoggerFactory.getLogger(CameraUpdateNotification.class); + public CameraUpdateNotification(Short header, ByteBuf body) { super(header, body); } @@ -21,11 +23,11 @@ public class CameraUpdateNotification extends CameraIncomingMessage { int type = this.readInt(); if (type == 0) { - log.info("Camera update: {}", message); + LOGGER.info("Camera update: {}", message); } else if (type == 1) { - log.warn("Camera update: {}", message); + LOGGER.warn("Camera update: {}", message); } else if (type == 2) { - log.error("Camera update: {}", message); + LOGGER.error("Camera update: {}", message); } if (alert) { diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteFrameDecoder.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteFrameDecoder.java index 3007425..f902a3c 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteFrameDecoder.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameByteFrameDecoder.java @@ -6,36 +6,27 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder; public class GameByteFrameDecoder extends LengthFieldBasedFrameDecoder { - private static final int MAX_PACKET_LENGTH = 2097152; // 2 MB + /** + * MAX_PACKET_LENGTH is based on the maximum camera PNG size. + * Source: https://superuser.com/a/759030 + * Maximum camera packet is 320 * 320 Pixel * 4 Bytes per Pixel = 409600. + * Adding some for overhead 409600 + 8192 = 417792 + */ + private static final int MAX_PACKET_LENGTH = 417792; private static final int LENGTH_FIELD_OFFSET = 0; private static final int LENGTH_FIELD_LENGTH = 4; private static final int LENGTH_FIELD_ADJUSTMENT = 0; private static final int INITIAL_BYTES_TO_STRIP = 4; - public GameByteFrameDecoder() { + public GameByteFrameDecoder() + { super(MAX_PACKET_LENGTH, LENGTH_FIELD_OFFSET, LENGTH_FIELD_LENGTH, LENGTH_FIELD_ADJUSTMENT, INITIAL_BYTES_TO_STRIP); } @Override - protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { - if (in.readableBytes() < LENGTH_FIELD_LENGTH) { - // Wait until we have at least LENGTH_FIELD_LENGTH bytes available - return null; - } - - int packetLength = in.getInt(in.readerIndex()); - if (packetLength > MAX_PACKET_LENGTH) { - // Packet exceeds limit, could be an indication of problem or attack - ctx.close(); // Close channel - return null; - } - - if (in.readableBytes() < LENGTH_FIELD_LENGTH + packetLength) { - // Wait until we have all packet bytes available - return null; - } - - // Everything seems to be in order, continue with normal decoding + protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception + { return super.decode(ctx, in); } + } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java index 63b9caa..bf43325 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameClientMessageLogger.java @@ -6,11 +6,14 @@ import com.eu.habbo.messages.PacketNames; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.List; -@Slf4j public class GameClientMessageLogger extends MessageToMessageDecoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameClientMessageLogger.class); private final PacketNames names; public GameClientMessageLogger() { @@ -19,7 +22,7 @@ public class GameClientMessageLogger extends MessageToMessageDecoder out) { - log.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + LOGGER.debug(String.format("[" + ANSI.GREEN + "CLIENT" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", message.getMessageId(), this.names.getIncomingName(message.getMessageId()), message.getMessageBody())); diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index 1e3a4a3..e593600 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -11,8 +11,9 @@ import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.TooLongFrameException; import io.netty.handler.codec.UnsupportedMessageTypeException; import io.netty.handler.ssl.NotSslRecordException; -import io.netty.util.AttributeKey; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import java.io.IOException; @@ -20,8 +21,10 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; @ChannelHandler.Sharable -@Slf4j public class GameMessageHandler extends ChannelInboundHandlerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(GameMessageHandler.class); + + @Override public void channelRegistered(ChannelHandlerContext ctx) { if (!Emulator.getGameServer().getGameClientManager().addClient(ctx)) { @@ -48,7 +51,7 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { handler.run(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -64,41 +67,34 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { return; } if (Emulator.getConfig().getBoolean("debug.mode")) { - String clientIpAddress = ctx.channel().remoteAddress().toString(); - String xForwardedFor = (String) ctx.channel().attr(AttributeKey.valueOf("X-Forwarded-For")).get(); - if (xForwardedFor != null && !xForwardedFor.isEmpty()) { - clientIpAddress = xForwardedFor; - } - clientIpAddress = clientIpAddress.substring(1, clientIpAddress.lastIndexOf(':')); - if (cause instanceof NotSslRecordException) { - log.error("Someone speaks transport plaintext instead of SSL, IP: {}", clientIpAddress); + LOGGER.error("Plaintext received instead of ssl, closing channel"); } else if (cause instanceof DecoderException) { - log.error("Someone speaks transport plaintext instead of SSL, IP: {}", clientIpAddress); + LOGGER.error("Plaintext received instead of ssl, closing channel"); } else if (cause instanceof TooLongFrameException) { - log.error("Disconnecting client, reason: {}", cause.getMessage()); + LOGGER.error("Disconnecting client, reason " + cause.getMessage()); } else if (cause instanceof SSLHandshakeException) { - log.error("URL Request error from source: {}", clientIpAddress); + LOGGER.error("URL Request error from source " + ctx.channel().remoteAddress()); } else if (cause instanceof NoSuchAlgorithmException) { - log.error("Invalid SSL algorithm, only TLSv1.2 supported in the request, IP: {}", clientIpAddress); + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); } else if (cause instanceof KeyManagementException) { - log.error("Invalid SSL algorithm, only TLSv1.2 supported in the request, IP: {}", clientIpAddress); + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); } else if (cause instanceof UnsupportedMessageTypeException) { - log.error("There was an illegal SSL request from (X-forwarded-for/CF-Connecting-IP has not being injected yet!) {}", clientIpAddress); + LOGGER.error("There was an illegal SSL request from (X-forwarded-for/CF-Connecting-IP has not being injected yet!) " + ctx.channel().remoteAddress()); } else if (cause instanceof SSLException) { - log.error("SSL Problem: {}", cause.getMessage() + cause); + LOGGER.error("SSL Problem: "+ cause.getMessage() + cause); } else { - log.error("Disconnecting client, exception in GameMessageHandler.", cause); + LOGGER.error("Disconnecting client, exception in GameMessageHandler.", cause); } } ctx.channel().close(); } -} \ No newline at end of file +} diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java index 6f0db54..7a4c8de 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageRateLimit.java @@ -8,12 +8,11 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; import java.util.List; -import java.util.logging.Logger; public class GameMessageRateLimit extends MessageToMessageDecoder { + private static final int RESET_TIME = 1; private static final int MAX_COUNTER = 10; - private static final Logger logger = Logger.getLogger(GameMessageRateLimit.class.getName()); @Override protected void decode(ChannelHandlerContext ctx, ClientMessage message, List out) throws Exception { @@ -23,22 +22,28 @@ public class GameMessageRateLimit extends MessageToMessageDecoder return; } + int count = 0; + + // Check if reset time has passed. int timestamp = Emulator.getIntUnixTimestamp(); if (timestamp - client.lastPacketCounterCleared > RESET_TIME) { + // Reset counter. client.incomingPacketCounter.clear(); client.lastPacketCounterCleared = timestamp; + } else { + // Get stored count for message id. + count = client.incomingPacketCounter.getOrDefault(message.getMessageId(), 0); } - int count = client.incomingPacketCounter.getOrDefault(message.getMessageId(), 0); - + // If we exceeded the counter, drop the packet. if (count > MAX_COUNTER) { - String userIP = ctx.channel().remoteAddress().toString(); - logger.warning(String.format("User with IP %s exceeded the message rate limit for message ID %s", userIP, message.getMessageId())); return; } - client.incomingPacketCounter.put(message.getMessageId(), count + 1); + client.incomingPacketCounter.put(message.getMessageId(), ++count); + // Continue processing. out.add(message); } + } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java index 5ae445a..fd35194 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/encoders/GameServerMessageLogger.java @@ -6,11 +6,14 @@ import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.util.ANSI; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageEncoder; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.List; -@Slf4j public class GameServerMessageLogger extends MessageToMessageEncoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameServerMessageLogger.class); private final PacketNames names; public GameServerMessageLogger() { @@ -19,7 +22,7 @@ public class GameServerMessageLogger extends MessageToMessageEncoder out) { - log.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", + LOGGER.debug(String.format("[" + ANSI.BLUE + "SERVER" + ANSI.DEFAULT + "][%-4d][%-41s] => %s", message.getHeader(), this.names.getOutgoingName(message.getHeader()), message.getBodyString())); diff --git a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java index e17e2d9..26c5566 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/gameserver/handlers/IdleTimeoutHandler.java @@ -18,9 +18,7 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { private final long pongTimeoutNanos; volatile ScheduledFuture pingScheduleFuture; - volatile boolean sentPing; - volatile long lastPingTime; // in nanoseconds - volatile long lastPongTime; // in nanoseconds + volatile long lastPongTime;// in nanoseconds private volatile int state; // 0 - none, 1 - initialized, 2 - destroyed @@ -99,18 +97,10 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { // check if its a pong message - if (msg instanceof ClientMessage) { + if(msg instanceof ClientMessage) { ClientMessage packet = (ClientMessage) msg; - if (packet.getMessageId() == Incoming.PongEvent) { + if(packet.getMessageId() == Incoming.PongEvent) { this.lastPongTime = System.nanoTime(); - - final GameClient client = ctx.channel().attr(GameServerAttributes.CLIENT).get(); - if (client != null) { - if (sentPing) { - sentPing = false; - client.getLatencyTracker().update(lastPongTime - lastPingTime); - } - } } } super.channelRead(ctx, msg); @@ -130,15 +120,13 @@ public class IdleTimeoutHandler extends ChannelDuplexHandler { } long currentTime = System.nanoTime(); - if (currentTime - lastPongTime > pongTimeoutNanos) { + if(currentTime - lastPongTime > pongTimeoutNanos) { ctx.close();// add a promise here ? return; } - final GameClient client = ctx.channel().attr(GameServerAttributes.CLIENT).get(); + GameClient client = ctx.channel().attr(GameServerAttributes.CLIENT).get(); if (client != null) { - lastPingTime = System.nanoTime(); - sentPing = true; client.sendResponse(new PingComposer()); } diff --git a/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java b/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java index 0d29e43..fed9aa5 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServer.java @@ -9,22 +9,29 @@ import gnu.trove.map.hash.THashMap; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Collections; import java.util.List; -@Slf4j 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<>(); public RCONServer(String host, int port) throws Exception { super("RCON Server", host, port, 1, 2); + this.messages = new THashMap<>(); + this.gsonBuilder = new GsonBuilder(); this.gsonBuilder.registerTypeAdapter(RCONMessage.class, new RCONMessage.RCONMessageSerializer()); + this.addRCONMessage("alertuser", AlertUser.class); this.addRCONMessage("disconnect", DisconnectUser.class); this.addRCONMessage("forwarduser", ForwardUser.class); @@ -86,19 +93,19 @@ public class RCONServer extends Server { RCONMessage rcon = message.getDeclaredConstructor().newInstance(); Gson gson = this.gsonBuilder.create(); rcon.handle(gson, gson.fromJson(body, rcon.type)); - log.info("Handled RCON Message: {}", message.getSimpleName()); + LOGGER.info("Handled RCON Message: {}", message.getSimpleName()); result = gson.toJson(rcon, RCONMessage.class); if (Emulator.debugging) { - log.debug("RCON Data {} RCON Result {}", body, result); + LOGGER.debug("RCON Data {} RCON Result {}", body, result); } return result; } catch (Exception ex) { - log.error("Failed to handle RCONMessage", ex); + LOGGER.error("Failed to handle RCONMessage", ex); } } else { - log.error("Couldn't find: {}", key); + LOGGER.error("Couldn't find: {}", key); } throw new ArrayIndexOutOfBoundsException("Unhandled RCON Message"); diff --git a/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java b/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java index 7279823..0563fe0 100644 --- a/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java +++ b/Emulator/src/main/java/com/eu/habbo/networking/rconserver/RCONServerHandler.java @@ -1,5 +1,6 @@ package com.eu.habbo.networking.rconserver; + import com.eu.habbo.Emulator; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -8,10 +9,13 @@ import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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("/", ""); @@ -24,7 +28,7 @@ public class RCONServerHandler extends ChannelInboundHandlerAdapter { ctx.channel().close(); - log.warn("RCON Remote connection closed: {}. IP not allowed!", adress); + LOGGER.warn("RCON Remote connection closed: {}. IP not allowed!", adress); } @Override @@ -42,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) { - log.error("Unknown RCON Message: {}", key); + LOGGER.error("Unknown RCON Message: {}", key); } catch (Exception e) { - log.error("Invalid RCON Message: {}", message); + LOGGER.error("Invalid RCON Message: {}", message); e.printStackTrace(); } diff --git a/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java b/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java index 5cfbd07..a7d6027 100644 --- a/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -21,11 +21,13 @@ import com.eu.habbo.habbohotel.navigation.EventCategory; import com.eu.habbo.habbohotel.navigation.NavigatorManager; import com.eu.habbo.habbohotel.pets.PetManager; import com.eu.habbo.habbohotel.rooms.*; +import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.habbohotel.users.HabboInventory; import com.eu.habbo.habbohotel.users.HabboManager; -import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager; import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub; +import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionManager; import com.eu.habbo.habbohotel.wired.WiredHandler; +import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.incoming.camera.CameraPublishToWebEvent; import com.eu.habbo.messages.incoming.camera.CameraPurchaseEvent; @@ -38,6 +40,7 @@ import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; import com.eu.habbo.messages.outgoing.catalog.GiftConfigurationComposer; import com.eu.habbo.messages.outgoing.navigator.NewNavigatorEventCategoriesComposer; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; +import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.users.*; import com.eu.habbo.threading.runnables.RoomTrashing; @@ -46,7 +49,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import gnu.trove.iterator.hash.TObjectHashIterator; import gnu.trove.set.hash.THashSet; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -60,8 +65,10 @@ import java.util.Objects; import java.util.regex.Pattern; import java.util.stream.Collectors; -@Slf4j public class PluginManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class); + private final THashSet plugins = new THashSet<>(); private final THashSet methods = new THashSet<>(); @@ -99,7 +106,7 @@ public class PluginManager { Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.users.max.friends.hc", 1100); Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); - Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 3000); + Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500); Room.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200); Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240); @@ -122,7 +129,7 @@ public class PluginManager { try { RoomChatMessage.BANNED_BUBBLES[i] = Integer.valueOf(bannedBubbles[i]); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } @@ -234,7 +241,7 @@ public class PluginManager { if (!loc.exists()) { if (loc.mkdirs()) { - log.info("Created plugins directory!"); + LOGGER.info("Created plugins directory!"); } } @@ -268,12 +275,12 @@ public class PluginManager { this.plugins.add(plugin); plugin.onEnable(); } catch (Exception e) { - log.error("Could not load plugin {}!", pluginConfigurtion.name); - log.error("Caught exception", e); + LOGGER.error("Could not load plugin {}!", pluginConfigurtion.name); + LOGGER.error("Caught exception", e); } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } @@ -306,8 +313,8 @@ public class PluginManager { try { method.invoke(null, event); } catch (Exception e) { - log.error("Could not pass default event {} to {}: {}!", event.getClass().getName(), method.getClass().getName(), method.getName()); - log.error("Caught exception", e); + LOGGER.error("Could not pass default event {} to {}: {}!", event.getClass().getName(), method.getClass().getName(), method.getName()); + LOGGER.error("Caught exception", e); } } } @@ -325,8 +332,8 @@ public class PluginManager { try { method.invoke(plugin, event); } catch (Exception e) { - log.error("Could not pass event {} to {}", event.getClass().getName(), plugin.configuration.name); - log.error("Caught exception", e); + LOGGER.error("Could not pass event {} to {}", event.getClass().getName(), plugin.configuration.name); + LOGGER.error("Caught exception", e); } } } @@ -365,7 +372,7 @@ public class PluginManager { public void dispose() { this.disposePlugins(); - log.info("Disposed Plugin Manager!"); + LOGGER.info("Disposed Plugin Manager!"); } private void disposePlugins() { @@ -381,9 +388,9 @@ public class PluginManager { p.stream.close(); p.classLoader.close(); } catch (IOException e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } catch (Exception ex) { - log.error("Failed to disable {} because of an exception.", p.configuration.name, ex); + LOGGER.error("Failed to disable {} because of an exception.", p.configuration.name, ex); } } } catch (NoSuchElementException e) { @@ -400,7 +407,7 @@ public class PluginManager { this.loadPlugins(); - log.info("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(); } @@ -417,9 +424,10 @@ public class PluginManager { this.methods.add(InteractionFootballGate.class.getMethod("onUserExitRoomEvent", UserExitRoomEvent.class)); this.methods.add(InteractionFootballGate.class.getMethod("onUserSavedLookEvent", UserSavedLookEvent.class)); this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class)); + this.methods.add(WiredHighscoreManager.class.getMethod("onEmulatorLoaded", EmulatorLoadedEvent.class)); } catch (NoSuchMethodException e) { - log.info("Failed to define default events!"); - log.error("Caught exception", e); + LOGGER.info("Failed to define default events!"); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java b/Emulator/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java index 5cdbc11..ce2dd0d 100644 --- a/Emulator/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/plugin/events/furniture/FurnitureRedeemedEvent.java @@ -7,8 +7,6 @@ public class FurnitureRedeemedEvent extends FurnitureUserEvent { public static final int CREDITS = -1; public static final int PIXELS = 0; public static final int DIAMONDS = 5; - public static final int NFT = 4; - public final int amount; public final int currencyID; diff --git a/Emulator/src/main/java/com/eu/habbo/threading/HabboExecutorService.java b/Emulator/src/main/java/com/eu/habbo/threading/HabboExecutorService.java index e165200..36ccd05 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/HabboExecutorService.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/HabboExecutorService.java @@ -1,12 +1,15 @@ package com.eu.habbo.threading; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; -@Slf4j public class HabboExecutorService extends ScheduledThreadPoolExecutor { + private static final Logger LOGGER = LoggerFactory.getLogger(HabboExecutorService.class); + public HabboExecutorService(int corePoolSize, ThreadFactory threadFactory) { super(corePoolSize, threadFactory); } @@ -16,7 +19,7 @@ public class HabboExecutorService extends ScheduledThreadPoolExecutor { super.afterExecute(r, t); if (t != null && !(t instanceof IOException)) { - log.error("Error in HabboExecutorService", t); + LOGGER.error("Error in HabboExecutorService", t); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java b/Emulator/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java index 59ba0f8..1517ce1 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/RejectedExecutionHandlerImpl.java @@ -1,14 +1,16 @@ package com.eu.habbo.threading; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; -@Slf4j public class RejectedExecutionHandlerImpl implements RejectedExecutionHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(RejectedExecutionHandlerImpl.class); @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { - log.error(r.toString() + " is rejected"); + LOGGER.error(r.toString() + " is rejected"); } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/ThreadPooling.java b/Emulator/src/main/java/com/eu/habbo/threading/ThreadPooling.java index 7652a79..eb7e25c 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/ThreadPooling.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/ThreadPooling.java @@ -2,25 +2,26 @@ package com.eu.habbo.threading; import com.eu.habbo.Emulator; import io.netty.util.concurrent.DefaultThreadFactory; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -@Slf4j public class ThreadPooling { + private static final Logger LOGGER = LoggerFactory.getLogger(ThreadPooling.class); + public final int threads; private final ScheduledExecutorService scheduledPool; private volatile boolean canAdd; - public ThreadPooling(Integer threads) { this.threads = threads; this.scheduledPool = new HabboExecutorService(this.threads, new DefaultThreadFactory("HabExec")); this.canAdd = true; - log.info("Thread Pool -> Loaded!"); + LOGGER.info("Thread Pool -> Loaded!"); } public ScheduledFuture run(Runnable run) { @@ -33,7 +34,7 @@ public class ThreadPooling { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -46,12 +47,12 @@ public class ThreadPooling { try { run.run(); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } }, delay, TimeUnit.MILLISECONDS); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } return null; @@ -61,11 +62,11 @@ public class ThreadPooling { this.canAdd = false; this.scheduledPool.shutdownNow(); - log.info("Threading -> Disposed!"); + LOGGER.info("Threading -> Disposed!"); } public void setCanAdd(boolean canAdd) { - this.canAdd = canAdd; + this.canAdd = canAdd; } public ScheduledExecutorService getService() { diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java index 0eedee3..a3b3114 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/CameraClientAutoReconnect.java @@ -2,16 +2,18 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.networking.camera.CameraClient; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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())) { - log.info("Attempting to connect to the Camera server."); + LOGGER.info("Attempting to connect to the Camera server."); if (Emulator.getCameraClient() != null) { Emulator.getCameraClient().disconnect(); } else { @@ -21,13 +23,14 @@ public class CameraClientAutoReconnect implements Runnable { try { Emulator.getCameraClient().connect(); } catch (Exception e) { - log.error("Failed to start the camera client.", e); + LOGGER.error("Failed to start the camera client.", e); } } else { CameraClient.attemptReconnect = false; - log.info("Already connected to the camera. Reconnecting not needed!"); + LOGGER.info("Already connected to the camera. Reconnecting not needed!"); } } + Emulator.getThreading().run(this, 5000); } } \ No newline at end of file diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java index 97cc4be..5674259 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/InsertModToolIssue.java @@ -2,11 +2,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.*; -@Slf4j public class InsertModToolIssue implements Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(InsertModToolIssue.class); + private final ModToolIssue issue; public InsertModToolIssue(ModToolIssue issue) { @@ -37,7 +41,7 @@ public class InsertModToolIssue implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); @@ -45,7 +49,7 @@ public class InsertModToolIssue implements Runnable { statement.setInt(1, this.issue.senderId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java index 2edb688..03e0260 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/OpenGift.java @@ -11,14 +11,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@Slf4j 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; @@ -101,7 +104,7 @@ public class OpenGift implements Runnable { this.habbo.getClient().sendResponse(new PresentItemOpenedComposer(inside, "", false)); } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java index 239499d..2910fed 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboBadge.java @@ -2,13 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j class QueryDeleteHabboBadge implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboBadge.class); + private final String name; private final Habbo habbo; @@ -24,7 +27,7 @@ class QueryDeleteHabboBadge implements Runnable { statement.setString(2, this.name); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java index d1627b2..91579bf 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItem.java @@ -2,13 +2,16 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.HabboItem; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class QueryDeleteHabboItem implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItem.class); + private final int itemId; public QueryDeleteHabboItem(int itemId) { @@ -25,7 +28,7 @@ public class QueryDeleteHabboItem implements Runnable { statement.setInt(1, this.itemId); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java index 025d2f0..71e30ac 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/QueryDeleteHabboItems.java @@ -3,13 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class QueryDeleteHabboItems implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(QueryDeleteHabboItems.class); + private TIntObjectMap items; public QueryDeleteHabboItems(TIntObjectMap items) { @@ -29,7 +32,7 @@ public class QueryDeleteHabboItems implements Runnable { statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } this.items.clear(); diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java index f621e0b..e6c8360 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java @@ -28,7 +28,7 @@ public class RandomDiceNumber implements Runnable { @Override public void run() { if (this.result <= 0) - this.result = (Emulator.getRandomDice().nextInt(this.maxNumber) + 1); + this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1); this.item.setExtradata(this.result + ""); this.item.needsUpdate(true); diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 6cec89a..9cbe83c 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -7,12 +7,13 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.LinkedList; -@Slf4j public class RoomUnitTeleport implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitTeleport.class); private RoomUnit roomUnit; private Room room; @@ -44,7 +45,7 @@ public class RoomUnitTeleport implements Runnable { try { topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } this.roomUnit.setPath(new LinkedList<>()); diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java index 895dcbf..61c65c7 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleportWalkToAction.java @@ -5,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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; @@ -31,7 +33,7 @@ public class RoomUnitTeleportWalkToAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { if (tile.isWalkable()) { diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java index 212ca28..926e38f 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitVendingMachineAction.java @@ -5,10 +5,11 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class RoomUnitVendingMachineAction implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(RoomUnitVendingMachineAction.class); private final Habbo habbo; private final HabboItem habboItem; @@ -31,7 +32,7 @@ public class RoomUnitVendingMachineAction implements Runnable { try { this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0}); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } else { if (this.room.getLayout().getTile(tile.x, tile.y).isWalkable()) { diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java index 97e2cc7..44151ae 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/SaveScoreForTeam.java @@ -4,15 +4,15 @@ 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 lombok.extern.slf4j.Slf4j; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class SaveScoreForTeam implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(SaveScoreForTeam.class); public final GameTeam team; public final Game game; @@ -38,7 +38,7 @@ public class SaveScoreForTeam implements Runnable { statement.executeBatch(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java index b829f9c..83c6388 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/TeleportInteraction.java @@ -11,10 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j 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; @@ -114,7 +116,7 @@ class TeleportInteraction extends Thread { } } } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java index 2cda500..2a26db6 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/UpdateModToolIssue.java @@ -2,13 +2,15 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.modtool.ModToolIssue; -import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -@Slf4j public class UpdateModToolIssue implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(UpdateModToolIssue.class); private final ModToolIssue issue; @@ -27,7 +29,7 @@ public class UpdateModToolIssue implements Runnable { statement.setInt(5, this.issue.id); statement.execute(); } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java index f617a7f..c8ba461 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/freeze/FreezeHandleSnowballExplosion.java @@ -10,9 +10,11 @@ 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 lombok.extern.slf4j.Slf4j; -@Slf4j +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; @@ -102,7 +104,7 @@ class FreezeHandleSnowballExplosion implements Runnable { Emulator.getThreading().run(new FreezeResetExplosionTiles(freezeTiles, this.thrownData.room), 1000); } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java index baa826c..97b04dc 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/hopper/HopperActionTwo.java @@ -4,14 +4,17 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j 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; @@ -40,7 +43,7 @@ class HopperActionTwo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } if (targetRoomId != 0 && targetItemId != 0) { diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java index 907fcb5..ad3cee4 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java @@ -72,6 +72,7 @@ class TeleportActionThree implements Runnable { targetTeleport.setExtradata("2"); targetRoom.updateItem(targetTeleport); //targetRoom.updateHabbo(this.client.getHabbo()); + //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); diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java index 1c19529..feedd76 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionTwo.java @@ -9,15 +9,16 @@ 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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -@Slf4j class TeleportActionTwo implements Runnable { + private static final Logger LOGGER = LoggerFactory.getLogger(TeleportActionTwo.class); private final HabboItem currentTeleport; private final Room room; @@ -37,10 +38,6 @@ class TeleportActionTwo implements Runnable { delayOffset = 0; } - if(this.client.getHabbo() == null) { - return; - } - if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room) return; @@ -79,7 +76,7 @@ class TeleportActionTwo implements Runnable { } } } catch (SQLException e) { - log.error("Caught SQL exception", e); + LOGGER.error("Caught SQL exception", e); } } diff --git a/Emulator/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java b/Emulator/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java index a597e2f..616f697 100644 --- a/Emulator/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java +++ b/Emulator/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java @@ -5,7 +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 lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.imageio.ImageIO; import java.awt.*; @@ -16,17 +17,18 @@ import java.awt.image.WritableRaster; import java.io.File; import java.util.Map; -@Slf4j 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()) { - log.info("Badge Imager -> Loaded!"); + LOGGER.info("Badge Imager -> Loaded!"); } else { - log.warn("Badge Imager -> Disabled! Please check your configuration!"); + LOGGER.warn("Badge Imager -> Disabled! Please check your configuration!"); } } } @@ -115,7 +117,7 @@ public class BadgeImager { public synchronized boolean reload() { File file = new File(Emulator.getConfig().getValue("imager.location.badgeparts")); if (!file.exists()) { - log.error("BadgeImager output folder: {} does not exist!", Emulator.getConfig().getValue("imager.location.badgeparts")); + LOGGER.error("BadgeImager output folder: {} does not exist!", Emulator.getConfig().getValue("imager.location.badgeparts")); return false; } @@ -128,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) { - log.info(("[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"))); } } @@ -136,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) { - log.info(("[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) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return false; } @@ -159,7 +161,7 @@ public class BadgeImager { if (outputFile.exists()) return; } catch (Exception e) { - log.error("Caught exception", e); + LOGGER.error("Caught exception", e); return; } @@ -215,9 +217,7 @@ public class BadgeImager { point = getPoint(image, imagePart, position); - if(color != null) { - recolor(imagePart, colorFromHexString(color.valueA)); - } + recolor(imagePart, colorFromHexString(color.valueA)); graphics.drawImage(imagePart, point.x, point.y, null); } @@ -239,7 +239,7 @@ public class BadgeImager { try { ImageIO.write(image, "PNG", outputFile); } catch (Exception e) { - log.error("Failed to generate guild badge: {}.png Make sure the output folder exists and is writable!", outputFile); + LOGGER.error("Failed to generate guild badge: {}.png Make sure the output folder exists and is writable!", outputFile); } graphics.dispose(); diff --git a/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar b/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar index ed38fa3..f851fb3 100644 Binary files a/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar and b/Latest_Compiled_Version/Habbo-3.6.0-jar-with-dependencies.jar differ