diff --git a/Emulator/.gitignore b/Emulator/.gitignore
new file mode 100644
index 0000000..94c0cbd
--- /dev/null
+++ b/Emulator/.gitignore
@@ -0,0 +1,17 @@
+logging/
+compiled-builds/
+*.iml
+.idea/
+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
new file mode 100644
index 0000000..e1d0de3
--- /dev/null
+++ b/Emulator/.gitlab-ci.yml
@@ -0,0 +1,18 @@
+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
new file mode 100644
index 0000000..efe4ac3
--- /dev/null
+++ b/Emulator/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "morningstar-default-database"]
+ path = morningstar-default-database
+ url = https://git.krews.org/morningstar/morningstar-default-database
diff --git a/Emulator/Dockerfile b/Emulator/Dockerfile
new file mode 100644
index 0000000..e045ce4
--- /dev/null
+++ b/Emulator/Dockerfile
@@ -0,0 +1,19 @@
+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/Example_Start/Linux/emulator b/Emulator/Example_Start/Linux/emulator
new file mode 100644
index 0000000..1b071ed
--- /dev/null
+++ b/Emulator/Example_Start/Linux/emulator
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -Dfile.encoding=UTF8 -Xmx4096m -jar /PATH_TO_YOUR_EMULATOR/Habbo-3.5.3-jar-with-dependencies.jar
\ No newline at end of file
diff --git a/Emulator/Example_Start/Windows/emulator.cmd b/Emulator/Example_Start/Windows/emulator.cmd
new file mode 100644
index 0000000..54b15c4
--- /dev/null
+++ b/Emulator/Example_Start/Windows/emulator.cmd
@@ -0,0 +1 @@
+java -Dfile.encoding=UTF8 -Xmx4096m -jar /PATH_TO_YOUR_EMULATOR/Habbo-3.5.3-jar-with-dependencies.jar
\ No newline at end of file
diff --git a/Emulator/LICENSE b/Emulator/LICENSE
new file mode 100644
index 0000000..418dc9a
--- /dev/null
+++ b/Emulator/LICENSE
@@ -0,0 +1,165 @@
+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
new file mode 100644
index 0000000..7f49499
--- /dev/null
+++ b/Emulator/featurelist.md
@@ -0,0 +1,208 @@
+
+
+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
new file mode 100644
index 0000000..276a08d
--- /dev/null
+++ b/Emulator/pom.xml
@@ -0,0 +1,200 @@
+
+
+ 4.0.0
+
+ com.eu.habbo
+ Habbo
+ 3.6.0
+
+
+ UTF-8
+
+ -Xdoclint:none
+
+
+
+
+ java8-doclint-disabled
+
+ [1.8,)
+
+
+ -Xdoclint:none
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.12.1
+
+ 16
+ 16
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.6.0
+
+
+ jar-with-dependencies
+
+
+
+ com.eu.habbo.Emulator
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.6.3
+
+
+ -Xdoclint:none
+
+ public
+
+
+
+
+
+
+
+ central
+ https://repo1.maven.org/maven2/
+
+
+ mvnrepo
+ https://mvnrepository.com/
+
+
+
+
+
+
+ io.netty
+ netty-all
+ 4.1.106.Final
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.10.1
+
+
+
+
+
+
+ com.mysql
+ mysql-connector-j
+ 8.3.0
+ runtime
+
+
+
+
+ net.sf.trove4j
+ trove4j
+ 3.0.3
+ compile
+
+
+
+
+ com.zaxxer
+ HikariCP
+ 5.1.0
+ 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
+ compile
+
+
+
+ org.apache.commons
+ commons-math3
+ 3.6.1
+ compile
+
+
+
+ org.jsoup
+ jsoup
+ 1.17.2
+ compile
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.4.7
+ compile
+
+
+
+ org.fusesource.jansi
+ jansi
+ 2.4.1
+
+
+
+ joda-time
+ joda-time
+ 2.12.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
new file mode 100644
index 0000000..b8ca710
--- /dev/null
+++ b/Emulator/src/main/java/com/eu/habbo/Emulator.java
@@ -0,0 +1,527 @@
+package com.eu.habbo;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.ConsoleAppender;
+import com.eu.habbo.core.*;
+import com.eu.habbo.core.consolecommands.ConsoleCommand;
+import com.eu.habbo.database.Database;
+import com.eu.habbo.habbohotel.GameEnvironment;
+import com.eu.habbo.networking.camera.CameraClient;
+import com.eu.habbo.networking.gameserver.GameServer;
+import com.eu.habbo.networking.rconserver.RCONServer;
+import com.eu.habbo.networking.websockets.NetworkChannelInitializer;
+import com.eu.habbo.plugin.PluginManager;
+import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
+import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
+import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent;
+import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
+import com.eu.habbo.plugin.events.users.UserGetIPAddressEvent;
+import com.eu.habbo.threading.ThreadPooling;
+import com.eu.habbo.util.imager.badges.BadgeImager;
+import io.netty.channel.Channel;
+import io.netty.util.AttributeKey;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.security.MessageDigest;
+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 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;
+ public final static String PREVIEW = "";
+
+ public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
+ private static final String logo =
+ "\n" +
+ "███╗ ███╗ ██████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗ █████╗ ██████╗ \n" +
+ "████╗ ████║██╔═══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗\n" +
+ "██╔████╔██║██║ ██║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗███████╗ ██║ ███████║██████╔╝\n" +
+ "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" +
+ "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" +
+ "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" +
+ " Extended version";
+
+
+ public static String build = "";
+ public static String debuglevel = "";
+ public static boolean isReady = false;
+ public static boolean isShuttingDown = false;
+ public static boolean stopped = false;
+ public static boolean debugging = false;
+ private static int timeStarted = 0;
+ private static Runtime runtime;
+ private static ConfigurationManager config;
+ private static CryptoConfig crypto;
+ private static TextsManager texts;
+ private static GameServer gameServer;
+ private static RCONServer rconServer;
+ private static CameraClient cameraClient;
+ private static Logging logging;
+ private static Database database;
+ private static DatabaseLogger databaseLogger;
+ private static ThreadPooling threading;
+ 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() {
+ public synchronized void run() {
+ Emulator.dispose();
+ }
+ });
+ hook.setPriority(10);
+ Runtime.getRuntime().addShutdownHook(hook);
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ // Check if running on Windows and not in IntelliJ.
+ // If so, we need to reconfigure the console appender and enable Jansi for colors.
+ if (OS_NAME.startsWith("Windows") && !CLASS_PATH.contains("idea_rt.jar")) {
+ ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ ConsoleAppender appender = (ConsoleAppender) root.getAppender("Console");
+
+ appender.stop();
+ appender.setWithJansi(true);
+ appender.start();
+ }
+
+ Locale.setDefault(new Locale("en"));
+ setBuild();
+ Emulator.stopped = false;
+ ConsoleCommand.load();
+ Emulator.logging = new Logging();
+
+ System.out.println(logo);
+
+ log.info("Version: {}", version);
+ log.info("Build: {}", build);
+
+ long startTime = System.nanoTime();
+
+ Emulator.runtime = Runtime.getRuntime();
+ Emulator.config = new ConfigurationManager("config.ini");
+ Emulator.crypto = new CryptoConfig(
+ Emulator.getConfig().getBoolean("enc.enabled", false),
+ Emulator.getConfig().getValue("enc.e"),
+ Emulator.getConfig().getValue("enc.n"),
+ Emulator.getConfig().getValue("enc.d"));
+ Emulator.database = new Database(Emulator.getConfig());
+ Emulator.databaseLogger = new DatabaseLogger();
+ Emulator.config.loaded = true;
+ Emulator.config.loadFromDatabase();
+ Emulator.threading = new ThreadPooling(Emulator.getConfig().getInt("runtime.threads"));
+ Emulator.getDatabase().getDataSource().setMaximumPoolSize(Emulator.getConfig().getInt("runtime.threads") * 2);
+ Emulator.getDatabase().getDataSource().setMinimumIdle(10);
+ Emulator.pluginManager = new PluginManager();
+ Emulator.pluginManager.reload();
+ Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent());
+ Emulator.texts = new TextsManager();
+ new CleanerThread();
+ Emulator.gameServer = new GameServer(getConfig().getValue("game.host", "127.0.0.1"), getConfig().getInt("game.port", 30000));
+ Emulator.rconServer = new RCONServer(getConfig().getValue("rcon.host", "127.0.0.1"), getConfig().getInt("rcon.port", 30001));
+ Emulator.gameEnvironment = new GameEnvironment();
+ Emulator.gameEnvironment.load();
+ Emulator.gameServer.initializePipeline();
+ Emulator.gameServer.connect();
+ Emulator.rconServer.initializePipeline();
+ Emulator.rconServer.connect();
+ Emulator.badgeImager = new BadgeImager();
+ Emulator.getConfig().register("websockets.whitelist", "localhost");
+ Emulator.getConfig().register("ws.nitro.host", "0.0.0.0");
+ Emulator.getConfig().register("ws.nitro.port", "2096");
+ Emulator.getConfig().register("ws.nitro.ip.header", "");
+ NetworkChannelInitializer wsChannelHandler = new NetworkChannelInitializer();
+ Emulator.getGameServer().getServerBootstrap().childHandler(wsChannelHandler);
+ Emulator.getGameServer().getServerBootstrap().bind(Emulator.getConfig().getValue("ws.nitro.host", "0.0.0.0"), Emulator.getConfig().getInt("ws.nitro.port", 2096)).sync();
+ log.info("Websockets has started!");
+ log.info("Websockets Listening on " + (wsChannelHandler.isSSL() ? "wss://" : "ws://") + Emulator.getConfig().getValue("ws.nitro.host", "0.0.0.0") + ":" + Emulator.getConfig().getInt("ws.nitro.port", 2096));
+ 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));
+
+ 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);
+ }
+
+ Emulator.getPluginManager().fireEvent(new EmulatorLoadedEvent());
+ Emulator.isReady = true;
+ 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.",
+ Emulator.getConfig().getInt("runtime.threads"),
+ Runtime.getRuntime().availableProcessors() * 2);
+ }
+
+ Emulator.getThreading().run(() -> {
+ }, 1500);
+
+ // Check if console mode is true or false, default is true
+ if (Emulator.getConfig().getBoolean("console.mode", true)) {
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+
+ while (!isShuttingDown && isReady) {
+ try {
+ String line = reader.readLine();
+
+ if (line != null) {
+ ConsoleCommand.handle(line);
+ }
+ 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);
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void setBuild() {
+ if (Emulator.class.getProtectionDomain().getCodeSource() == null) {
+ build = "UNKNOWN";
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ try {
+ String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
+ MessageDigest md = MessageDigest.getInstance("MD5");// MD5
+ FileInputStream fis = new FileInputStream(filepath);
+ byte[] dataBytes = new byte[1024];
+ int nread = 0;
+ while ((nread = fis.read(dataBytes)) != -1)
+ md.update(dataBytes, 0, nread);
+ byte[] mdbytes = md.digest();
+ for (int i = 0; i < mdbytes.length; i++)
+ sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
+ } catch (Exception e) {
+ build = "UNKNOWN";
+ return;
+ }
+
+ build = sb.toString();
+ }
+
+ private static void dispose() {
+ Emulator.getThreading().setCanAdd(false);
+ Emulator.isShuttingDown = true;
+ Emulator.isReady = false;
+
+ log.info("Stopping Arcturus Morningstar {}", version);
+
+ try {
+ if (Emulator.getPluginManager() != null)
+ Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent());
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.cameraClient != null)
+ Emulator.cameraClient.disconnect();
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.rconServer != null)
+ Emulator.rconServer.stop();
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.gameEnvironment != null)
+ Emulator.gameEnvironment.dispose();
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.getPluginManager() != null)
+ Emulator.getPluginManager().fireEvent(new EmulatorStoppedEvent());
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.pluginManager != null)
+ Emulator.pluginManager.dispose();
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.config != null) {
+ Emulator.config.saveToDatabase();
+ }
+ } catch (Exception e) {
+ }
+
+ try {
+ if (Emulator.gameServer != null)
+ Emulator.gameServer.stop();
+ } catch (Exception e) {
+ }
+
+ log.info("Stopped Arcturus Morningstar {}", version);
+
+ if (Emulator.database != null) {
+ Emulator.getDatabase().dispose();
+ }
+ Emulator.stopped = true;
+
+ // if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
+ // AnsiConsole.systemUninstall();
+ // }
+ try {
+ if (Emulator.threading != null)
+
+ Emulator.threading.shutDown();
+ } catch (Exception e) {
+ }
+ }
+
+ public static ConfigurationManager getConfig() {
+ return config;
+ }
+
+ public static CryptoConfig getCrypto() {
+ return crypto;
+ }
+
+ public static TextsManager getTexts() {
+ return texts;
+ }
+
+ public static Database getDatabase() {
+ return database;
+ }
+
+ public static DatabaseLogger getDatabaseLogger() {
+ return databaseLogger;
+ }
+
+ public static Runtime getRuntime() {
+ return runtime;
+ }
+
+ public static GameServer getGameServer() {
+ return gameServer;
+ }
+
+ public static RCONServer getRconServer() {
+ return rconServer;
+ }
+
+ public void onUserGetIPEvent(UserGetIPAddressEvent e) {
+ Channel channel = e.habbo.getClient().getChannel();
+ if(channel != null && channel.hasAttr(Emulator.WS_IP)) {
+ String ip = channel.attr(Emulator.WS_IP).get();
+ if(!ip.isEmpty()) {
+ e.setUpdatedIp(ip);
+ }
+ }
+ }
+
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
+ public static Logging getLogging() {
+ return logging;
+ }
+
+ public static ThreadPooling getThreading() {
+ return threading;
+ }
+
+ public static GameEnvironment getGameEnvironment() {
+ return gameEnvironment;
+ }
+
+ public static PluginManager getPluginManager() {
+ return pluginManager;
+ }
+
+ public static Random getRandom() {
+ return ThreadLocalRandom.current();
+ }
+
+ public static SecureRandom getRandomDice() {
+ return secureRandom;
+ }
+
+ public static BadgeImager getBadgeImager() {
+ return badgeImager;
+ }
+
+ public static CameraClient getCameraClient() {
+ return cameraClient;
+ }
+
+ public static synchronized void setCameraClient(CameraClient client) {
+ cameraClient = client;
+ }
+
+ public static int getTimeStarted() {
+ return timeStarted;
+ }
+
+ public static int getOnlineTime() {
+ return getIntUnixTimestamp() - timeStarted;
+ }
+
+ public static void prepareShutdown() {
+ System.exit(0);
+ }
+
+ public static int timeStringToSeconds(String timeString) {
+ int totalSeconds = 0;
+
+ Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
+ Map map = new HashMap() {
+ {
+ put("second", 1);
+ put("minute", 60);
+ put("hour", 3600);
+ put("day", 86400);
+ put("week", 604800);
+ put("month", 2628000);
+ put("year", 31536000);
+ }
+ };
+
+ while (m.find()) {
+ try {
+ int amount = Integer.parseInt(m.group(2));
+ String what = m.group(3);
+ totalSeconds += amount * map.get(what);
+ }
+ catch (Exception ignored) { }
+ }
+
+ return totalSeconds;
+ }
+
+ public static Date modifyDate(Date date, String timeString) {
+ int totalSeconds = 0;
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+
+ Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
+ Map map = new HashMap() {
+ {
+ put("second", Calendar.SECOND);
+ put("minute", Calendar.MINUTE);
+ put("hour", Calendar.HOUR);
+ put("day", Calendar.DAY_OF_MONTH);
+ put("week", Calendar.WEEK_OF_MONTH);
+ put("month", Calendar.MONTH);
+ put("year", Calendar.YEAR);
+ }
+ };
+
+ while (m.find()) {
+ try {
+ int amount = Integer.parseInt(m.group(2));
+ String what = m.group(3);
+ c.add(map.get(what), amount);
+ }
+ catch (Exception ignored) { }
+ }
+
+ return c.getTime();
+ }
+
+ private static String dateToUnixTimestamp(Date date) {
+ String res = "";
+ Date aux = stringToDate("1970-01-01 00:00:00");
+ Timestamp aux1 = dateToTimeStamp(aux);
+ Timestamp aux2 = dateToTimeStamp(date);
+ long difference = aux2.getTime() - aux1.getTime();
+ long seconds = difference / 1000L;
+ return res + seconds;
+ }
+
+ public static Date stringToDate(String date) {
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date res = null;
+ try {
+ res = format.parse(date);
+ } catch (Exception e) {
+ log.error("Error parsing date", e);
+ }
+ return res;
+ }
+
+ public static Timestamp dateToTimeStamp(Date date) {
+ return new Timestamp(date.getTime());
+ }
+
+ public static Date getDate() {
+ return new Date(System.currentTimeMillis());
+ }
+
+ public static String getUnixTimestamp() {
+ return dateToUnixTimestamp(getDate());
+ }
+
+ public static int getIntUnixTimestamp() {
+ return (int) (System.currentTimeMillis() / 1000);
+ }
+
+ public static boolean isNumeric(String string)
+ throws IllegalArgumentException {
+ boolean isnumeric = false;
+ if ((string != null) && (!string.equals(""))) {
+ isnumeric = true;
+ char[] chars = string.toCharArray();
+ for (char aChar : chars) {
+ isnumeric = Character.isDigit(aChar);
+ if (!isnumeric) {
+ break;
+ }
+ }
+ }
+ return isnumeric;
+ }
+
+ public int getUserCount() {
+ return gameEnvironment.getHabboManager().getOnlineCount();
+ }
+
+ public int getRoomCount() {
+ return gameEnvironment.getRoomManager().getActiveRooms().size();
+ }
+}
diff --git a/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java b/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java
new file mode 100644
index 0000000..04ee5f4
--- /dev/null
+++ b/Emulator/src/main/java/com/eu/habbo/core/CleanerThread.java
@@ -0,0 +1,160 @@
+package com.eu.habbo.core;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.messages.incoming.friends.SearchUserEvent;
+import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent;
+import com.eu.habbo.messages.outgoing.users.UserDataComposer;
+import com.eu.habbo.threading.runnables.AchievementUpdater;
+import lombok.extern.slf4j.Slf4j;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Map;
+
+@Slf4j
+public class CleanerThread implements Runnable {
+
+ 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 CLEAR_CACHED_VALUES = 60 * 60;
+ private static final int CALLBACK_TIME = 60 * 15;
+
+ private static int LAST_HOF_RELOAD = Emulator.getIntUnixTimestamp();
+ private static int LAST_NL_RELOAD = Emulator.getIntUnixTimestamp();
+ private static int LAST_INACTIVE_ROOMS_CLEARED = Emulator.getIntUnixTimestamp();
+ private static int LAST_INACTIVE_GUILDS_CLEARED = Emulator.getIntUnixTimestamp();
+ private static int LAST_INACTIVE_TOURS_CLEARED = Emulator.getIntUnixTimestamp();
+ private static int LAST_DAILY_REFILL = Emulator.getIntUnixTimestamp();
+ private static int LAST_CALLBACK = Emulator.getIntUnixTimestamp();
+ private static int LAST_HABBO_CACHE_CLEARED = Emulator.getIntUnixTimestamp();
+
+ public CleanerThread() {
+ this.databaseCleanup();
+ Emulator.getThreading().run(this, DELAY);
+
+ Emulator.getThreading().run(new AchievementUpdater());
+
+ // Emulator.getThreading().run(new HTTPVersionCheck(), 10000);
+ }
+
+ @Override
+ public void run() {
+ Emulator.getThreading().run(this, DELAY);
+
+ int time = Emulator.getIntUnixTimestamp();
+
+ if (time - LAST_HOF_RELOAD > RELOAD_HALL_OF_FAME) {
+ Emulator.getGameEnvironment().getHotelViewManager().getHallOfFame().reload();
+ LAST_HOF_RELOAD = time;
+ }
+
+ if (time - LAST_NL_RELOAD > RELOAD_NEWS_LIST) {
+ Emulator.getGameEnvironment().getHotelViewManager().getNewsList().reload();
+ LAST_NL_RELOAD = time;
+ }
+
+ if (time - LAST_INACTIVE_ROOMS_CLEARED > REMOVE_INACTIVE_ROOMS) {
+ Emulator.getGameEnvironment().getRoomManager().clearInactiveRooms();
+ LAST_INACTIVE_ROOMS_CLEARED = time;
+ }
+
+ if (time - LAST_INACTIVE_GUILDS_CLEARED > REMOVE_INACTIVE_GUILDS) {
+ Emulator.getGameEnvironment().getGuildManager().clearInactiveGuilds();
+ ForumThread.clearCache();
+ LAST_INACTIVE_GUILDS_CLEARED = time;
+ }
+
+ if (time - LAST_INACTIVE_TOURS_CLEARED > REMOVE_INACTIVE_TOURS) {
+ Emulator.getGameEnvironment().getGuideManager().cleanup();
+ LAST_INACTIVE_TOURS_CLEARED = time;
+ }
+
+ if (time - LAST_CALLBACK > CALLBACK_TIME) {
+ // Emulator.getThreading().run(new HTTPPostStatus());
+ LAST_CALLBACK = time;
+ }
+
+ if (time - LAST_DAILY_REFILL > Emulator.getConfig().getInt("hotel.refill.daily")) {
+ this.refillDailyRespects();
+ LAST_DAILY_REFILL = time;
+ }
+
+ if (time - LAST_HABBO_CACHE_CLEARED > CLEAR_CACHED_VALUES) {
+ this.clearCachedValues();
+ LAST_HABBO_CACHE_CLEARED = time;
+ }
+
+ SearchRoomsEvent.cachedResults.clear();
+ SearchUserEvent.cachedResults.clear();
+ }
+
+
+ void databaseCleanup() {
+ this.refillDailyRespects();
+
+ int time = Emulator.getIntUnixTimestamp();
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
+ try (Statement statement = connection.createStatement()) {
+ statement.execute("UPDATE users SET online = '0' WHERE online = '1'");
+ statement.execute("UPDATE rooms SET users = '0' WHERE users > 0");
+ statement.execute("DELETE FROM room_mutes WHERE ends < " + time);
+ statement.execute("DELETE FROM room_bans WHERE ends < " + time);
+ statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL");
+ }
+
+ try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp + duration < ? AND activation_timestamp > 0 AND duration > 0")) {
+ statement.setInt(1, Emulator.getIntUnixTimestamp());
+ statement.execute();
+ }
+
+ try (Statement statement = connection.createStatement()) {
+ statement.execute("DELETE FROM users_effects WHERE total <= 0");
+ }
+ } catch (SQLException e) {
+ log.error("Caught SQL exception", e);
+ }
+
+ log.info("Database -> Cleaned!");
+ }
+
+ public void refillDailyRespects() {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET daily_respect_points = ?, daily_pet_respect_points = ?")) {
+ statement.setInt(1, Emulator.getConfig().getInt("hotel.daily.respect"));
+ statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets"));
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ log.error("Caught SQL exception", e);
+ }
+
+ if (Emulator.isReady) {
+ for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) {
+ habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect");
+ habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets");
+ habbo.getClient().sendResponse(new UserDataComposer(habbo));
+ }
+ }
+ }
+
+ private void clearCachedValues() {
+ Habbo habbo;
+ for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
+ habbo = map.getValue();
+
+ try {
+ if (habbo != null) {
+ habbo.clearCaches();
+ }
+ } catch (Exception e) {
+ log.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
new file mode 100644
index 0000000..a0039a5
--- /dev/null
+++ b/Emulator/src/main/java/com/eu/habbo/core/CommandLog.java
@@ -0,0 +1,41 @@
+package com.eu.habbo.core;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+public class CommandLog implements DatabaseLoggable {
+
+ private static final String INSERT_QUERY = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)";
+
+ private final int userId;
+ private final int timestamp = Emulator.getIntUnixTimestamp();
+ private final Command command;
+ private final String params;
+ private final boolean success;
+
+ public CommandLog(int userId, Command command, String params, boolean success) {
+ this.userId = userId;
+ this.command = command;
+ this.params = params;
+ this.success = success;
+ }
+
+ @Override
+ public String getQuery() {
+ return CommandLog.INSERT_QUERY;
+ }
+
+ @Override
+ public void log(PreparedStatement statement) throws SQLException {
+ statement.setInt(1, this.userId);
+ 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.addBatch();
+ }
+
+}
\ No newline at end of file
diff --git a/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java
new file mode 100644
index 0000000..e583ea0
--- /dev/null
+++ b/Emulator/src/main/java/com/eu/habbo/core/ConfigurationManager.java
@@ -0,0 +1,226 @@
+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 java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.*;
+import java.util.Map;
+import java.util.Properties;
+
+@Slf4j
+public class ConfigurationManager {
+
+ private final Properties properties;
+ private final String configurationPath;
+ public boolean loaded = false;
+ public boolean isLoading = false;
+
+ public ConfigurationManager(String configurationPath) {
+ this.properties = new Properties();
+ this.configurationPath = configurationPath;
+ this.reload();
+ }
+
+ public void reload() {
+ this.isLoading = true;
+ this.properties.clear();
+
+ InputStream input = null;
+
+ String envDbHostname = System.getenv("DB_HOSTNAME");
+
+ boolean useEnvVarsForDbConnection = false;
+
+ if(envDbHostname != null)
+ {
+ useEnvVarsForDbConnection = envDbHostname.length() > 1;
+ }
+
+ if (!useEnvVarsForDbConnection) {
+ try {
+ File f = new File(this.configurationPath);
+ input = new FileInputStream(f);
+ this.properties.load(input);
+
+ } catch (IOException ex) {
+ log.error("Failed to load config file.", ex);
+ ex.printStackTrace();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ } else {
+
+ Map envMapping = new THashMap<>();
+
+ // Database section
+ envMapping.put("db.hostname", "DB_HOSTNAME");
+ envMapping.put("db.port", "DB_PORT");
+ envMapping.put("db.database", "DB_DATABASE");
+ envMapping.put("db.username", "DB_USERNAME");
+ envMapping.put("db.password", "DB_PASSWORD");
+ envMapping.put("db.params", "DB_PARAMS");
+
+ // Game Configuration
+ envMapping.put("game.host", "EMU_HOST");
+ envMapping.put("game.port", "EMU_PORT");
+
+ // RCON
+ envMapping.put("rcon.host", "RCON_HOST");
+ envMapping.put("rcon.port", "RCON_PORT");
+ envMapping.put("rcon.allowed", "RCON_ALLOWED");
+
+ // Runtime
+ envMapping.put("runtime.threads", "RT_THREADS");
+ envMapping.put("logging.errors.runtime", "RT_LOG_ERRORS");
+
+ for (Map.Entry entry : envMapping.entrySet()) {
+ String envValue = System.getenv(entry.getValue());
+
+ if (envValue == null || envValue.length() == 0) {
+ log.info("Cannot find environment-value for variable `" + entry.getValue() + "`");
+ } else {
+ this.properties.setProperty(entry.getKey(), envValue);
+ }
+ }
+ }
+
+ if (this.loaded) {
+ this.loadFromDatabase();
+ }
+
+ this.isLoading = false;
+ log.info("Configuration Manager -> Loaded!");
+
+ if (Emulator.getPluginManager() != null) {
+ Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent());
+ }
+ }
+
+ public void loadFromDatabase() {
+ log.info("Loading configuration from database...");
+
+ long millis = System.currentTimeMillis();
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) {
+ if (statement.execute("SELECT * FROM emulator_settings")) {
+ try (ResultSet set = statement.getResultSet()) {
+ while (set.next()) {
+ this.properties.put(set.getString("key"), set.getString("value"));
+ }
+ }
+ }
+ } catch (SQLException e) {
+ log.error("Caught SQL exception", e);
+ }
+
+ log.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ }
+
+ public void saveToDatabase() {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE emulator_settings SET `value` = ? WHERE `key` = ? LIMIT 1")) {
+ for (Map.Entry