diff --git a/.gitignore b/.gitignore
index 04b8b762..94c0cbd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,11 +6,12 @@ target/**
TODO.txt
packet.pkt
plugins/**
-src/main/resources/
src/test/
target/
config.ini
*.txt
*.jar
*.log
-*.zip
\ No newline at end of file
+*.zip
+.DS_Store
+
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a0cacc72..e1d0de35 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,18 @@
image: maven:latest
-cache:
- paths:
- - target/
+stages:
+ - build
build:
+ stage: build
script:
- mvn package
only:
- - dev
- - master
+ changes:
+ - src/**/*
+ - pom.xml
artifacts:
- paths:
- - target/Habbo-*.jar
\ No newline at end of file
+ expire_in: 2 weeks
+ paths:
+ - target/Habbo-*.jar
+
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..efe4ac3e
--- /dev/null
+++ b/.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/README.md b/README.md
index 112dd0da..8a4a8145 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha
Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
## Versions ##
-![image](https://img.shields.io/badge/VERSION-2.3.2-success.svg?style=for-the-badge&logo=appveyor)
-![image](https://img.shields.io/badge/STATUS-STABLE-green.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/VERSION-2.4.0-success.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor)
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases
@@ -34,6 +34,8 @@ When making an bug report or a feature request use the template we provide so th
- Skeletor
- z
- ArpyAge
+- Mike
+
## Discord ##
Join us on Discord at https://discord.gg/BzfFsTp
diff --git a/pom.xml b/pom.xml
index 374a7b6a..35de71dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.eu.habbo
Habbo
- 2.3.2
+ 2.4.0
UTF-8
@@ -32,7 +32,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.3
+ 3.8.1
1.8
@@ -42,7 +42,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- 2.4.1
+ 3.3.0
jar-with-dependencies
@@ -67,7 +67,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.0.0
+ 3.2.0
-Xdoclint:none
public
@@ -92,50 +92,21 @@
io.netty
netty-all
- 4.1.36.Final
-
-
-
-
- org.fusesource.jansi
- jansi
- 1.18
-
-
-
-
- io.netty
- netty-codec-http
- 4.1.36.Final
- compile
-
-
-
- io.netty
- netty-codec-http2
- 4.1.36.Final
- compile
-
-
-
- io.netty
- netty-handler
- 4.1.36.Final
- compile
+ 4.1.49.Final
com.google.code.gson
gson
- 2.8.4
+ 2.8.6
mysql
mysql-connector-java
- 5.1.46
+ 5.1.49
runtime
@@ -151,16 +122,17 @@
com.zaxxer
HikariCP
- 3.1.0
+ 3.4.3
compile
org.apache.commons
commons-lang3
- 3.7
+ 3.10
compile
+
org.apache.commons
commons-math3
@@ -171,35 +143,27 @@
org.jsoup
jsoup
- 1.11.3
+ 1.13.1
compile
- org.slf4j
- slf4j-api
- 1.7.25
+ ch.qos.logback
+ logback-classic
+ 1.2.3
+ compile
- org.slf4j
- slf4j-simple
- 1.7.25
+ org.fusesource.jansi
+ jansi
+ 1.18
joda-time
joda-time
- 2.9.9
+ 2.10.6
-
-
-
-
- internal.repo
- Internal repo
- file:///home/thara/testesb/in
-
-
\ No newline at end of file
diff --git a/sqlupdates/1_0_6_TO_1_0_7.sql b/sqlupdates/1_0_6_TO_1_0_7.sql
index 7b15a7fa..0274afa8 100644
--- a/sqlupdates/1_0_6_TO_1_0_7.sql
+++ b/sqlupdates/1_0_6_TO_1_0_7.sql
@@ -1,6 +1,6 @@
#DATABASE UPDATE: 1.0.6 -> 1.0.7
-ALTER TABLE `permissions` ADD `acc_update_notifications` ENUM( '0', '1' ) NOT NULL DEFAULT '0';
+ALTER TABLE `permissions` ADD `"acc_update_notifications"` ENUM( '0', '1' ) NOT NULL DEFAULT '0';
DELETE FROM emulator_settings WHERE `key` LIKE 'emulator.version';
#END DATABASE UPDATE: 1.0.5 -> 1.0.6
\ No newline at end of file
diff --git a/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql
new file mode 100644
index 00000000..3e2d7895
--- /dev/null
+++ b/sqlupdates/2_3_1_TO_2_4_0-RC-1.sql
@@ -0,0 +1,3 @@
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.stickies.max', '200');
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('retro.style.homeroom', '1');
\ No newline at end of file
diff --git a/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql
new file mode 100644
index 00000000..960943ef
--- /dev/null
+++ b/sqlupdates/2_4_0-RC-1 to 2_4_0-RC-2.sql
@@ -0,0 +1,52 @@
+-- Hide email from specific ranks.
+ALTER TABLE `permissions` ADD `acc_hide_mail` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `acc_hide_ip`;
+
+-- Flood with rights.
+INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('flood.with.rights', '0');
+
+-- Softkick command.
+ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`;
+INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick');
+INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found');
+INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!');
+
+-- Rank ignoring
+INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.error.ignore_higher_rank', 'You can\'t ignore this user.');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staffs', '1');
+
+-- Inventory Limiting
+INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('error.bots.max.inventory', 'You can\'t buy or pickup anymore bots until you place some, the maximum amount of bots you are allowed is %amount%.');
+
+UPDATE `emulator_texts` SET `value` = 'You\'ve reached the maximum amount of pets in your inventory! The Limit is %amount%!' WHERE `key` = 'error.pets.max.inventory';
+
+-- Tradelock counter
+ALTER TABLE `users_settings` ADD `tradelock_amount` INT(11) NOT NULL DEFAULT '0' AFTER `helper_level`;
+
+-- Gift wrapping configuration
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.gifts.box_types', '0,1,2,3,4,5,6,8');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.gifts.ribbon_types', '0,1,2,3,4,5,6,7,8,9,10');
+
+-- Configurable mute time
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.flood.mute.time', '30');
+
+-- TraxManager Jukebox Limits
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.jukebox.limit.large', '20');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.jukebox.limit.normal', '10');
+
+-- Background Toner Scripter Warning
+INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('scripter.warning.item.bgtoner.permission', '%username% tried to change the background toner without rights in %room% owned by %owner%');
+
+-- Table structure for room_trax
+DROP TABLE IF EXISTS `room_trax`;
+CREATE TABLE `room_trax` (
+ `room_id` int(11) NOT NULL,
+ `trax_item_id` int(11) NOT NULL
+) ENGINE = InnoDB CHARACTER SET = armscii8 COLLATE = armscii8_general_ci ROW_FORMAT = Compact;
+
+-- Table structure for trax_playlist
+DROP TABLE IF EXISTS `trax_playlist`;
+CREATE TABLE `trax_playlist` (
+ `trax_item_id` int(11) NOT NULL,
+ `item_id` int(11) NOT NULL
+) ENGINE = InnoDB CHARACTER SET = armscii8 COLLATE = armscii8_general_ci ROW_FORMAT = Compact;
+
diff --git a/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql b/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql
new file mode 100644
index 00000000..78ce8842
--- /dev/null
+++ b/sqlupdates/2_4_0-RC-2 to 2_4_0-RC-3.sql
@@ -0,0 +1,2 @@
+-- Recycler value fix
+INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('recycler.value', '8');
\ No newline at end of file
diff --git a/sqlupdates/2_4_0-RC-2 to 2_4_0.sql b/sqlupdates/2_4_0-RC-2 to 2_4_0.sql
new file mode 100644
index 00000000..ea380bc0
--- /dev/null
+++ b/sqlupdates/2_4_0-RC-2 to 2_4_0.sql
@@ -0,0 +1,3 @@
+-- Adds config value for max amount of people to move per roller. Default is like habbo.
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.rollers.roll_avatars.max', '1');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.nux.gifts.enabled', '0');
diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java
index a8a37ee2..9954c318 100644
--- a/src/main/java/com/eu/habbo/Emulator.java
+++ b/src/main/java/com/eu/habbo/Emulator.java
@@ -1,9 +1,9 @@
package com.eu.habbo;
-import com.eu.habbo.core.CleanerThread;
-import com.eu.habbo.core.ConfigurationManager;
-import com.eu.habbo.core.Logging;
-import com.eu.habbo.core.TextsManager;
+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;
@@ -17,7 +17,8 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent;
import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
import com.eu.habbo.threading.ThreadPooling;
import com.eu.habbo.util.imager.badges.BadgeImager;
-import org.fusesource.jansi.AnsiConsole;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.*;
import java.security.MessageDigest;
@@ -26,21 +27,19 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
public final class Emulator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
+ private static final String OS_NAME = System.getProperty("os.name");
+ private static final String CLASS_PATH = System.getProperty("java.class.path");
public final static int MAJOR = 2;
- public final static int MINOR = 3;
- public final static int BUILD = 2;
- public static final String ANSI_RED = "\u001B[31m";
- public static final String ANSI_BLUE = "\u001B[34m";
- public static final String ANSI_PURPLE = "\u001B[35m";
- public static final String ANSI_WHITE = "\u001B[37m";
- public static final String ANSI_YELLOW = "\u001B[33m";
-
-
- public final static String PREVIEW = "RC-3";
+ public final static int MINOR = 4;
+ public final static int BUILD = 0;
+
+ public final static String PREVIEW = "";
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD;
private static final String logo =
@@ -58,21 +57,20 @@ public final class Emulator {
public static boolean isShuttingDown = false;
public static boolean stopped = false;
public static boolean debugging = false;
- private static String classPath = System.getProperty("java.class.path");
- private static String osName = System.getProperty("os.name");
private static int timeStarted = 0;
private static Runtime runtime;
private static ConfigurationManager config;
+ private static CryptoConfig crypto;
private static TextsManager texts;
private static GameServer gameServer;
private static RCONServer rconServer;
private static CameraClient cameraClient;
- private static Database database;
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 Random random;
private static BadgeImager badgeImager;
static {
@@ -87,26 +85,42 @@ public final class Emulator {
public static void main(String[] args) throws Exception {
try {
- if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
- AnsiConsole.systemInstall();
+ // 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(ANSI_PURPLE + logo );
- System.out.println(ANSI_WHITE + "This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
- System.out.println(ANSI_BLUE + "[VERSION] " + ANSI_WHITE + version);
- System.out.println(ANSI_RED + "[BUILD] " + ANSI_WHITE + build + "\n");
- System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq" );
- System.out.println(ANSI_YELLOW + "[KREWS] " + ANSI_WHITE + "Join our discord at https://discord.gg/syuqgN" + "\n");
- random = new Random();
+
+ System.out.println(logo);
+
+ LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
+ LOGGER.info("Version: {}", version);
+ LOGGER.info("Build: {}", build);
+ LOGGER.info("Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq");
+ LOGGER.info("Join our discord at https://discord.gg/syuqgN");
+
long startTime = System.nanoTime();
Emulator.runtime = Runtime.getRuntime();
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"));
@@ -126,13 +140,17 @@ public final class Emulator {
Emulator.rconServer.initializePipeline();
Emulator.rconServer.connect();
Emulator.badgeImager = new BadgeImager();
- Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version);
- Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!");
- Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB");
+
+ LOGGER.info("Arcturus Morningstar has succesfully loaded.");
+ LOGGER.info("System launched in: {}ms. Using {} threads!", (System.nanoTime() - startTime) / 1e6, Runtime.getRuntime().availableProcessors() * 2);
+ LOGGER.info("Memory: {}/{}MB", (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024), (runtime.freeMemory()) / (1024 * 1024));
Emulator.debugging = Emulator.getConfig().getBoolean("debug.mode");
+
if (debugging) {
- Emulator.getLogging().logDebugLine("Debugging Enabled!");
+ ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ root.setLevel(Level.DEBUG);
+ LOGGER.debug("Debugging enabled.");
}
Emulator.getPluginManager().fireEvent(new EmulatorLoadedEvent());
@@ -140,7 +158,9 @@ public final class Emulator {
Emulator.timeStarted = getIntUnixTimestamp();
if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) {
- Emulator.getLogging().logStart("Emulator settings runtime.threads (" + Emulator.getConfig().getInt("runtime.threads") + ") can be increased to " + (Runtime.getRuntime().availableProcessors() * 2) + " to possibly increase performance.");
+ LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to {} to possibly increase performance.",
+ Emulator.getConfig().getInt("runtime.threads"),
+ Runtime.getRuntime().availableProcessors() * 2);
}
@@ -151,7 +171,6 @@ public final class Emulator {
while (!isShuttingDown && isReady) {
try {
-
String line = reader.readLine();
if (line != null) {
@@ -160,7 +179,7 @@ public final class Emulator {
System.out.println("Waiting for command: ");
} catch (Exception e) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Error while reading command", e);
}
}
}
@@ -196,11 +215,12 @@ public final class Emulator {
}
private static void dispose() {
-
Emulator.getThreading().setCanAdd(false);
Emulator.isShuttingDown = true;
Emulator.isReady = false;
- Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "...");
+
+ LOGGER.info("Stopping Arcturus Morningstar {}", version);
+
try {
if (Emulator.getPluginManager() != null)
Emulator.getPluginManager().fireEvent(new EmulatorStartShutdownEvent());
@@ -219,7 +239,6 @@ public final class Emulator {
} catch (Exception e) {
}
-
try {
if (Emulator.gameEnvironment != null)
Emulator.gameEnvironment.dispose();
@@ -238,8 +257,6 @@ public final class Emulator {
} catch (Exception e) {
}
- Emulator.getLogging().saveLogs();
-
try {
if (Emulator.config != null) {
Emulator.config.saveToDatabase();
@@ -252,16 +269,17 @@ public final class Emulator {
Emulator.gameServer.stop();
} catch (Exception e) {
}
- Emulator.getLogging().logShutdownLine("Stopped Arcturus Emulator " + version + "...");
+
+ LOGGER.info("Stopped Arcturus Morningstar {}", version);
if (Emulator.database != null) {
Emulator.getDatabase().dispose();
}
Emulator.stopped = true;
- if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
- AnsiConsole.systemUninstall();
- }
+ // if (osName.startsWith("Windows") && (!classPath.contains("idea_rt.jar"))) {
+ // AnsiConsole.systemUninstall();
+ // }
try {
if (Emulator.threading != null)
@@ -274,6 +292,10 @@ public final class Emulator {
return config;
}
+ public static CryptoConfig getCrypto() {
+ return crypto;
+ }
+
public static TextsManager getTexts() {
return texts;
}
@@ -282,6 +304,10 @@ public final class Emulator {
return database;
}
+ public static DatabaseLogger getDatabaseLogger() {
+ return databaseLogger;
+ }
+
public static Runtime getRuntime() {
return runtime;
}
@@ -294,6 +320,10 @@ 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;
}
@@ -311,7 +341,7 @@ public final class Emulator {
}
public static Random getRandom() {
- return random;
+ return ThreadLocalRandom.current();
}
public static BadgeImager getBadgeImager() {
@@ -354,7 +384,7 @@ public final class Emulator {
try {
res = format.parse(date);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Error parsing date", e);
}
return res;
}
diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java
index 764770d0..b9a721dc 100644
--- a/src/main/java/com/eu/habbo/core/CleanerThread.java
+++ b/src/main/java/com/eu/habbo/core/CleanerThread.java
@@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.friends.SearchUserEvent;
import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent;
import com.eu.habbo.threading.runnables.AchievementUpdater;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -15,57 +17,26 @@ import java.util.Map;
public class CleanerThread implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CleanerThread.class);
- public static final int DELAY = 10000;
-
-
- public static final int RELOAD_HALL_OF_FAME = 1800;
-
-
- public static final int RELOAD_NEWS_LIST = 3600;
-
-
- public static final int REMOVE_INACTIVE_ROOMS = 120;
-
-
- public static final int REMOVE_INACTIVE_GUILDS = 60;
-
-
- public static final int REMOVE_INACTIVE_TOURS = 600;
-
-
- public static final int SAVE_ERROR_LOGS = 30;
-
-
- public static final int CLEAR_CACHED_VALUES = 60 * 60;
-
-
+ private static final int DELAY = 10000;
+ private static final int RELOAD_HALL_OF_FAME = 1800;
+ private static final int RELOAD_NEWS_LIST = 3600;
+ private static final int REMOVE_INACTIVE_ROOMS = 120;
+ private static final int REMOVE_INACTIVE_GUILDS = 60;
+ private static final int REMOVE_INACTIVE_TOURS = 600;
+ private static final int SAVE_ERROR_LOGS = 30;
+ private static final int CLEAR_CACHED_VALUES = 60 * 60;
private static final int CALLBACK_TIME = 60 * 15;
-
private static int LAST_HOF_RELOAD = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_NL_RELOAD = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_INACTIVE_ROOMS_CLEARED = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_INACTIVE_GUILDS_CLEARED = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_INACTIVE_TOURS_CLEARED = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_ERROR_LOGS_SAVED = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_DAILY_REFILL = Emulator.getIntUnixTimestamp();
-
private static int LAST_CALLBACK = Emulator.getIntUnixTimestamp();
-
-
private static int LAST_HABBO_CACHE_CLEARED = Emulator.getIntUnixTimestamp();
public CleanerThread() {
@@ -110,7 +81,7 @@ public class CleanerThread implements Runnable {
}
if (time - LAST_ERROR_LOGS_SAVED > SAVE_ERROR_LOGS) {
- Emulator.getLogging().saveLogs();
+ Emulator.getDatabaseLogger().save();
LAST_ERROR_LOGS_SAVED = time;
}
@@ -156,9 +127,10 @@ public class CleanerThread implements Runnable {
statement.execute("DELETE FROM users_effects WHERE total <= 0");
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
- Emulator.getLogging().logStart("Database -> Cleaned!");
+
+ LOGGER.info("Database -> Cleaned!");
}
public void refillDailyRespects() {
@@ -167,7 +139,7 @@ public class CleanerThread implements Runnable {
statement.setInt(2, Emulator.getConfig().getInt("hotel.daily.respect.pets"));
statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
if (Emulator.isReady) {
@@ -188,7 +160,7 @@ public class CleanerThread implements Runnable {
habbo.clearCaches();
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/CommandLog.java b/src/main/java/com/eu/habbo/core/CommandLog.java
index 1f4cefbc..1dfb2847 100644
--- a/src/main/java/com/eu/habbo/core/CommandLog.java
+++ b/src/main/java/com/eu/habbo/core/CommandLog.java
@@ -6,8 +6,9 @@ import com.eu.habbo.habbohotel.commands.Command;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-public class CommandLog implements Loggable {
- public static final String insertQuery = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)";
+public class CommandLog implements DatabaseLoggable {
+
+ private static final String INSERT_QUERY = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)";
private final int userId;
private final int timestamp = Emulator.getIntUnixTimestamp();
@@ -15,7 +16,6 @@ public class CommandLog implements Loggable {
private final String params;
private final boolean succes;
-
public CommandLog(int userId, Command command, String params, boolean succes) {
this.userId = userId;
this.command = command;
@@ -23,6 +23,11 @@ public class CommandLog implements Loggable {
this.succes = succes;
}
+ @Override
+ public String getQuery() {
+ return CommandLog.INSERT_QUERY;
+ }
+
@Override
public void log(PreparedStatement statement) throws SQLException {
statement.setInt(1, this.userId);
@@ -32,4 +37,5 @@ public class CommandLog implements Loggable {
statement.setString(5, this.succes ? "yes" : "no");
statement.addBatch();
}
+
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/ConfigurationManager.java b/src/main/java/com/eu/habbo/core/ConfigurationManager.java
index 446c028f..19b442fe 100644
--- a/src/main/java/com/eu/habbo/core/ConfigurationManager.java
+++ b/src/main/java/com/eu/habbo/core/ConfigurationManager.java
@@ -2,6 +2,9 @@ package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
+import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
@@ -13,38 +16,85 @@ import java.util.Properties;
public class ConfigurationManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class);
+
private final Properties properties;
private final String configurationPath;
public boolean loaded = false;
public boolean isLoading = false;
- public ConfigurationManager(String configurationPath) throws Exception {
+ 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;
- try {
- File f = new File(this.configurationPath);
- input = new FileInputStream(f);
- this.properties.load(input);
+ String envDbHostname = System.getenv("DB_HOSTNAME");
- } catch (IOException ex) {
- Emulator.getLogging().logErrorLine("[CRITICAL] FAILED TO LOAD CONFIG FILE! (" + this.configurationPath + ")");
- ex.printStackTrace();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
+ 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) {
+ LOGGER.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) {
+ LOGGER.info("Cannot find environment-value for variable `" + entry.getValue() + "`");
+ } else {
+ this.properties.setProperty(entry.getKey(), envValue);
}
}
}
@@ -54,16 +104,15 @@ public class ConfigurationManager {
}
this.isLoading = false;
- Emulator.getLogging().logStart("Configuration Manager -> Loaded!");
+ LOGGER.info("Configuration Manager -> Loaded!");
if (Emulator.getPluginManager() != null) {
Emulator.getPluginManager().fireEvent(new EmulatorConfigUpdatedEvent());
}
}
-
public void loadFromDatabase() {
- Emulator.getLogging().logStart("Loading configuration from database...");
+ LOGGER.info("Loading configuration from database...");
long millis = System.currentTimeMillis();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement()) {
@@ -75,10 +124,10 @@ public class ConfigurationManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
- Emulator.getLogging().logStart("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Configuration -> loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public void saveToDatabase() {
@@ -89,7 +138,7 @@ public class ConfigurationManager {
statement.executeUpdate();
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -104,17 +153,15 @@ public class ConfigurationManager {
return defaultValue;
if (!this.properties.containsKey(key)) {
- Emulator.getLogging().logErrorLine("[CONFIG] Key not found: " + key);
+ LOGGER.error("Config key not found {}", key);
}
return this.properties.getProperty(key, defaultValue);
}
-
public boolean getBoolean(String key) {
return this.getBoolean(key, false);
}
-
public boolean getBoolean(String key, boolean defaultValue) {
if (this.isLoading)
return defaultValue;
@@ -122,17 +169,15 @@ public class ConfigurationManager {
try {
return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true"));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type boolean.");
+ LOGGER.error("Failed to parse key {} with value '{}' to type boolean.", key, this.getValue(key));
}
return defaultValue;
}
-
public int getInt(String key) {
return this.getInt(key, 0);
}
-
public int getInt(String key, Integer defaultValue) {
if (this.isLoading)
return defaultValue;
@@ -140,17 +185,15 @@ public class ConfigurationManager {
try {
return Integer.parseInt(this.getValue(key, defaultValue.toString()));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type integer.");
+ LOGGER.error("Failed to parse key {} with value '{}' to type integer.", key, this.getValue(key));
}
return defaultValue;
}
-
public double getDouble(String key) {
return this.getDouble(key, 0.0);
}
-
public double getDouble(String key, Double defaultValue) {
if (this.isLoading)
return defaultValue;
@@ -158,13 +201,12 @@ public class ConfigurationManager {
try {
return Double.parseDouble(this.getValue(key, defaultValue.toString()));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type double.");
+ LOGGER.error("Failed to parse key {} with value '{}' to type double.", key, this.getValue(key));
}
return defaultValue;
}
-
public void update(String key, String value) {
this.properties.setProperty(key, value);
}
@@ -178,9 +220,9 @@ public class ConfigurationManager {
statement.setString(2, value);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.update(key, value);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
index ce136ede..d5442bbf 100644
--- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
@@ -2,11 +2,15 @@ package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
public class CreditsScheduler extends Scheduler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CreditsScheduler.class);
+
public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED;
@@ -48,7 +52,7 @@ public class CreditsScheduler extends Scheduler {
habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount());
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/CryptoConfig.java b/src/main/java/com/eu/habbo/core/CryptoConfig.java
new file mode 100644
index 00000000..28fbe7cd
--- /dev/null
+++ b/src/main/java/com/eu/habbo/core/CryptoConfig.java
@@ -0,0 +1,33 @@
+package com.eu.habbo.core;
+
+public class CryptoConfig {
+
+ private final boolean enabled;
+ private final String exponent;
+ private final String modulus;
+ private final String privateExponent;
+
+ public CryptoConfig(boolean enabled, String exponent, String modulus, String privateExponent) {
+ this.enabled = enabled;
+ this.exponent = exponent;
+ this.modulus = modulus;
+ this.privateExponent = privateExponent;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public String getExponent() {
+ return exponent;
+ }
+
+ public String getModulus() {
+ return modulus;
+ }
+
+ public String getPrivateExponent() {
+ return privateExponent;
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/core/Loggable.java b/src/main/java/com/eu/habbo/core/DatabaseLoggable.java
similarity index 71%
rename from src/main/java/com/eu/habbo/core/Loggable.java
rename to src/main/java/com/eu/habbo/core/DatabaseLoggable.java
index 90826717..821ea7aa 100644
--- a/src/main/java/com/eu/habbo/core/Loggable.java
+++ b/src/main/java/com/eu/habbo/core/DatabaseLoggable.java
@@ -3,6 +3,10 @@ package com.eu.habbo.core;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-public interface Loggable {
+public interface DatabaseLoggable {
+
+ String getQuery();
+
void log(PreparedStatement statement) throws SQLException;
-}
\ No newline at end of file
+
+}
diff --git a/src/main/java/com/eu/habbo/core/DatabaseLogger.java b/src/main/java/com/eu/habbo/core/DatabaseLogger.java
new file mode 100644
index 00000000..2f8806a9
--- /dev/null
+++ b/src/main/java/com/eu/habbo/core/DatabaseLogger.java
@@ -0,0 +1,46 @@
+package com.eu.habbo.core;
+
+import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class DatabaseLogger {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseLogger.class);
+
+ private final ConcurrentLinkedQueue loggables = new ConcurrentLinkedQueue<>();
+
+ public void store(DatabaseLoggable loggable) {
+ this.loggables.add(loggable);
+ }
+
+ public void save() {
+ if (Emulator.getDatabase() == null || Emulator.getDatabase().getDataSource() == null) {
+ return;
+ }
+
+ if (this.loggables.isEmpty()) {
+ return;
+ }
+
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
+ while (!this.loggables.isEmpty()) {
+ DatabaseLoggable loggable = this.loggables.remove();
+
+ try (PreparedStatement statement = connection.prepareStatement(loggable.getQuery())) {
+ loggable.log(statement);
+ statement.executeBatch();
+ }
+
+ }
+ } catch (SQLException e) {
+ LOGGER.error("Exception caught while saving loggables to database.", e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/core/ErrorLog.java b/src/main/java/com/eu/habbo/core/ErrorLog.java
index 44d0176f..f0d62072 100644
--- a/src/main/java/com/eu/habbo/core/ErrorLog.java
+++ b/src/main/java/com/eu/habbo/core/ErrorLog.java
@@ -1,6 +1,8 @@
package com.eu.habbo.core;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.PrintWriter;
@@ -8,9 +10,11 @@ import java.io.StringWriter;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+public class ErrorLog implements DatabaseLoggable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ErrorLog.class);
+ private static final String QUERY = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)";
-public class ErrorLog implements Loggable {
- public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)";
public final String version;
public final String buildHash;
@@ -19,7 +23,6 @@ public class ErrorLog implements Loggable {
public final String stackTrace;
public ErrorLog(String type, Throwable e) {
-
this.version = Emulator.version;
this.buildHash = Emulator.version;
@@ -35,7 +38,7 @@ public class ErrorLog implements Loggable {
pw.close();
sw.close();
} catch (IOException e1) {
- Emulator.getLogging().logErrorLine(e1);
+ LOGGER.error("Exception caught", e1);
}
}
@@ -48,6 +51,11 @@ public class ErrorLog implements Loggable {
this.stackTrace = message;
}
+ @Override
+ public String getQuery() {
+ return QUERY;
+ }
+
@Override
public void log(PreparedStatement statement) throws SQLException {
statement.setInt(1, this.timeStamp);
diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
index 4a85969e..58b3acc7 100644
--- a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
@@ -2,11 +2,15 @@ package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
public class GotwPointsScheduler extends Scheduler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GotwPointsScheduler.class);
+
public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED;
public static String GOTW_POINTS_NAME;
@@ -63,7 +67,7 @@ public class GotwPointsScheduler extends Scheduler {
}
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/Logging.java b/src/main/java/com/eu/habbo/core/Logging.java
index c364f2ec..b1384a42 100644
--- a/src/main/java/com/eu/habbo/core/Logging.java
+++ b/src/main/java/com/eu/habbo/core/Logging.java
@@ -1,338 +1,97 @@
package com.eu.habbo.core;
import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
-import gnu.trove.set.hash.THashSet;
-import io.netty.util.internal.ConcurrentSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Logging {
- public static final String ANSI_BRIGHT = "\u001B[1m";
- public static final String ANSI_ITALICS = "\u001B[3m";
- public static final String ANSI_UNDERLINE = "\u001B[4m";
- public static final String ANSI_RESET = "\u001B[0m";
- public static final String ANSI_BLACK = "\u001B[30m";
- public static final String ANSI_RED = "\u001B[31m";
- public static final String ANSI_GREEN = "\u001B[32m";
- public static final String ANSI_YELLOW = "\u001B[33m";
- public static final String ANSI_BLUE = "\u001B[34m";
- public static final String ANSI_PURPLE = "\u001B[35m";
- public static final String ANSI_CYAN = "\u001B[36m";
- public static final String ANSI_WHITE = "\u001B[37m";
- private static PrintWriter packetsWriter;
- private static PrintWriter packetsUndefinedWriter;
- private static PrintWriter errorsPacketsWriter;
- private static PrintWriter errorsSQLWriter;
- private static PrintWriter errorsRuntimeWriter;
- private static PrintWriter debugFileWriter;
- private final THashSet errorLogs = new THashSet<>(100);
-
-
- private final THashSet commandLogs = new THashSet<>(100);
-
- private ConcurrentSet chatLogs = new ConcurrentSet<>();
-
- public Logging() {
-
- File packets = new File("logging//packets//defined.txt");
-
- File packetsUndefined = new File("logging//packets//packets.txt");
-
- File errorsPackets = new File("logging//errors//packets.txt");
-
- File errorsSQL = new File("logging//errors//sql.txt");
-
- File errorsRuntime = new File("logging//errors//runtime.txt");
-
- File debugFile = new File("logging//debug.txt");
-
- try {
- if (!packets.exists()) {
- if (!packets.getParentFile().exists()) {
- packets.getParentFile().mkdirs();
- }
-
- packets.createNewFile();
- }
-
- if (!packetsUndefined.exists()) {
- if (!packetsUndefined.getParentFile().exists()) {
- packetsUndefined.getParentFile().mkdirs();
- }
-
- packetsUndefined.createNewFile();
- }
-
- if (!errorsPackets.exists()) {
- if (!errorsPackets.getParentFile().exists()) {
- errorsPackets.getParentFile().mkdirs();
- }
-
- errorsPackets.createNewFile();
- }
-
- if (!errorsSQL.exists()) {
- if (!errorsSQL.getParentFile().exists()) {
- errorsSQL.getParentFile().mkdirs();
- }
-
- errorsSQL.createNewFile();
- }
-
- if (!errorsRuntime.exists()) {
- if (!errorsRuntime.getParentFile().exists()) {
- errorsRuntime.getParentFile().mkdirs();
- }
-
- errorsRuntime.createNewFile();
- }
-
- if (!debugFile.exists()) {
- if (!debugFile.getParentFile().exists()) {
- debugFile.getParentFile().mkdirs();
- }
-
- debugFile.createNewFile();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- try {
- packetsWriter = new PrintWriter(new FileWriter(packets, true));
- packetsUndefinedWriter = new PrintWriter(new FileWriter(packetsUndefined, true));
- errorsPacketsWriter = new PrintWriter(new FileWriter(errorsPackets, true));
- errorsSQLWriter = new PrintWriter(new FileWriter(errorsSQL, true));
- errorsRuntimeWriter = new PrintWriter(new FileWriter(errorsRuntime, true));
- debugFileWriter = new PrintWriter(new FileWriter(debugFile, true));
- } catch (IOException e) {
- System.out.println("[CRITICAL] FAILED TO LOAD LOGGING COMPONENT!");
- }
- }
-
- public static PrintWriter getPacketsWriter() {
- return packetsWriter;
- }
-
- public static PrintWriter getPacketsUndefinedWriter() {
- return packetsUndefinedWriter;
- }
+ 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) {
- System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "LOADING" + Logging.ANSI_RESET + "] " + line.toString());
+ LOGGER.info("[LOADING] {}", line);
}
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
public void logShutdownLine(Object line) {
- if (Emulator.getConfig().getBoolean("logging.debug")) {
- this.write(debugFileWriter, line.toString());
- }
- System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_RED + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
+ LOGGER.info("[SHUTDOWN] {}", line);
}
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
public void logUserLine(Object line) {
- if (Emulator.getConfig().getBoolean("logging.debug")) {
- this.write(debugFileWriter, line.toString());
- }
-
- if (Emulator.getConfig().getBoolean("debug.show.users")) {
- System.out.println("[USER] " + line.toString());
- }
+ LOGGER.info("[USER] {}", line);
}
- public synchronized void logDebugLine(Object line) {
- if (line instanceof Throwable) {
- this.logErrorLine(line);
- return;
- }
- if (Emulator.getConfig().getBoolean("debug.mode")) {
- System.out.println("[DEBUG] " + line.toString());
- }
-
- if (Emulator.getConfig().getBoolean("logging.debug")) {
- this.write(debugFileWriter, line.toString());
- }
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
+ public void logDebugLine(Object line) {
+ LOGGER.debug("[DEBUG] {}", line);
}
- public synchronized void logPacketLine(Object 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")) {
- System.out.println("[" + Logging.ANSI_BLUE + "PACKET" + Logging.ANSI_RESET + "]" + line.toString());
- }
-
- if (Emulator.getConfig().getBoolean("logging.packets")) {
- this.write(packetsWriter, line.toString());
+ LOGGER.debug("[PACKET] {}", line);
}
}
- public synchronized void logUndefinedPacketLine(Object 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")) {
- System.out.println("[PACKET] [UNDEFINED] " + line.toString());
- }
-
- if (Emulator.getConfig().getBoolean("logging.packets.undefined")) {
- this.write(packetsUndefinedWriter, line.toString());
+ LOGGER.debug("[PACKET] [UNDEFINED] {}", line);
}
}
- public synchronized void logErrorLine(Object line) {
- if (Emulator.isReady && Emulator.getConfig().getBoolean("debug.show.errors")) {
- System.err.println("[ERROR] " + line.toString());
- }
-
- if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime")) {
- this.write(errorsRuntimeWriter, line);
- }
-
- if (line instanceof Throwable) {
- ((Throwable) line).printStackTrace();
- if (line instanceof SQLException) {
- this.logSQLException((SQLException) line);
- return;
- }
- // Emulator.getThreading().run(new HTTPPostError((Throwable) line));
-
- this.errorLogs.add(new ErrorLog("Exception", (Throwable) line));
-
- return;
- }
-
- this.errorLogs.add(new ErrorLog("Emulator", line.toString()));
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
+ public void logErrorLine(Object line) {
+ LOGGER.error("[ERROR] {}", line);
}
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
public void logSQLException(SQLException e) {
- if (Emulator.getConfig().getBoolean("logging.errors.sql")) {
- e.printStackTrace();
- this.write(errorsSQLWriter, e);
-
- //Emulator.getThreading().run(new HTTPPostError(e));
- }
+ LOGGER.error("[ERROR] SQLException", e);
}
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
public void logPacketError(Object e) {
- if (Emulator.getConfig().getBoolean("logging.errors.packets")) {
- if (e instanceof Throwable)
- ((Exception) e).printStackTrace();
-
- this.write(errorsPacketsWriter, e);
- }
-
- if (e instanceof Throwable) {
- ((Throwable) e).printStackTrace();
- if (e instanceof SQLException) {
- this.logSQLException((SQLException) e);
- return;
- }
-
- // Emulator.getThreading().run(new HTTPPostError((Throwable) e));
- }
+ LOGGER.error("[ERROR] PacketError {}", e);
}
+ /**
+ * @deprecated Do not use. Please use LoggerFactory.getLogger(YourClass.class) to log.
+ */
+ @Deprecated
public void handleException(Exception e) {
- e.printStackTrace();
+ LOGGER.error("[ERROR] Exception", e);
}
- private synchronized void write(PrintWriter printWriter, Object message) {
- if (printWriter != null && message != null) {
- if (message instanceof Throwable) {
- ((Exception) message).printStackTrace(printWriter);
- } else {
- printWriter.write("MSG: " + message.toString() + "\r\n");
- }
-
- printWriter.flush();
- }
- }
-
- public void addLog(Loggable log) {
- if (log instanceof ErrorLog) {
- synchronized (this.errorLogs) {
- this.errorLogs.add(log);
- }
- } else if (log instanceof CommandLog) {
- synchronized (this.commandLogs) {
- this.commandLogs.add(log);
- }
- }
- }
-
- public void addChatLog(Loggable chatLog) {
- this.chatLogs.add(chatLog);
- }
-
- public void saveLogs() {
- if (Emulator.getDatabase() != null && Emulator.getDatabase().getDataSource() != null) {
- if (!this.errorLogs.isEmpty() || !this.commandLogs.isEmpty() || !this.chatLogs.isEmpty()) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
- if (!this.errorLogs.isEmpty()) {
- synchronized (this.errorLogs) {
- try (PreparedStatement statement = connection.prepareStatement(ErrorLog.insertQuery)) {
- for (Loggable log : this.errorLogs) {
- log.log(statement);
- }
- statement.executeBatch();
- }
- this.errorLogs.clear();
- }
- }
-
- if (!this.commandLogs.isEmpty()) {
- synchronized (this.commandLogs) {
- try (PreparedStatement statement = connection.prepareStatement(CommandLog.insertQuery)) {
- for (Loggable log : this.commandLogs) {
- log.log(statement);
- }
-
- statement.executeBatch();
- }
- this.commandLogs.clear();
- }
- }
-
- if (!this.chatLogs.isEmpty()) {
- ConcurrentSet chatLogs = this.chatLogs;
- this.chatLogs = new ConcurrentSet<>();
-
- try (PreparedStatement statement = connection.prepareStatement(RoomChatMessage.insertQuery)) {
- for (Loggable log : chatLogs) {
- log.log(statement);
- }
-
- statement.executeBatch();
- }
- chatLogs.clear();
- }
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- }
- }
- }
- }
- /*
- public static PrintWriter getErrorsPacketsWriter()
- {
- return errorsPacketsWriter;
- }
-
- public static PrintWriter getErrorsSQLWriter()
- {
- return errorsSQLWriter;
- }
-
- public static PrintWriter getErrorsRuntimeWriter()
- {
- return errorsRuntimeWriter;
- }
-
- public static PrintWriter getDebugFileWriter()
- {
- return debugFileWriter;
- }
- */
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java
index 13a0cf3d..cadf07ea 100644
--- a/src/main/java/com/eu/habbo/core/PixelScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java
@@ -2,11 +2,15 @@ package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
public class PixelScheduler extends Scheduler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PixelScheduler.class);
+
public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED;
@@ -46,7 +50,7 @@ public class PixelScheduler extends Scheduler {
habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount());
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java
index f5c8042d..d30abc6a 100644
--- a/src/main/java/com/eu/habbo/core/PointsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java
@@ -2,11 +2,15 @@ package com.eu.habbo.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
public class PointsScheduler extends Scheduler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PointsScheduler.class);
+
public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED;
@@ -49,7 +53,7 @@ public class PointsScheduler extends Scheduler {
habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount());
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
index 9799350d..d593d1ff 100644
--- a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
+++ b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
@@ -19,7 +19,7 @@ public class RoomUserPetComposer extends MessageComposer {
}
@Override
- public ServerMessage compose() {
+ protected ServerMessage composeInternal() {
this.response.init(Outgoing.RoomUsersComposer);
this.response.appendInt(1);
this.response.appendInt(this.habbo.getHabboInfo().getId());
diff --git a/src/main/java/com/eu/habbo/core/TextsManager.java b/src/main/java/com/eu/habbo/core/TextsManager.java
index 7b28651c..90c6520a 100644
--- a/src/main/java/com/eu/habbo/core/TextsManager.java
+++ b/src/main/java/com/eu/habbo/core/TextsManager.java
@@ -1,12 +1,16 @@
package com.eu.habbo.core;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.Properties;
public class TextsManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TextsManager.class);
+
private final Properties texts;
public TextsManager() {
@@ -15,16 +19,14 @@ public class TextsManager {
this.texts = new Properties();
try {
-
this.reload();
- Emulator.getLogging().logStart("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Texts Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
} catch (Exception e) {
e.printStackTrace();
}
}
-
public void reload() throws Exception {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM emulator_texts")) {
while (set.next()) {
@@ -35,54 +37,47 @@ public class TextsManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
-
public String getValue(String key) {
return this.getValue(key, "");
}
-
public String getValue(String key, String defaultValue) {
if (!this.texts.containsKey(key)) {
- Emulator.getLogging().logErrorLine("[TEXTS] Text key not found: " + key);
+ LOGGER.error("Text key not found: {}", key);
}
return this.texts.getProperty(key, defaultValue);
}
-
public boolean getBoolean(String key) {
return this.getBoolean(key, false);
}
-
public boolean getBoolean(String key, Boolean defaultValue) {
try {
return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true"));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return defaultValue;
}
-
public int getInt(String key) {
return this.getInt(key, 0);
}
-
public int getInt(String key, Integer defaultValue) {
try {
return Integer.parseInt(this.getValue(key, defaultValue.toString()));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return defaultValue;
}
-
public void update(String key, String value) {
this.texts.setProperty(key, value);
}
@@ -96,7 +91,7 @@ public class TextsManager {
statement.setString(2, value);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.update(key, value);
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
index 25e523a9..ea103623 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
@@ -1,25 +1,21 @@
package com.eu.habbo.core.consolecommands;
-import com.eu.habbo.Emulator;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class ConsoleCommand {
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleCommand.class);
private static final THashMap commands = new THashMap<>();
-
public final String key;
-
-
public final String usage;
-
public ConsoleCommand(String key, String usage) {
this.key = key;
this.usage = usage;
}
-
public static void load() {
addCommand(new ConsoleShutdownCommand());
addCommand(new ConsoleInfoCommand());
@@ -27,6 +23,7 @@ public abstract class ConsoleCommand {
addCommand(new ConsoleReconnectCameraCommand());
addCommand(new ShowInteractionsCommand());
addCommand(new ShowRCONCommands());
+ addCommand(new ThankyouArcturusCommand());
}
public static void addCommand(ConsoleCommand command) {
@@ -48,14 +45,14 @@ public abstract class ConsoleCommand {
command.handle(message);
return true;
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
} else {
- System.out.println("Unknown Console Command " + message[0]);
- System.out.println("Commands Available (" + commands.size() + "): ");
+ LOGGER.info("Unknown Console Command " + message[0]);
+ LOGGER.info("Commands Available (" + commands.size() + "): ");
for (ConsoleCommand c : commands.values()) {
- System.out.println(c.key + " - " + c.usage);
+ LOGGER.info(c.key + " - " + c.usage);
}
}
}
@@ -64,4 +61,5 @@ public abstract class ConsoleCommand {
}
public abstract void handle(String[] args) throws Exception;
+
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
index c36f82bf..db7c22bf 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
@@ -2,10 +2,14 @@ package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.catalog.CatalogManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
public class ConsoleInfoCommand extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleInfoCommand.class);
+
public ConsoleInfoCommand() {
super("info", "Show current statistics.");
}
@@ -18,21 +22,21 @@ public class ConsoleInfoCommand extends ConsoleCommand {
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
- System.out.println("Emulator version: " + Emulator.version);
- System.out.println("Emulator build: " + Emulator.build);
+ LOGGER.info("Emulator version: " + Emulator.version);
+ LOGGER.info("Emulator build: " + Emulator.build);
- System.out.println("");
+ LOGGER.info("");
- System.out.println("Hotel Statistics");
- System.out.println("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount());
- System.out.println("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size());
- System.out.println("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items.");
- System.out.println("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items.");
- System.out.println("");
- System.out.println("Server Statistics");
- System.out.println("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!"));
- System.out.println("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB");
- System.out.println("- CPU Cores: " + Emulator.getRuntime().availableProcessors());
- System.out.println("- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB");
+ LOGGER.info("Hotel Statistics");
+ LOGGER.info("- Users: " + Emulator.getGameEnvironment().getHabboManager().getOnlineCount());
+ LOGGER.info("- Rooms: " + Emulator.getGameEnvironment().getRoomManager().getActiveRooms().size());
+ LOGGER.info("- Shop: " + Emulator.getGameEnvironment().getCatalogManager().catalogPages.size() + " pages and " + CatalogManager.catalogItemAmount + " items.");
+ LOGGER.info("- Furni: " + Emulator.getGameEnvironment().getItemManager().getItems().size() + " items.");
+ LOGGER.info("");
+ LOGGER.info("Server Statistics");
+ LOGGER.info("- Uptime: " + day + (day > 1 ? " days, " : " day, ") + hours + (hours > 1 ? " hours, " : " hour, ") + minute + (minute > 1 ? " minutes, " : " minute, ") + second + (second > 1 ? " seconds!" : " second!"));
+ LOGGER.info("- RAM Usage: " + (Emulator.getRuntime().totalMemory() - Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "/" + (Emulator.getRuntime().freeMemory()) / (1024 * 1024) + "MB");
+ LOGGER.info("- CPU Cores: " + Emulator.getRuntime().availableProcessors());
+ LOGGER.info("- Total Memory: " + Emulator.getRuntime().maxMemory() / (1024 * 1024) + "MB");
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java
index 0520a5e3..587130d1 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleReconnectCameraCommand.java
@@ -1,15 +1,19 @@
package com.eu.habbo.core.consolecommands;
import com.eu.habbo.networking.camera.CameraClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConsoleReconnectCameraCommand extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleReconnectCameraCommand.class);
+
public ConsoleReconnectCameraCommand() {
super("camera", "Attempt to reconnect to the camera server.");
}
@Override
public void handle(String[] args) throws Exception {
- System.out.println("Connecting to the camera...");
+ LOGGER.info("Connecting to the camera...");
CameraClient.attemptReconnect = true;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java
index d40fb13e..cd02b90c 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleTestCommand.java
@@ -3,8 +3,12 @@ package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConsoleTestCommand extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleTestCommand.class);
+
public ConsoleTestCommand() {
super("test", "This is just a test.");
}
@@ -12,7 +16,7 @@ public class ConsoleTestCommand extends ConsoleCommand {
@Override
public void handle(String[] args) throws Exception {
if (Emulator.debugging) {
- System.out.println("This is a test command for live debugging.");
+ LOGGER.info("This is a test command for live debugging.");
//AchievementManager.progressAchievement(4, Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"), 30);
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java
index 9aa6eee9..e8487a92 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowInteractionsCommand.java
@@ -1,8 +1,12 @@
package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ShowInteractionsCommand extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShowInteractionsCommand.class);
+
public ShowInteractionsCommand() {
super("interactions", "Show a list of available furniture interactions.");
}
@@ -10,7 +14,7 @@ public class ShowInteractionsCommand extends ConsoleCommand {
@Override
public void handle(String[] args) throws Exception {
for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList()) {
- System.out.println(interaction);
+ LOGGER.info(interaction);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java
index a7df7bf3..821d2f1f 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ShowRCONCommands.java
@@ -1,8 +1,12 @@
package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ShowRCONCommands extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ShowRCONCommands.class);
+
public ShowRCONCommands() {
super("rconcommands", "Show a list of all RCON commands");
}
@@ -10,7 +14,7 @@ public class ShowRCONCommands extends ConsoleCommand {
@Override
public void handle(String[] args) throws Exception {
for (String command : Emulator.getRconServer().getCommands()) {
- System.out.println(command);
+ LOGGER.info(command);
}
}
}
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java
new file mode 100644
index 00000000..64378af5
--- /dev/null
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ThankyouArcturusCommand.java
@@ -0,0 +1,43 @@
+package com.eu.habbo.core.consolecommands;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ThankyouArcturusCommand extends ConsoleCommand {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ThankyouArcturusCommand.class);
+
+ public ThankyouArcturusCommand() {
+ super("thankyou", "A thankyou message.");
+ }
+
+ @Override
+ public void handle(String[] args) throws Exception {
+ 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/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java
new file mode 100644
index 00000000..f9db196d
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java
@@ -0,0 +1,108 @@
+package com.eu.habbo.crypto;
+
+import com.eu.habbo.crypto.exceptions.HabboCryptoException;
+import com.eu.habbo.crypto.utils.BigIntegerUtils;
+import com.eu.habbo.util.HexUtils;
+
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.ThreadLocalRandom;
+
+public class HabboDiffieHellman {
+
+ private static final int DH_PRIMES_BIT_SIZE = 128;
+ private static final int DH_KEY_BIT_SIZE = 128;
+
+ private final HabboRSACrypto crypto;
+
+ private BigInteger DHPrime;
+ private BigInteger DHGenerator;
+ private BigInteger DHPrivate;
+ private BigInteger DHPublic;
+
+ public HabboDiffieHellman(HabboRSACrypto crypto) {
+ this.crypto = crypto;
+ this.generateDHPrimes();
+ this.generateDHKeys();
+ }
+
+ public BigInteger getDHPrime() {
+ return DHPrime;
+ }
+
+ public BigInteger getDHGenerator() {
+ return DHGenerator;
+ }
+
+ private void generateDHPrimes() {
+ this.DHPrime = BigInteger.probablePrime(DH_PRIMES_BIT_SIZE, ThreadLocalRandom.current());
+ this.DHGenerator = BigInteger.probablePrime(DH_PRIMES_BIT_SIZE, ThreadLocalRandom.current());
+
+ if (this.DHGenerator.compareTo(this.DHPrime) > 0) {
+ BigInteger temp = this.DHPrime;
+
+ this.DHPrime = this.DHGenerator;
+ this.DHGenerator = temp;
+ }
+ }
+
+ private void generateDHKeys() {
+ this.DHPrivate = BigInteger.probablePrime(DH_KEY_BIT_SIZE, ThreadLocalRandom.current());
+ this.DHPublic = this.DHGenerator.modPow(this.DHPrivate, this.DHPrime);
+ }
+
+ private String encryptBigInteger(BigInteger integer) throws HabboCryptoException {
+ String str = integer.toString(10);
+ byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
+ byte[] encrypted = this.crypto.Sign(bytes);
+
+ return HexUtils.toHex(encrypted).toLowerCase();
+ }
+
+ private BigInteger decryptBigInteger(String str) throws HabboCryptoException {
+ byte[] bytes = HexUtils.toBytes(str);
+ byte[] decrypted = this.crypto.Decrypt(bytes);
+ String intStr = new String(decrypted, StandardCharsets.UTF_8);
+
+ return new BigInteger(intStr, 10);
+ }
+
+ public String getPublicKey() throws HabboCryptoException {
+ return encryptBigInteger(this.DHPublic);
+ }
+
+ public String getSignedPrime() throws HabboCryptoException {
+ return encryptBigInteger(this.DHPrime);
+ }
+
+ public String getSignedGenerator() throws HabboCryptoException {
+ return encryptBigInteger(this.DHGenerator);
+ }
+
+ public void doHandshake(String signedPrime, String signedGenerator) throws HabboCryptoException {
+ this.DHPrime = decryptBigInteger(signedPrime);
+ this.DHGenerator = decryptBigInteger(signedGenerator);
+
+ if (this.DHPrime == null || this.DHGenerator == null) {
+ throw new HabboCryptoException("DHPrime or DHGenerator was null.");
+ }
+
+ if (this.DHPrime.compareTo(BigInteger.valueOf(2)) < 1) {
+ throw new HabboCryptoException("Prime cannot be <= 2!\nPrime: " + this.DHPrime.toString());
+ }
+
+ if (this.DHGenerator.compareTo(this.DHPrime) > -1) {
+ throw new HabboCryptoException("Generator cannot be >= Prime!\nPrime: " + this.DHPrime.toString() + "\nGenerator: " + this.DHGenerator.toString());
+ }
+
+ generateDHKeys();
+ }
+
+ public byte[] getSharedKey(String publicKeyStr) throws HabboCryptoException {
+ BigInteger publicKey = this.decryptBigInteger(publicKeyStr);
+ BigInteger sharedKey = publicKey.modPow(this.DHPrivate, this.DHPrime);
+
+ return BigIntegerUtils.toUnsignedByteArray(sharedKey);
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/crypto/HabboEncryption.java b/src/main/java/com/eu/habbo/crypto/HabboEncryption.java
new file mode 100644
index 00000000..42985f64
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/HabboEncryption.java
@@ -0,0 +1,21 @@
+package com.eu.habbo.crypto;
+
+public class HabboEncryption {
+
+ private final HabboRSACrypto crypto;
+ private final HabboDiffieHellman diffie;
+
+ public HabboEncryption(String e, String n, String d) {
+ this.crypto = new HabboRSACrypto(e, n, d);
+ this.diffie = new HabboDiffieHellman(this.crypto);
+ }
+
+ public HabboRSACrypto getCrypto() {
+ return crypto;
+ }
+
+ public HabboDiffieHellman getDiffie() {
+ return diffie;
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/crypto/HabboRC4.java b/src/main/java/com/eu/habbo/crypto/HabboRC4.java
new file mode 100644
index 00000000..b7959ed7
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/HabboRC4.java
@@ -0,0 +1,46 @@
+package com.eu.habbo.crypto;
+
+public class HabboRC4 {
+
+ private int i;
+ private int j;
+ private final int[] table = new int[256];
+
+ public HabboRC4(byte[] key) {
+ int length = key.length;
+
+ while (this.i < 256) {
+ table[this.i] = this.i;
+ this.i++;
+ }
+
+ this.i = 0;
+ this.j = 0;
+
+ while (this.i < 256) {
+ this.j = ((this.j + this.table[this.i]) + (key[this.i % length] & 0xff)) % 256;
+ this.swap(this.i, this.j);
+ this.i++;
+ }
+
+ this.i = 0;
+ this.j = 0;
+ }
+
+ private void swap(int a, int b) {
+ int num = table[a];
+ table[a] = table[b];
+ table[b] = num;
+ }
+
+ public void parse(byte[] bytes) {
+ for (int index1 = 0; index1 < bytes.length; index1++) {
+ this.i = (this.i + 1) % 256;
+ this.j = (this.j + this.table[this.i]) % 256;
+ this.swap(this.i, this.j);
+
+ bytes[index1] = (byte) ((bytes[index1] & 0xFF) ^ this.table[(this.table[this.i] + this.table[this.j]) % 256]);
+ }
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/crypto/HabboRSACrypto.java b/src/main/java/com/eu/habbo/crypto/HabboRSACrypto.java
new file mode 100644
index 00000000..7e1863ac
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/HabboRSACrypto.java
@@ -0,0 +1,168 @@
+package com.eu.habbo.crypto;
+
+import com.eu.habbo.crypto.exceptions.HabboCryptoException;
+import com.eu.habbo.crypto.utils.BigIntegerUtils;
+import org.apache.commons.lang3.mutable.MutableInt;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.concurrent.ThreadLocalRandom;
+
+public class HabboRSACrypto {
+
+ private final BigInteger e;
+ private final BigInteger n;
+ private final BigInteger d;
+ private final int blockSize;
+
+ public HabboRSACrypto(String e, String n) {
+ this.e = new BigInteger(e, 16);
+ this.n = new BigInteger(n, 16);
+ this.d = null;
+ this.blockSize = (this.n.bitLength() + 7) / 8;
+ }
+
+ public HabboRSACrypto(String e, String n, String d) {
+ this.e = new BigInteger(e, 16);
+ this.n = new BigInteger(n, 16);
+ this.d = new BigInteger(d, 16);
+ this.blockSize = (this.n.bitLength() + 7) / 8;
+ }
+
+ public byte[] Encrypt(byte[] data) throws HabboCryptoException {
+ return DoEncrypt(data, true, 2);
+ }
+
+ public byte[] Decrypt(byte[] data) throws HabboCryptoException {
+ return DoDecrypt(data, false, 2);
+ }
+
+ public byte[] Sign(byte[] data) throws HabboCryptoException {
+ return DoEncrypt(data, false, 1);
+ }
+
+ public byte[] Verify(byte[] data) throws HabboCryptoException {
+ return DoDecrypt(data, true, 1);
+ }
+
+ private BigInteger DoPublic(BigInteger x) {
+ return x.modPow(this.e, this.n);
+ }
+
+ private BigInteger DoPrivate(BigInteger x) {
+ return x.modPow(this.d, this.n);
+ }
+
+ private byte[] DoEncrypt(byte[] data, boolean isPublic, int padType) throws HabboCryptoException {
+ try (ByteArrayOutputStream dst = new ByteArrayOutputStream()) {
+ int bl = this.blockSize;
+ int end = data.length;
+ MutableInt pos = new MutableInt(0);
+
+ while (pos.intValue() < end) {
+ byte[] padded = Pkcs1Pad(data, pos, end, bl, padType);
+ BigInteger block = new BigInteger(padded);
+ BigInteger chunk = isPublic ? DoPublic(block) : DoPrivate(block);
+
+ for (int b = (int) (bl - Math.ceil(chunk.bitLength() / 8.0)); b > 0; --b) {
+ dst.write(0x00);
+ }
+
+ dst.write(BigIntegerUtils.toUnsignedByteArray(chunk));
+ }
+
+ return dst.toByteArray();
+ } catch (IOException e) {
+ throw new HabboCryptoException(e);
+ }
+ }
+
+ private byte[] DoDecrypt(byte[] data, boolean isPublic, int padType) throws HabboCryptoException {
+ if (data.length % this.blockSize != 0) {
+ throw new HabboCryptoException("Decryption data was not in blocks of " + this.blockSize + " bytes, total " + data.length + ".");
+ }
+
+ try (ByteArrayOutputStream dst = new ByteArrayOutputStream()) {
+ int end = data.length;
+ int pos = 0;
+
+ while (pos < end) {
+ byte[] blockData = new byte[this.blockSize];
+ System.arraycopy(data, pos, blockData, 0, this.blockSize);
+
+ BigInteger block = new BigInteger(1, blockData);
+ BigInteger chunk = isPublic ? DoPublic(block) : DoPrivate(block);
+ byte[] unpadded = Pkcs1Unpad(chunk.toByteArray(), this.blockSize, padType);
+
+ pos += this.blockSize;
+ dst.write(unpadded);
+ }
+
+ return dst.toByteArray();
+ } catch (IOException e) {
+ throw new HabboCryptoException(e);
+ }
+ }
+
+ private static byte[] Pkcs1Pad(byte[] src, MutableInt pos, int end, int n, int padType) {
+ byte[] result = new byte[n];
+ int p = pos.intValue();
+ end = Math.min(end, Math.min(src.length, p + n - 11));
+ pos.setValue(end);
+ int i = end - 1;
+
+ while (i >= p && n > 11) {
+ result[--n] = src[i--];
+ }
+
+ result[--n] = 0;
+
+ if (padType == 2) {
+ while (n > 2) {
+ result[--n] = (byte) ThreadLocalRandom.current().nextInt(1, 256);
+ }
+ } else {
+ while (n > 2) {
+ result[--n] = (byte) 0xFF;
+ }
+ }
+
+ result[--n] = (byte) padType;
+ result[--n] = 0;
+
+ return result;
+ }
+
+ private static byte[] Pkcs1Unpad(byte[] b, int n, int padType) throws HabboCryptoException {
+ byte[] result = new byte[n];
+ int resultPos = 0;
+ int i = 0;
+
+ while (i < b.length && b[i] == 0) {
+ ++i;
+ }
+
+ if (b.length - i != n - 1 || b[i] != padType) {
+ throw new HabboCryptoException("PKCS#1 unpad: i=" + i + ", expected b[i]==" + padType + ", got b[i]=" + b[i]);
+ }
+
+ ++i;
+
+ while (b[i] != 0) {
+ if (++i >= b.length) {
+ throw new HabboCryptoException("PKCS#1 unpad: i=" + i + ", b[i-1]!=0 (=" + b[i-1] + ")");
+ }
+ }
+
+ while (++i < b.length) {
+ result[resultPos++] = b[i];
+ }
+
+ byte[] resultCopy = new byte[resultPos];
+ System.arraycopy(result, 0, resultCopy, 0, resultPos);
+
+ return resultCopy;
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/crypto/exceptions/HabboCryptoException.java b/src/main/java/com/eu/habbo/crypto/exceptions/HabboCryptoException.java
new file mode 100644
index 00000000..e2b86a8d
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/exceptions/HabboCryptoException.java
@@ -0,0 +1,17 @@
+package com.eu.habbo.crypto.exceptions;
+
+public class HabboCryptoException extends Exception {
+
+ public HabboCryptoException(String message) {
+ super(message);
+ }
+
+ public HabboCryptoException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public HabboCryptoException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/crypto/utils/BigIntegerUtils.java b/src/main/java/com/eu/habbo/crypto/utils/BigIntegerUtils.java
new file mode 100644
index 00000000..4998bde1
--- /dev/null
+++ b/src/main/java/com/eu/habbo/crypto/utils/BigIntegerUtils.java
@@ -0,0 +1,17 @@
+package com.eu.habbo.crypto.utils;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+
+public class BigIntegerUtils {
+
+ public static byte[] toUnsignedByteArray(BigInteger bigInteger) {
+ byte[] bytes = bigInteger.toByteArray();
+ if (bytes[0] == 0) {
+ bytes = Arrays.copyOfRange(bytes, 1, bytes.length);
+ }
+
+ return bytes;
+ }
+
+}
diff --git a/src/main/java/com/eu/habbo/database/Database.java b/src/main/java/com/eu/habbo/database/Database.java
index 81f7c508..c37a524a 100644
--- a/src/main/java/com/eu/habbo/database/Database.java
+++ b/src/main/java/com/eu/habbo/database/Database.java
@@ -3,16 +3,17 @@ package com.eu.habbo.database;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.ConfigurationManager;
import com.zaxxer.hikari.HikariDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Database {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Database.class);
+
private HikariDataSource dataSource;
-
-
private DatabasePool databasePool;
public Database(ConfigurationManager config) {
-
long millis = System.currentTimeMillis();
boolean SQLException = false;
@@ -20,25 +21,23 @@ public class Database {
try {
this.databasePool = new DatabasePool();
if (!this.databasePool.getStoragePooling(config)) {
- Emulator.getLogging().logStart("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down...");
+ LOGGER.info("Failed to connect to the database. Please check config.ini and make sure the MySQL process is running. Shutting down...");
SQLException = true;
return;
}
this.dataSource = this.databasePool.getDatabase();
} catch (Exception e) {
SQLException = true;
- e.printStackTrace();
- Emulator.getLogging().logStart("Failed to connect to your database.");
- Emulator.getLogging().logStart(e.getMessage());
+ LOGGER.error("Failed to connect to your database.", e);
} finally {
- if (SQLException)
+ if (SQLException) {
Emulator.prepareShutdown();
+ }
}
- Emulator.getLogging().logStart("Database -> Connected! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis);
}
-
public void dispose() {
if (this.databasePool != null) {
this.databasePool.getDatabase().close();
@@ -55,4 +54,3 @@ public class Database {
return this.databasePool;
}
}
-
diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
index 93312b2c..63a956bb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
@@ -1,10 +1,7 @@
package com.eu.habbo.habbohotel;
import com.eu.habbo.Emulator;
-import com.eu.habbo.core.CreditsScheduler;
-import com.eu.habbo.core.GotwPointsScheduler;
-import com.eu.habbo.core.PixelScheduler;
-import com.eu.habbo.core.PointsScheduler;
+import com.eu.habbo.core.*;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.catalog.CatalogManager;
@@ -23,8 +20,13 @@ import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.polls.PollManager;
import com.eu.habbo.habbohotel.rooms.RoomManager;
import com.eu.habbo.habbohotel.users.HabboManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GameEnvironment {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GameEnvironment.class);
+
public CreditsScheduler creditsScheduler;
public PixelScheduler pixelScheduler;
public PointsScheduler pointsScheduler;
@@ -49,7 +51,7 @@ public class GameEnvironment {
private PollManager pollManager;
public void load() throws Exception {
- Emulator.getLogging().logStart("GameEnvironment -> Loading...");
+ LOGGER.info("GameEnvironment -> Loading...");
this.permissionsManager = new PermissionsManager();
this.habboManager = new HabboManager();
@@ -85,7 +87,7 @@ public class GameEnvironment {
Emulator.getThreading().run(this.gotwPointsScheduler);
- Emulator.getLogging().logStart("GameEnvironment -> Loaded!");
+ LOGGER.info("GameEnvironment -> Loaded!");
}
public void dispose() {
@@ -101,7 +103,7 @@ public class GameEnvironment {
this.roomManager.dispose();
this.itemManager.dispose();
this.hotelViewManager.dispose();
- Emulator.getLogging().logShutdownLine("GameEnvironment -> Disposed!");
+ LOGGER.info("GameEnvironment -> Disposed!");
}
public HabboManager getHabboManager() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
index c6a865e5..9de60de5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
@@ -18,20 +18,21 @@ import com.eu.habbo.plugin.events.users.achievements.UserAchievementLeveledEvent
import com.eu.habbo.plugin.events.users.achievements.UserAchievementProgressEvent;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectIntProcedure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.LinkedHashMap;
import java.util.Map;
public class AchievementManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AchievementManager.class);
+
public static boolean TALENTTRACK_ENABLED = false;
-
private final THashMap achievements;
-
private final THashMap> talentTrackLevels;
-
public AchievementManager() {
this.achievements = new THashMap<>();
this.talentTrackLevels = new THashMap<>();
@@ -58,7 +59,7 @@ public class AchievementManager {
statement.setInt(4, amount);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -140,7 +141,7 @@ public class AchievementManager {
try {
badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase());
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
return;
}
}
@@ -203,7 +204,7 @@ public class AchievementManager {
statement.setInt(3, 1);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -217,7 +218,7 @@ public class AchievementManager {
}
statement.executeBatch();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -231,7 +232,7 @@ public class AchievementManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return 0;
@@ -254,9 +255,9 @@ public class AchievementManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
@@ -276,13 +277,13 @@ public class AchievementManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- Emulator.getLogging().logErrorLine("Achievement Manager -> Failed to load!");
+ LOGGER.error("Caught SQL exception", e);
+ LOGGER.error("Achievement Manager -> Failed to load!");
return;
}
}
- Emulator.getLogging().logStart("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Achievement Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public Achievement getAchievement(String name) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java
index 31e5d861..e491523f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java
+++ b/src/main/java/com/eu/habbo/habbohotel/achievements/TalentTrackLevel.java
@@ -5,27 +5,20 @@ import com.eu.habbo.habbohotel.items.Item;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class TalentTrackLevel {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TalentTrackLevel.class);
public TalentTrackType type;
-
-
public int level;
-
-
public TObjectIntMap achievements;
-
-
public THashSet- items;
-
-
public String[] perks;
-
-
public String[] badges;
public TalentTrackLevel(ResultSet set) throws SQLException {
@@ -46,7 +39,7 @@ public class TalentTrackLevel {
if (achievement != null) {
this.achievements.put(achievement, Integer.valueOf(achievementLevels[i]));
} else {
- Emulator.getLogging().logErrorLine("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type);
+ LOGGER.error("Could not find achievement with ID " + achievements[i] + " for talenttrack level " + this.level + " of type " + this.type);
}
}
}
@@ -57,7 +50,7 @@ public class TalentTrackLevel {
if (item != null) {
this.items.add(item);
} else {
- Emulator.getLogging().logStart("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level);
+ LOGGER.error("Incorrect reward furni (ID: " + s + ") for talent track level " + this.level);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
index d10ed613..8cedc5ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
@@ -12,6 +12,8 @@ import com.eu.habbo.plugin.events.bots.BotShoutEvent;
import com.eu.habbo.plugin.events.bots.BotTalkEvent;
import com.eu.habbo.plugin.events.bots.BotWhisperEvent;
import com.eu.habbo.threading.runnables.BotFollowHabbo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -21,6 +23,8 @@ import java.util.ArrayList;
import java.util.Arrays;
public class Bot implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
+
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
@@ -155,7 +159,7 @@ public class Bot implements Runnable {
statement.execute();
this.needsUpdate = false;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
index 3afd12e0..1f93888c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
@@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
@@ -15,19 +16,24 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
import com.eu.habbo.plugin.events.bots.BotPickUpEvent;
import com.eu.habbo.plugin.events.bots.BotPlacedEvent;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.sql.*;
import java.util.Map;
+
+
public class BotManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BotManager.class);
final private static THashMap> botDefenitions = new THashMap<>();
public static int MINIMUM_CHAT_SPEED = 7;
public static int MAXIMUM_CHAT_SPEED = 604800;
public static int MAXIMUM_CHAT_LENGTH = 120;
public static int MAXIMUM_NAME_LENGTH = 15;
-
+ public static int MAXIMUM_BOT_INVENTORY_SIZE = 25;
public BotManager() throws Exception {
long millis = System.currentTimeMillis();
@@ -38,7 +44,7 @@ public class BotManager {
this.reload();
- Emulator.getLogging().logStart("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Bot Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public static void addBotDefinition(String type, Class extends Bot> botClazz) throws Exception {
@@ -58,10 +64,10 @@ public class BotManager {
m.setAccessible(true);
m.invoke(null);
} catch (NoSuchMethodException e) {
- Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!");
+ LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. No Such Method!");
return false;
} catch (Exception e) {
- Emulator.getLogging().logStart("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage());
+ LOGGER.info("Bot Manager -> Failed to execute initialise method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage());
return false;
}
}
@@ -88,12 +94,12 @@ public class BotManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return bot;
@@ -107,8 +113,8 @@ public class BotManager {
return;
if (room != null && bot != null && habbo != null) {
- if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission("acc_placefurni")) {
- if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission("acc_unlimited_bots")) {
+ if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_PLACEFURNI)) {
+ if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS)) {
habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
return;
}
@@ -116,15 +122,18 @@ public class BotManager {
if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY))
return;
+ if (room.hasBotsAt(location.x, location.y)) {
+ habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE));
+ return;
+ }
+
RoomUnit roomUnit = new RoomUnit();
roomUnit.setRotation(RoomUserRotation.SOUTH);
roomUnit.setLocation(location);
- HabboItem topItem = room.getTopItemAt(location.x, location.y);
-
- double topItemHeight = 0;
- if (topItem != null) topItemHeight = Item.getCurrentHeight(topItem);
- roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight() - topItemHeight);
+ double stackHeight = room.getStackHeight(location.x, location.y, false);
+ roomUnit.setPreviousLocationZ(stackHeight);
+ roomUnit.setZ(stackHeight);
roomUnit.setPathFinderRoom(room);
roomUnit.setRoomUnitType(RoomUnitType.BOT);
@@ -139,13 +148,16 @@ public class BotManager {
habbo.getClient().sendResponse(new RemoveBotComposer(bot));
bot.onPlace(habbo, room);
+ HabboItem topItem = room.getTopItemAt(location.x, location.y);
+
if (topItem != null) {
try {
topItem.onWalkOn(bot.getRoomUnit(), room, null);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
+
bot.cycle(false);
} else {
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
@@ -160,27 +172,34 @@ public class BotManager {
}
public void pickUpBot(Bot bot, Habbo habbo) {
- if (bot != null && habbo != null) {
+ HabboInfo receiverInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo();
+
+ if (bot != null) {
BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo);
Emulator.getPluginManager().fireEvent(pickedUpEvent);
if (pickedUpEvent.isCancelled())
return;
- if (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) {
- if (!habbo.hasPermission("acc_unlimited_bots") && habbo.getInventory().getBotsComponent().getBots().size() >= 15)
+ if (habbo == null || (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER))) {
+ if (habbo != null && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
+ habbo.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + ""));
return;
+ }
- bot.onPickUp(habbo, habbo.getHabboInfo().getCurrentRoom());
- habbo.getHabboInfo().getCurrentRoom().removeBot(bot);
+ bot.onPickUp(habbo, receiverInfo.getCurrentRoom());
+ receiverInfo.getCurrentRoom().removeBot(bot);
bot.stopFollowingHabbo();
- bot.setOwnerId(habbo.getHabboInfo().getId());
- bot.setOwnerName(habbo.getHabboInfo().getUsername());
+ bot.setOwnerId(receiverInfo.getId());
+ bot.setOwnerName(receiverInfo.getUsername());
bot.needsUpdate(true);
Emulator.getThreading().run(bot);
- habbo.getInventory().getBotsComponent().addBot(bot);
- habbo.getClient().sendResponse(new AddBotComposer(bot));
+ Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(receiverInfo.getId()) : habbo;
+ if (receiver != null) {
+ receiver.getInventory().getBotsComponent().addBot(bot);
+ receiver.getClient().sendResponse(new AddBotComposer(bot));
+ }
}
}
}
@@ -193,11 +212,11 @@ public class BotManager {
if (botClazz != null)
return botClazz.getDeclaredConstructor(ResultSet.class).newInstance(set);
else
- Emulator.getLogging().logErrorLine("Unknown Bot Type: " + type);
+ LOGGER.error("Unknown Bot Type: " + type);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return null;
@@ -208,7 +227,7 @@ public class BotManager {
statement.setInt(1, bot.getId());
return statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -221,9 +240,9 @@ public class BotManager {
m.setAccessible(true);
m.invoke(null);
} catch (NoSuchMethodException e) {
- Emulator.getLogging().logStart("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!");
+ LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. No Such Method!");
} catch (Exception e) {
- Emulator.getLogging().logStart("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage());
+ LOGGER.info("Bot Manager -> Failed to execute dispose method upon bot type '" + set.getKey() + "'. Error: " + e.getMessage());
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
index 7d56944c..d776bee9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
@@ -8,6 +8,8 @@ import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -19,6 +21,7 @@ import java.util.List;
import java.util.Map;
public class ButlerBot extends Bot {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ButlerBot.class);
public static THashMap, Integer> serveItems = new THashMap<>();
public ButlerBot(ResultSet set) throws SQLException {
@@ -43,7 +46,7 @@ public class ButlerBot extends Bot {
serveItems.put(ks, set.getInt("item"));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -75,20 +78,13 @@ public class ButlerBot extends Bot {
tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0));
- tasks.add(new Runnable() {
- @Override
- public void run() {
- b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
- }
- });
+ tasks.add(() -> b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername())));
List failedReached = new ArrayList();
- failedReached.add(new Runnable() {
- public void run() {
- if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
- for (Runnable t : tasks) {
- t.run();
- }
+ failedReached.add(() -> {
+ if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
+ for (Runnable t : tasks) {
+ t.run();
}
}
});
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
index bfb9b297..dd6f0849 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
@@ -56,7 +56,7 @@ public class VisitorBot extends Bot {
public void onUserEnter(Habbo habbo) {
if (!this.showedLog) {
if (habbo.getHabboInfo().getCurrentRoom() != null) {
- this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getHabboInfo().getCurrentRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp());
+ this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getHabboInfo().getCurrentRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp(), habbo.getHabboInfo().getCurrentRoom().getOwnerName());
if (this.visits.isEmpty()) {
this.talk(Emulator.getTexts().getValue("bots.visitor.no_visits"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java
index 9abeae91..c8d015e6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogItem.java
@@ -3,9 +3,12 @@ package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -14,7 +17,7 @@ import java.sql.SQLException;
import java.util.HashMap;
public class CatalogItem implements ISerialize, Runnable, Comparable {
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(CatalogItem.class);
int id;
int limitedStack;
private int pageId;
@@ -211,7 +214,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable 0) {
@@ -258,8 +261,8 @@ public class CatalogItem implements ISerialize, Runnable, Comparable limitedNumbers;
private int totalSet;
@@ -47,7 +51,7 @@ public class CatalogLimitedConfiguration implements Runnable {
statement.setInt(5, item.getLimitedSells());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -65,7 +69,7 @@ public class CatalogLimitedConfiguration implements Runnable {
statement.executeBatch();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.totalSet += amount;
@@ -98,7 +102,7 @@ public class CatalogLimitedConfiguration implements Runnable {
statement.setInt(3, this.itemId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
index 009b0828..255031af 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
@@ -11,6 +11,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.SoundTrack;
import com.eu.habbo.habbohotel.items.interactions.*;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
+import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
@@ -39,14 +40,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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
import java.sql.*;
import java.util.*;
import java.util.stream.Collectors;
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()) {
@@ -209,7 +213,7 @@ public class CatalogManager {
this.ecotronItem = Emulator.getGameEnvironment().getItemManager().getItem("ecotron_box");
- Emulator.getLogging().logStart("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Catalog Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
@@ -249,7 +253,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
for (Map.Entry> set : limiteds.entrySet()) {
@@ -269,7 +273,7 @@ public class CatalogManager {
Class extends CatalogPage> pageClazz = pageDefinitions.get(set.getString("page_layout"));
if (pageClazz == null) {
- Emulator.getLogging().logStart("Unknown Page Layout: " + set.getString("page_layout"));
+ LOGGER.info("Unknown Page Layout: " + set.getString("page_layout"));
continue;
}
@@ -277,12 +281,12 @@ public class CatalogManager {
CatalogPage page = pageClazz.getConstructor(ResultSet.class).newInstance(set);
pages.put(page.getId(), page);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to load layout: " + set.getString("page_layout"));
+ LOGGER.error("Failed to load layout: {}", set.getString("page_layout"));
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
pages.forEachValue((object) -> {
@@ -294,7 +298,7 @@ public class CatalogManager {
}
} else {
if (object.parentId != -2) {
- Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")");
+ LOGGER.info("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")");
}
}
return true;
@@ -302,7 +306,7 @@ public class CatalogManager {
this.catalogPages.putAll(pages);
- Emulator.getLogging().logStart("Loaded " + this.catalogPages.size() + " Catalog Pages!");
+ LOGGER.info("Loaded " + this.catalogPages.size() + " Catalog Pages!");
}
@@ -323,7 +327,7 @@ public class CatalogManager {
));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -367,7 +371,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
for (CatalogPage page : this.catalogPages.valueCollection()) {
@@ -392,7 +396,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -408,7 +412,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -423,7 +427,7 @@ public class CatalogManager {
this.vouchers.add(new Voucher(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -443,11 +447,11 @@ public class CatalogManager {
this.prizes.get(set.getInt("rarity")).add(item);
} else {
- Emulator.getLogging().logErrorLine("Cannot load item with ID:" + set.getInt("item_id") + " as recycler reward!");
+ LOGGER.error("Cannot load item with ID: {} as recycler reward!", set.getInt("item_id"));
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -472,7 +476,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -489,7 +493,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -504,7 +508,7 @@ public class CatalogManager {
this.clothing.put(set.getInt("id"), new ClothItem(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -594,7 +598,7 @@ public class CatalogManager {
return statement.executeUpdate() >= 1;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -699,7 +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 {
- Emulator.getLogging().logErrorLine("[Recycler] No rewards specified for rarity level " + level);
+ LOGGER.error("No rewards specified for rarity level {}", level);
}
return null;
@@ -730,13 +734,11 @@ public class CatalogManager {
if (pageClazz != null) {
try {
catalogPage = pageClazz.getConstructor(ResultSet.class).newInstance(page);
- } catch (InvocationTargetException e) {
- Emulator.getLogging().logErrorLine(e.getCause());
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
} else {
- Emulator.getLogging().logErrorLine("Unknown Page Layout: " + page.getString("page_layout"));
+ LOGGER.error("Unknown page layout: {}", page.getString("page_layout"));
}
}
}
@@ -744,7 +746,7 @@ public class CatalogManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
if (catalogPage != null) {
@@ -803,7 +805,7 @@ public class CatalogManager {
}
}
- Emulator.getLogging().logShutdownLine("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);
- Emulator.getLogging().logUserLine(message);
+ LOGGER.info(message);
habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL));
return;
}
@@ -957,7 +959,7 @@ public class CatalogManager {
try {
pet = Emulator.getGameEnvironment().getPetManager().createPet(baseItem, data[0], data[1], data[2], habbo.getClient());
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
}
@@ -1012,28 +1014,28 @@ public class CatalogManager {
try {
guildId = Integer.parseInt(extradata);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
return;
}
- InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
- habboItem.setExtradata("");
- habboItem.needsUpdate(true);
+ Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
- Emulator.getThreading().run(habboItem);
- Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
- itemsList.add(habboItem);
+ if (guild != null && Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo) != null) {
+ InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
+ habboItem.setExtradata("");
+ habboItem.needsUpdate(true);
- if (baseItem.getName().equals("guild_forum")) {
- Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
- if (guild != null) {
+ Emulator.getThreading().run(habboItem);
+ Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
+ itemsList.add(habboItem);
+
+ if (baseItem.getName().equals("guild_forum")) {
guild.setForum(true);
guild.needsUpdate = true;
guild.run();
}
}
-
} else if (baseItem.getInteractionType().getType() == InteractionMusicDisc.class) {
SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(item.getExtradata());
@@ -1069,14 +1071,14 @@ public class CatalogManager {
}
}
- if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_credits")) {
+ if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
if (purchasedEvent.totalCredits > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.totalCredits);
habbo.getClient().sendResponse(new UserCreditsComposer(habbo.getClient().getHabbo()));
}
}
- if (!free && !habbo.getClient().getHabbo().hasPermission("acc_infinite_points")) {
+ if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS)) {
if (purchasedEvent.totalPoints > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -purchasedEvent.totalPoints);
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -purchasedEvent.totalPoints, item.getPointsType()));
@@ -1120,7 +1122,7 @@ public class CatalogManager {
habbo.getClient().sendResponse(new InventoryRefreshComposer());
} catch (Exception e) {
- Emulator.getLogging().logPacketError(e);
+ LOGGER.error("Exception caught", e);
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));
}
} finally {
@@ -1156,7 +1158,7 @@ public class CatalogManager {
statement.setInt(3, Emulator.getIntUnixTimestamp());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
index 4c7562ee..b161c201 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
@@ -1,6 +1,5 @@
package com.eu.habbo.habbohotel.catalog;
-import com.eu.habbo.Emulator;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.TCollections;
@@ -8,12 +7,16 @@ import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public abstract class CatalogPage implements Comparable, ISerialize {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPage.class);
+
protected final TIntArrayList offerIds = new TIntArrayList();
protected final THashMap childPages = new THashMap<>();
private final TIntObjectMap catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>());
@@ -70,8 +73,8 @@ public abstract class CatalogPage implements Comparable, ISerialize
try {
this.included.add(Integer.valueOf(id));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
- Emulator.getLogging().logErrorLine("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")");
+ LOGGER.error("Caught exception", e);
+ LOGGER.error("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")");
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
index 7291e193..b5e93b13 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -10,6 +12,8 @@ import java.util.ArrayList;
import java.util.List;
public class Voucher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Voucher.class);
+
public final int id;
public final String code;
public final int credits;
@@ -41,7 +45,7 @@ public class Voucher {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -64,7 +68,7 @@ public class Voucher {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
index e05ccb84..680d3e9b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
@@ -13,11 +13,15 @@ import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectProcedure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.Map;
public class RoomBundleLayout extends SingleBundle {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleLayout.class);
+
public int roomId;
public Room room;
private int lastUpdate = 0;
@@ -43,7 +47,7 @@ public class RoomBundleLayout extends SingleBundle {
if (this.room != null)
this.room.preventUnloading = true;
} else {
- Emulator.getLogging().logErrorLine("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")");
+ LOGGER.error("No room id specified for room bundle " + this.getPageName() + "(" + this.getId() + ")");
}
}
@@ -185,7 +189,7 @@ public class RoomBundleLayout extends SingleBundle {
statement.setInt(3, this.room.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -219,7 +223,7 @@ public class RoomBundleLayout extends SingleBundle {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId);
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
index 2e978403..031ff4f6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
@@ -16,6 +16,8 @@ import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemCancelledEvent;
import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemOfferedEvent;
import com.eu.habbo.plugin.events.marketplace.MarketPlaceItemSoldEvent;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -26,6 +28,8 @@ import java.util.List;
public class MarketPlace {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlace.class);
+
//Configuration. Loaded from database & updated accordingly.
public static boolean MARKETPLACE_ENABLED = true;
@@ -43,7 +47,7 @@ public class MarketPlace {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return offers;
@@ -101,7 +105,7 @@ public class MarketPlace {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
habbo.getClient().sendResponse(new MarketplaceCancelSaleComposer(offer, false));
}
}
@@ -110,7 +114,7 @@ public class MarketPlace {
public static List getOffers(int minPrice, int maxPrice, String search, int sort) {
List offers = new ArrayList<>(10);
- String query = "SELECT B.* FROM marketplace_items a INNER JOIN (SELECT b.item_id AS base_item_id, b.limited_data AS ltd_data, marketplace_items.*, AVG(price) as avg, MIN(marketplace_items.price) as minPrice, MAX(marketplace_items.price) as maxPrice, COUNT(*) as number, (SELECT COUNT(*) FROM marketplace_items c INNER JOIN items as items_b ON c.item_id = items_b.id WHERE state = 2 AND items_b.item_id = base_item_id AND DATE(from_unixtime(sold_timestamp)) = CURDATE()) as sold_count_today FROM marketplace_items INNER JOIN items b ON marketplace_items.item_id = b.id INNER JOIN items_base bi ON b.item_id = bi.id WHERE price = (SELECT MIN(e.price) FROM marketplace_items e, items d WHERE e.item_id = d.id AND d.item_id = b.item_id AND e.state = 1 AND e.timestamp > ? GROUP BY d.item_id) AND state = 1 AND timestamp > ?";
+ String query = "SELECT B.* FROM marketplace_items a INNER JOIN (SELECT b.item_id AS base_item_id, b.limited_data AS ltd_data, marketplace_items.*, AVG(price) as avg, MIN(marketplace_items.price) as minPrice, MAX(marketplace_items.price) as maxPrice, COUNT(*) as number, (SELECT COUNT(*) FROM marketplace_items c INNER JOIN items as items_b ON c.item_id = items_b.id WHERE state = 2 AND items_b.item_id = base_item_id AND DATE(from_unixtime(sold_timestamp)) = CURDATE()) as sold_count_today FROM marketplace_items INNER JOIN items b ON marketplace_items.item_id = b.id INNER JOIN items_base bi ON b.item_id = bi.id INNER JOIN catalog_items ci ON bi.id = ci.item_ids WHERE price = (SELECT MIN(e.price) FROM marketplace_items e, items d WHERE e.item_id = d.id AND d.item_id = b.item_id AND e.state = 1 AND e.timestamp > ? GROUP BY d.item_id) AND state = 1 AND timestamp > ?";
if (minPrice > 0) {
query += " AND CEIL(price + (price / 100)) >= " + minPrice;
}
@@ -118,7 +122,7 @@ public class MarketPlace {
query += " AND CEIL(price + (price / 100)) <= " + maxPrice;
}
if (search.length() > 0) {
- query += " AND bi.public_name LIKE ?";
+ query += " AND bi.public_name LIKE ? OR ci.catalog_name LIKE ?";
}
query += " GROUP BY base_item_id, ltd_data";
@@ -149,13 +153,15 @@ public class MarketPlace {
query += " AS B ON a.id = B.id";
- query += " LIMIT 100";
+ query += " LIMIT 250";
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) {
statement.setInt(1, Emulator.getIntUnixTimestamp() - 172800);
statement.setInt(2, Emulator.getIntUnixTimestamp() - 172800);
- if (search.length() > 0)
+ if (search.length() > 0) {
statement.setString(3, "%" + search + "%");
+ statement.setString(4, "%" + search + "%");
+ }
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
@@ -163,7 +169,7 @@ public class MarketPlace {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return offers;
@@ -193,7 +199,7 @@ public class MarketPlace {
message.appendInt(1);
message.appendInt(itemId);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -208,7 +214,7 @@ public class MarketPlace {
number = set.getInt("number");
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return number;
@@ -226,7 +232,7 @@ public class MarketPlace {
avg = set.getInt("avg");
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return calculateCommision(avg);
@@ -294,7 +300,7 @@ public class MarketPlace {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -321,7 +327,7 @@ public class MarketPlace {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -388,7 +394,7 @@ public class MarketPlace {
statement.setInt(2, offer.getOfferId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
index f8b68e5a..196544e7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
@@ -5,10 +5,14 @@ import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
public class MarketPlaceOffer implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MarketPlaceOffer.class);
+
public int avarage;
public int count;
private int offerId;
@@ -66,7 +70,7 @@ public class MarketPlaceOffer implements Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -86,7 +90,7 @@ public class MarketPlaceOffer implements Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -160,7 +164,7 @@ public class MarketPlaceOffer implements Runnable {
statement.setInt(3, this.offerId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java
index 5318102b..d590bb0e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java
@@ -3,12 +3,16 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.YoutubeManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class AddYoutubePlaylistCommand extends Command {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AddYoutubePlaylistCommand.class);
+
public AddYoutubePlaylistCommand() {
super("cmd_add_youtube_playlist", Emulator.getTexts().getValue("commands.keys.cmd_add_youtube_playlist").split(";"));
}
@@ -49,7 +53,7 @@ public class AddYoutubePlaylistCommand extends Command {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_add_youtube_playlist"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java
index d6ab608c..649d5137 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/AllowTradingCommand.java
@@ -25,22 +25,32 @@ public class AllowTradingCommand extends Command {
return true;
}
- if (params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) {
- String username = params[1];
- boolean enabled = params[2].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"));
+ final String username = params[1];
+ final String option = params[2];
- Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username);
+ if (option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes")) || option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.no"))) {
+ final boolean enabled = option.equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"));
+ final Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username);
if (habbo != null) {
+ if (!enabled) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement statement = connection.prepareStatement("UPDATE users_settings SET tradelock_amount = tradelock_amount + 1 WHERE user_id = ?")) {
+ statement.setInt(1, habbo.getHabboInfo().getId());
+ statement.executeUpdate();
+ }
+ }
habbo.getHabboStats().setAllowTrade(enabled);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_allow_trading." + (enabled ? "enabled" : "disabled")).replace("%username%", params[1]));
habbo.getClient().sendResponse(new UserPerksComposer(habbo));
return true;
} else {
boolean found;
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.user_id SET can_trade = ?, tradelock_amount = tradelock_amount + ? WHERE users.username LIKE ?")) {
statement.setString(1, enabled ? "1" : "0");
- statement.setString(2, username);
+ statement.setInt(2, enabled ? 0 : 1);
+ statement.setString(3, username);
found = statement.executeUpdate() > 0;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
index eac670e7..1328ed19 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
@@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -13,6 +15,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class BadgeCommand extends Command {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BadgeCommand.class);
+
public BadgeCommand() {
super("cmd_badge", Emulator.getTexts().getValue("commands.keys.cmd_badge").split(";"));
}
@@ -72,7 +76,7 @@ public class BadgeCommand extends Command {
return true;
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java
index 005911f7..6afc6dc3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/ChatTypeCommand.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
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.messages.outgoing.users.MeMenuSettingsComposer;
@@ -31,7 +32,7 @@ public class ChatTypeCommand extends Command {
return true;
}
- if (!gameClient.getHabbo().hasPermission("acc_anychatcolor")) {
+ if (!gameClient.getHabbo().hasPermission(Permission.ACC_ANYCHATCOLOR)) {
for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) {
if (Integer.valueOf(s) == chatColor) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_chatcolor.banned"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
index dbf2fa6a..16d2c5c9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
@@ -15,6 +15,8 @@ import com.eu.habbo.plugin.events.users.UserCommandEvent;
import com.eu.habbo.plugin.events.users.UserExecuteCommandEvent;
import gnu.trove.iterator.TIntObjectIterator;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Comparator;
@@ -22,6 +24,9 @@ import java.util.List;
import java.util.NoSuchElementException;
public class CommandHandler {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommandHandler.class);
+
private final static THashMap commands = new THashMap<>(5);
private static final Comparator ALPHABETICAL_ORDER = new Comparator() {
public int compare(Command c1, Command c2) {
@@ -33,7 +38,7 @@ public class CommandHandler {
public CommandHandler() {
long millis = System.currentTimeMillis();
this.reloadCommands();
- Emulator.getLogging().logStart("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public static void addCommand(Command command) {
@@ -48,9 +53,9 @@ public class CommandHandler {
try {
//command.getConstructor().setAccessible(true);
addCommand(command.newInstance());
- Emulator.getLogging().logDebugLine("Added command: " + command.getName());
+ LOGGER.debug("Added command: {}", command.getName());
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -67,7 +72,7 @@ public class CommandHandler {
for (String s : command.keys) {
if (s.toLowerCase().equals(parts[0].toLowerCase())) {
boolean succes = false;
- if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission("acc_placefurni") || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().guildRightLevel(gameClient.getHabbo()) >= 2))) {
+ if (command.permission == null || gameClient.getHabbo().hasPermission(command.permission, gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && (gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermission(Permission.ACC_PLACEFURNI) || (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().getGuildId() > 0 && gameClient.getHabbo().getHabboInfo().getCurrentRoom().guildRightLevel(gameClient.getHabbo()) >= 2))) {
try {
Emulator.getPluginManager().fireEvent(new UserExecuteCommandEvent(gameClient.getHabbo(), command, parts));
@@ -79,11 +84,11 @@ public class CommandHandler {
succes = event.succes;
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) {
- Emulator.getLogging().addLog(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes));
+ Emulator.getDatabaseLogger().store(new CommandLog(gameClient.getHabbo().getHabboInfo().getId(), command, commandLine, succes));
}
}
@@ -279,6 +284,7 @@ public class CommandHandler {
addCommand(new WordQuizCommand());
addCommand(new UpdateYoutubePlaylistsCommand());
addCommand(new AddYoutubePlaylistCommand());
+ addCommand(new SoftKickCommand());
addCommand(new TestCommand());
}
@@ -305,7 +311,6 @@ public class CommandHandler {
public void dispose() {
commands.clear();
-
- Emulator.getLogging().logShutdownLine("Command Handler -> Disposed!");
+ LOGGER.info("Command Handler -> Disposed!");
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java
index 2745aa0c..64ff8513 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyBotsInventoryCommand.java
@@ -6,6 +6,7 @@ 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 com.eu.habbo.messages.outgoing.inventory.InventoryBotsComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
@@ -30,26 +31,24 @@ public class EmptyBotsInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
- Habbo habbo = gameClient.getHabbo();
- if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
- habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
- }
+
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap bots = new TIntObjectHashMap<>();
bots.putAll(habbo.getInventory().getBotsComponent().getBots());
habbo.getInventory().getBotsComponent().getBots().clear();
- bots.forEachValue(new TObjectProcedure() {
- @Override
- public boolean execute(Bot object) {
- Emulator.getGameEnvironment().getBotManager().deleteBot(object);
- return true;
- }
+ bots.forEachValue(object -> {
+ Emulator.getGameEnvironment().getBotManager().deleteBot(object);
+ return true;
});
habbo.getClient().sendResponse(new InventoryRefreshComposer());
+ habbo.getClient().sendResponse(new InventoryBotsComposer(habbo));
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.cleared"), RoomChatMessageBubbles.ALERT);
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
+ } else {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty_bots"), RoomChatMessageBubbles.ALERT);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java
index ba7323a5..779dd3e5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyInventoryCommand.java
@@ -32,13 +32,10 @@ public class EmptyInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
- Habbo habbo = gameClient.getHabbo();
- if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
- habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
- }
+
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
-
TIntObjectMap items = new TIntObjectHashMap<>();
items.putAll(habbo.getInventory().getItemsComponent().getItems());
habbo.getInventory().getItemsComponent().getItems().clear();
@@ -47,10 +44,12 @@ public class EmptyInventoryCommand extends Command {
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems()));
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared"), RoomChatMessageBubbles.ALERT);
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
+ } else {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty"), RoomChatMessageBubbles.ALERT);
}
}
return true;
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java
index 6ab16663..f4b40793 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/EmptyPetsInventoryCommand.java
@@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.messages.outgoing.inventory.InventoryPetsComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
@@ -30,25 +31,24 @@ public class EmptyPetsInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
- Habbo habbo = gameClient.getHabbo();
- if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
- habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
- }
+
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap pets = new TIntObjectHashMap<>();
pets.putAll(habbo.getInventory().getPetsComponent().getPets());
habbo.getInventory().getPetsComponent().getPets().clear();
- pets.forEachValue(new TObjectProcedure() {
- @Override
- public boolean execute(Pet object) {
- Emulator.getGameEnvironment().getPetManager().deletePet(object);
- return true;
- }
+ pets.forEachValue(object -> {
+ Emulator.getGameEnvironment().getPetManager().deletePet(object);
+ return true;
});
habbo.getClient().sendResponse(new InventoryRefreshComposer());
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.cleared"), RoomChatMessageBubbles.ALERT);
+ habbo.getClient().sendResponse(new InventoryPetsComposer(habbo));
+
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
+ } else {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty_pets"), RoomChatMessageBubbles.ALERT);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java
index 3b459feb..cf69a1d1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/EnableCommand.java
@@ -2,10 +2,15 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class EnableCommand extends Command {
+ private static final Logger LOGGER = LoggerFactory.getLogger(EnableCommand.class);
+
public EnableCommand() {
super("cmd_enable", Emulator.getTexts().getValue("commands.keys.cmd_enable").split(";"));
}
@@ -25,7 +30,7 @@ public class EnableCommand extends Command {
}
if (target != null) {
- if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission("acc_enable_others")) {
+ if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermission(Permission.ACC_ENABLE_OTHERS)) {
try {
if (target.getHabboInfo().getCurrentRoom() != null) {
if (target.getHabboInfo().getRiding() == null) {
@@ -38,7 +43,7 @@ public class EnableCommand extends Command {
}
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java
index 148fa4c8..9e208a0a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/FilterWordCommand.java
@@ -4,12 +4,16 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.WordFilter;
import com.eu.habbo.habbohotel.modtool.WordFilterWord;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class FilterWordCommand extends Command {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterWordCommand.class);
+
public FilterWordCommand() {
super("cmd_filterword", Emulator.getTexts().getValue("commands.keys.cmd_filterword").split(";"));
}
@@ -35,7 +39,7 @@ public class FilterWordCommand extends Command {
statement.setString(2, replacement);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_filterword.error"));
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java
index 6be973a9..52a3d454 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/HotelAlertCommand.java
@@ -32,7 +32,6 @@ public class HotelAlertCommand extends Command {
habbo.getClient().sendResponse(msg);
}
-
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ha.forgot_message"), RoomChatMessageBubbles.ALERT);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java
index 6855b6b2..1c1055b1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java
@@ -59,24 +59,21 @@ public class MassGiftCommand extends Command {
keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous"));
ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
- Habbo habbo = set.getValue();
+ Emulator.getThreading().run(() -> {
+ for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
+ Habbo habbo = set.getValue();
- HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
+ HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
- Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
+ Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
- String extraData = "1\t" + item.getId();
- extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
+ String extraData = "1\t" + item.getId();
+ extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
- Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
+ Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
- habbo.getClient().sendResponse(new InventoryRefreshComposer());
- habbo.getClient().sendResponse(giftNotificiationMessage);
- }
+ habbo.getClient().sendResponse(new InventoryRefreshComposer());
+ habbo.getClient().sendResponse(giftNotificiationMessage);
}
});
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java
index 80bef498..123f1db4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/MimicCommand.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
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 com.eu.habbo.habbohotel.users.HabboGender;
@@ -27,7 +28,7 @@ public class MimicCommand extends Command {
if (habbo == gameClient.getHabbo()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_mimic.not_self"), RoomChatMessageBubbles.ALERT);
return true;
- } else if (habbo.hasPermission("acc_not_mimiced") && !gameClient.getHabbo().hasPermission("acc_not_mimiced")) {
+ } 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())) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java
index b88d5352..21db5c7f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/RedeemCommand.java
@@ -52,12 +52,6 @@ public class RedeemCommand extends Command {
pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]);
points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount);
- } else if (item.getBaseItem().getName().startsWith("CF_diamond_")) {
- try {
- int amount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]);
- points.adjustOrPutValue(5, amount, amount);
- } catch (Exception e) {
- }
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java
index 8affbd20..3b3f5161 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/RoomBundleCommand.java
@@ -7,10 +7,14 @@ import com.eu.habbo.habbohotel.catalog.CatalogPageLayouts;
import com.eu.habbo.habbohotel.catalog.layouts.RoomBundleLayout;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
public class RoomBundleCommand extends Command {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RoomBundleCommand.class);
+
public RoomBundleCommand() {
super("cmd_bundle", Emulator.getTexts().getValue("commands.keys.cmd_bundle").split(";"));
}
@@ -62,7 +66,7 @@ public class RoomBundleCommand extends Command {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
((RoomBundleLayout) page).loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom());
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java
new file mode 100644
index 00000000..c89ab075
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/SoftKickCommand.java
@@ -0,0 +1,38 @@
+package com.eu.habbo.habbohotel.commands;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.users.Habbo;
+
+public class SoftKickCommand extends Command {
+ public SoftKickCommand() {
+ super("cmd_softkick", Emulator.getTexts().getValue("commands.keys.cmd_softkick").split(";"));
+ }
+
+ @Override
+ public boolean handle(GameClient gameClient, String[] params) throws Exception {
+ if (params.length == 2) {
+ final String username = params[1];
+ final Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(username);
+
+ if (habbo == null) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error").replace("%user%", username), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
+ if (habbo == gameClient.getHabbo()) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.keys.cmd_softkick_error_self"), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
+ final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+
+ if (room != null) {
+ room.kickHabbo(habbo, false);
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java
index 9caaa41d..243dec78 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/TestCommand.java
@@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.messages.ServerMessage;
public class TestCommand extends Command {
@@ -12,7 +12,7 @@ public class TestCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
- if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasPermission("acc_supporttool") || !Emulator.debugging)
+ if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL) || !Emulator.debugging)
return false;
int header = Integer.valueOf(params[1]);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java
index ee3b5f9a..c01c2e94 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/UpdateNavigatorCommand.java
@@ -13,7 +13,7 @@ public class UpdateNavigatorCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) throws Exception {
Emulator.getGameEnvironment().getNavigatorManager().loadNavigator();
Emulator.getGameEnvironment().getRoomManager().loadRoomModels();
-
+ Emulator.getGameEnvironment().getRoomManager().loadPublicRooms();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_navigator"), RoomChatMessageBubbles.ALERT);
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
index 88d25872..fdd621c8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
@@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.ModToolBan;
+import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
@@ -42,9 +43,9 @@ public class UserInfoCommand extends Command {
Emulator.getTexts().getValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.rank") + ": " + habbo.getRank().getName() + " (" + habbo.getRank().getId() + ") \r" +
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
- Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r" +
- ((habbo.getRank().hasPermission("acc_hide_ip", true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
- ((habbo.getRank().hasPermission("acc_hide_ip", true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
+ ((habbo.getRank().hasPermission(Permission.ACC_HIDE_MAIL, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
+ ((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
+ ((habbo.getRank().hasPermission(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java
index cdaded07..9fe611a4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingManager.java
@@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectProcedure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -11,6 +13,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class CraftingManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CraftingManager.class);
private final THashMap
- altars;
@@ -53,14 +56,14 @@ public class CraftingManager {
recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount"));
altar.addIngredient(ingredientItem);
} else {
- Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id"));
+ LOGGER.error("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id"));
}
}
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -114,7 +117,7 @@ public class CraftingManager {
}
statement.executeBatch();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.altars.clear();
diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
index 6b7ff3f5..a05ef0a0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
+++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClient.java
@@ -1,15 +1,14 @@
package com.eu.habbo.habbohotel.gameclients;
import com.eu.habbo.Emulator;
-import com.eu.habbo.core.Logging;
+import com.eu.habbo.crypto.HabboEncryption;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.messages.PacketManager;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.MessageComposer;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -18,66 +17,95 @@ import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
public class GameClient {
- public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GameClient.class);
+
private final Channel channel;
- public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
+ private final HabboEncryption encryption;
+
private Habbo habbo;
+ private boolean handshakeFinished;
private String machineId = "";
+
+ public final ConcurrentHashMap incomingPacketCounter = new ConcurrentHashMap<>(25);
public final ConcurrentHashMap, Long> messageTimestamps = new ConcurrentHashMap<>();
+ public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
public GameClient(Channel channel) {
this.channel = channel;
+ this.encryption = Emulator.getCrypto().isEnabled()
+ ? new HabboEncryption(
+ Emulator.getCrypto().getExponent(),
+ Emulator.getCrypto().getModulus(),
+ Emulator.getCrypto().getPrivateExponent())
+ : null;
}
+ public Channel getChannel() {
+ return this.channel;
+ }
+
+ public HabboEncryption getEncryption() {
+ return encryption;
+ }
+
+ public Habbo getHabbo() {
+ return this.habbo;
+ }
+
+ public void setHabbo(Habbo habbo) {
+ this.habbo = habbo;
+ }
+
+ public boolean isHandshakeFinished() {
+ return handshakeFinished;
+ }
+
+ public void setHandshakeFinished(boolean handshakeFinished) {
+ this.handshakeFinished = handshakeFinished;
+ }
+
+ public String getMachineId() {
+ return this.machineId;
+ }
+
+ public void setMachineId(String machineId) {
+ if (machineId == null) {
+ throw new RuntimeException("Cannot set machineID to NULL");
+ }
+
+ this.machineId = machineId;
+ }
public void sendResponse(MessageComposer composer) {
- if (this.channel.isOpen()) {
- try {
- ServerMessage msg = composer.compose();
- this.sendResponse(msg);
- } catch (Exception e) {
- Emulator.getLogging().logPacketError(e);
- }
- }
+ this.sendResponse(composer.compose());
}
-
public void sendResponse(ServerMessage response) {
if (this.channel.isOpen()) {
if (response == null || response.getHeader() <= 0) {
return;
}
- if (PacketManager.DEBUG_SHOW_PACKETS)
- Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString());
-
- this.channel.write(response.get(), this.channel.voidPromise());
+ this.channel.write(response, this.channel.voidPromise());
this.channel.flush();
}
}
-
public void sendResponses(ArrayList responses) {
- ByteBuf buffer = Unpooled.buffer();
-
if (this.channel.isOpen()) {
for (ServerMessage response : responses) {
if (response == null || response.getHeader() <= 0) {
return;
}
- if (PacketManager.DEBUG_SHOW_PACKETS)
- Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString());
-
- buffer.writeBytes(response.get());
+ this.channel.write(response);
}
- this.channel.write(buffer.copy(), this.channel.voidPromise());
+
this.channel.flush();
}
- buffer.release();
}
-
public void dispose() {
try {
this.channel.close();
@@ -91,40 +119,7 @@ public class GameClient {
this.habbo = null;
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
- }
- }
-
- public Channel getChannel() {
- return this.channel;
- }
-
- public Habbo getHabbo() {
- return this.habbo;
- }
-
- public void setHabbo(Habbo habbo) {
- this.habbo = habbo;
- }
-
- public String getMachineId() {
- return this.machineId;
- }
-
- public void setMachineId(String machineId) {
- if (machineId == null) {
- throw new RuntimeException("Cannot set machineID to NULL");
- }
- this.machineId = machineId;
-
- if (this.habbo != null) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) {
- statement.setString(1, this.machineId);
- statement.setInt(2, this.habbo.getHabboInfo().getId());
- statement.execute();
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- }
+ LOGGER.error("Caught exception", e);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
index 4d1198f4..ad9b28ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
@@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.gameclients;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
+import com.eu.habbo.networking.gameserver.GameServerAttributes;
import io.netty.channel.*;
-import io.netty.util.AttributeKey;
import java.util.ArrayList;
import java.util.List;
@@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class GameClientManager {
- public static final AttributeKey CLIENT = AttributeKey.valueOf("GameClient");
+
private final ConcurrentMap clients;
public GameClientManager() {
@@ -34,7 +34,7 @@ public class GameClientManager {
}
});
- ctx.channel().attr(CLIENT).set(client);
+ ctx.channel().attr(GameServerAttributes.CLIENT).set(client);
ctx.fireChannelRegistered();
return this.clients.putIfAbsent(ctx.channel().id(), client) == null;
@@ -46,13 +46,13 @@ public class GameClientManager {
}
private void disposeClient(Channel channel) {
- GameClient client = channel.attr(CLIENT).get();
+ GameClient client = channel.attr(GameServerAttributes.CLIENT).get();
if (client != null) {
client.dispose();
}
channel.deregister();
- channel.attr(CLIENT).set(null);
+ channel.attr(GameServerAttributes.CLIENT).set(null);
channel.closeFuture();
channel.close();
this.clients.remove(channel.id());
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
index b64d8292..16783eb7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
@@ -20,12 +20,14 @@ import com.eu.habbo.plugin.events.games.GameStartedEvent;
import com.eu.habbo.plugin.events.games.GameStoppedEvent;
import com.eu.habbo.threading.runnables.SaveScoreForTeam;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.stream.Collectors;
public abstract class Game implements Runnable {
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(Game.class);
protected final THashMap teams = new THashMap<>();
protected final Room room;
private final Class extends GameTeam> gameTeamClazz;
@@ -73,7 +75,7 @@ public abstract class Game implements Runnable {
return true;
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return false;
@@ -120,6 +122,10 @@ public abstract class Game implements Runnable {
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
((WiredBlob) item).onGameStart(this.room);
}
+
+ for (GameTeam team : this.teams.values()) {
+ team.resetScores();
+ }
}
public void onEnd() {
@@ -135,9 +141,11 @@ public abstract class Game implements Runnable {
}
GameTeam winningTeam = null;
- for (GameTeam team : this.teams.values()) {
- if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) {
- winningTeam = team;
+ if(totalPointsGained > 0) {
+ for (GameTeam team : this.teams.values()) {
+ if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore()) {
+ winningTeam = team;
+ }
}
}
@@ -164,7 +172,7 @@ public abstract class Game implements Runnable {
WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
}
- if (team.getMembers().size() > 0) {
+ if (team.getMembers().size() > 0 && team.getTotalScore() > 0) {
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), team.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), team.getTotalScore(), false, Emulator.getIntUnixTimestamp()));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
index aad945b1..143974dd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
@@ -86,6 +86,8 @@ public class GameTeam {
player.reset();
}
+
+ this.teamScore = 0;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
index 074d494a..07b83048 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
@@ -17,12 +17,16 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
public class BattleBanzaiGame extends Game {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BattleBanzaiGame.class);
+
public static final int effectId = 32;
@@ -40,6 +44,7 @@ public class BattleBanzaiGame extends Game {
private final THashMap gameTiles;
private int tileCount;
private int countDown;
+ private int countDown2;
public BattleBanzaiGame(Room room) {
super(BattleBanzaiGameTeam.class, BattleBanzaiGamePlayer.class, room, true);
@@ -54,8 +59,12 @@ public class BattleBanzaiGame extends Game {
public void initialise() {
if (!this.state.equals(GameState.IDLE))
return;
-
+
+ /* The first countdown is activated for the first two seconds emitting only the blue light (second interaction),
+ the second, after another two seconds, completely activates the sphere (third interaction).
+ */
this.countDown = 3;
+ this.countDown2 = 2;
this.resetMap();
@@ -101,8 +110,15 @@ public class BattleBanzaiGame extends Game {
if (this.countDown == 0) {
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
- item.setExtradata("2");
+ item.setExtradata("1");
this.room.updateItemState(item);
+ if(this.countDown2 > 0) {
+ this.countDown2--;
+ if(this.countDown2 == 0) {
+ item.setExtradata("2");
+ this.room.updateItemState(item);
+ }
+ }
}
}
@@ -149,7 +165,7 @@ public class BattleBanzaiGame extends Game {
}
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
index 24b0a64c..eb625350 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
@@ -23,11 +23,15 @@ import com.eu.habbo.threading.runnables.freeze.FreezeThrowSnowball;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
public class FreezeGame extends Game {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreezeGame.class);
+
public static final int effectId = 39;
public static int POWER_UP_POINTS;
@@ -261,7 +265,7 @@ public class FreezeGame extends Game {
}
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java
index 075b31a7..d77f6773 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/Guild.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.guilds;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -8,6 +10,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class Guild implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Guild.class);
public boolean needsUpdate;
public int lastRequested = Emulator.getIntUnixTimestamp();
private int id;
@@ -91,7 +94,7 @@ public class Guild implements Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -116,7 +119,7 @@ public class Guild implements Runnable {
this.needsUpdate = false;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
index 71a017aa..2f84660d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
@@ -13,6 +13,8 @@ import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.*;
@@ -20,6 +22,8 @@ import java.util.stream.Collectors;
public class GuildManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GuildManager.class);
+
private final THashMap> guildParts;
private final TIntObjectMap guilds;
@@ -34,7 +38,7 @@ public class GuildManager {
this.loadGuildParts();
this.loadGuildViews();
- Emulator.getLogging().logStart("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Guild Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
@@ -52,7 +56,7 @@ public class GuildManager {
this.guildParts.get(GuildPartType.valueOf(set.getString("type").toUpperCase())).put(set.getInt("id"), new GuildPart(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -66,7 +70,7 @@ public class GuildManager {
this.views.add(new ForumView(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -107,7 +111,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
habbo.getHabboStats().addGuild(guild.getId());
@@ -155,7 +159,7 @@ public class GuildManager {
room.setGuild(0);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -276,7 +280,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -288,7 +292,7 @@ public class GuildManager {
statement.setInt(3, guild.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -303,7 +307,7 @@ public class GuildManager {
statement.setInt(3, guild.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -325,7 +329,7 @@ public class GuildManager {
statement.setInt(2, guild.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -352,7 +356,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return member;
@@ -375,7 +379,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return guildMembers;
@@ -397,7 +401,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return guildMembers;
@@ -416,7 +420,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return 0;
@@ -434,7 +438,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return guildAdmins;
@@ -466,7 +470,7 @@ public class GuildManager {
if (g != null)
g.loadMemberCount();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -494,7 +498,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return guilds;
@@ -514,7 +518,7 @@ public class GuildManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return guilds;
@@ -593,7 +597,7 @@ public class GuildManager {
statement.setInt(2, furni.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -608,7 +612,7 @@ public class GuildManager {
guildIterator.remove();
}
- Emulator.getLogging().logShutdownLine("Guild Manager -> Disposed!");
+ LOGGER.info("Guild Manager -> Disposed!");
}
public boolean hasViewedForum(int userId, int guildId) {
@@ -628,7 +632,7 @@ public class GuildManager {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
index 5d432c79..f4325c0d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
@@ -9,11 +9,15 @@ import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadBeforeCreated;
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCreated;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.*;
public class ForumThread implements Runnable, ISerialize {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ForumThread.class);
+
private final static THashMap> guildThreadsCache = new THashMap<>();
private final static THashMap forumThreadsCache = new THashMap<>();
@@ -69,7 +73,8 @@ public class ForumThread implements Runnable, ISerialize {
try {
this.lastComment = ForumThreadComment.getById(set.getInt("last_comment_id"));
- } catch (Exception e) {
+ } catch (SQLException e) {
+ LOGGER.error("ForumThread last_comment_id exception", e);
}
this.comments = new THashMap<>();
@@ -108,7 +113,7 @@ public class ForumThread implements Runnable, ISerialize {
Emulator.getPluginManager().fireEvent(new GuildForumThreadCreated(createdThread));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return createdThread;
@@ -156,7 +161,7 @@ public class ForumThread implements Runnable, ISerialize {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return threads;
@@ -195,7 +200,7 @@ public class ForumThread implements Runnable, ISerialize {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return foundThread;
@@ -337,7 +342,7 @@ public class ForumThread implements Runnable, ISerialize {
addComment(comment);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -461,7 +466,7 @@ public class ForumThread implements Runnable, ISerialize {
this.needsUpdate = false;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
index 01f6792c..1be9631a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadComment.java
@@ -8,10 +8,13 @@ import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentBeforeCreated;
import com.eu.habbo.plugin.events.guilds.forums.GuildForumThreadCommentCreated;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
public class ForumThreadComment implements Runnable, ISerialize {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ForumThreadComment.class);
private static THashMap forumCommentsCache = new THashMap<>();
private final int commentId;
@@ -64,7 +67,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(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) {
- Emulator.getLogging().logSQLException(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) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java
index 1593623b..a4c398b8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HallOfFame.java
@@ -2,6 +2,8 @@ package com.eu.habbo.habbohotel.hotelview;
import com.eu.habbo.Emulator;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -9,6 +11,7 @@ import java.sql.SQLException;
import java.sql.Statement;
public class HallOfFame {
+ private static final Logger LOGGER = LoggerFactory.getLogger(HallOfFame.class);
private final THashMap winners = new THashMap<>();
@@ -32,7 +35,7 @@ public class HallOfFame {
this.winners.put(winner.getId(), winner);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java
index b097edcd..81048f3b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/HotelViewManager.java
@@ -1,8 +1,12 @@
package com.eu.habbo.habbohotel.hotelview;
-import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HotelViewManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HotelViewManager.class);
+
private final HallOfFame hallOfFame;
private final NewsList newsList;
@@ -11,7 +15,7 @@ public class HotelViewManager {
this.hallOfFame = new HallOfFame();
this.newsList = new NewsList();
- Emulator.getLogging().logStart("Hotelview Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Hotelview Manager -> Loaded! ({} MS)", System.currentTimeMillis() - millis);
}
public HallOfFame getHallOfFame() {
@@ -23,6 +27,7 @@ public class HotelViewManager {
}
public void dispose() {
- Emulator.getLogging().logShutdownLine("HotelView Manager -> Disposed!");
+ LOGGER.info("HotelView Manager -> Disposed!");
}
+
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java
index 8be6fd7c..b3bebc4f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java
+++ b/src/main/java/com/eu/habbo/habbohotel/hotelview/NewsList.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.hotelview;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -9,6 +11,8 @@ import java.sql.Statement;
import java.util.ArrayList;
public class NewsList {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NewsList.class);
+
private final ArrayList newsWidgets;
public NewsList() {
@@ -25,7 +29,7 @@ public class NewsList {
this.newsWidgets.add(new NewsWidget(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
index 87e1caf6..60497794 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.items;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -9,6 +11,8 @@ import java.util.HashMap;
import java.util.Map;
public class CrackableReward {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CrackableReward.class);
+
public final int itemId;
public final int count;
public final Map> prizes;
@@ -44,7 +48,7 @@ public class CrackableReward {
itemId = Integer.valueOf(prize.split(":")[0]);
chance = Integer.valueOf(prize.split(":")[1]);
} else if (prize.contains(":")) {
- Emulator.getLogging().logErrorLine("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance.");
+ LOGGER.error("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance.");
} else {
itemId = Integer.valueOf(prize.replace(":", ""));
}
@@ -52,7 +56,7 @@ public class CrackableReward {
this.prizes.put(itemId, new AbstractMap.SimpleEntry<>(this.totalChance, this.totalChance + chance));
this.totalChance += chance;
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
index caf8932a..eb7316ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
@@ -54,7 +54,7 @@ public class Item {
try {
int index = Integer.valueOf(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length);
return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)];
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
index dbfea5f1..7fdc0202 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
@@ -60,12 +60,17 @@ import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor;
import java.sql.*;
import java.util.*;
public class ItemManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ItemManager.class);
+
//Configuration. Loaded from database & updated accordingly.
public static boolean RECYCLER_ENABLED = true;
@@ -100,7 +105,7 @@ public class ItemManager {
this.highscoreManager.load();
this.loadNewUserGifts();
- Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
protected void loadItemInteractions() {
@@ -197,12 +202,7 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_trg_game_ends", WiredTriggerGameEnds.class));
this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_stf", WiredTriggerBotReachedFurni.class));
this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_says_command", WiredTriggerHabboSaysCommand.class));
this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_idles", WiredTriggerHabboIdle.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_starts_dancing", WiredTriggerHabboStartsDancing.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_stops_dancing", WiredTriggerHabboStopsDancing.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class));
@@ -233,22 +233,10 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowHabbo.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_clothes", WiredEffectBotClothes.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToHabbo.class));
- this.interactionsList.add(new ItemInteraction("wf_act_give_diamonds", WiredEffectGiveDiamonds.class));
- this.interactionsList.add(new ItemInteraction("wf_act_give_credits", WiredEffectGiveCredits.class));
- this.interactionsList.add(new ItemInteraction("wf_act_give_duckets", WiredEffectGiveDuckets.class));
- this.interactionsList.add(new ItemInteraction("wf_act_give_badge", WiredEffectGiveBadge.class));
- this.interactionsList.add(new ItemInteraction("wf_act_forward_user", WiredEffectForwardToRoom.class));
- this.interactionsList.add(new ItemInteraction("wf_act_roller_speed", WiredEffectRollerSpeed.class));
- this.interactionsList.add(new ItemInteraction("wf_act_raise_furni", WiredEffectRaiseFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_act_lower_furni", WiredEffectLowerFurni.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_respect", WiredEffectGiveRespect.class));
this.interactionsList.add(new ItemInteraction("wf_act_alert", WiredEffectAlert.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class));
- this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot2", WiredEffectMatchFurniStaff.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class));
- this.interactionsList.add(new ItemInteraction("wf_act_open_habbo_pages", WiredEffectOpenHabboPages.class));
- this.interactionsList.add(new ItemInteraction("wf_act_give_achievement", WiredEffectGiveAchievement.class));
-
this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class));
@@ -274,23 +262,6 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class));
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_cnd_motto_contains", WiredConditionMottoContains.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_battlebanzai", WiredConditionBattleBanzaiGameActive.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_battlebanzai", WiredConditionNotBattleBanzaiGameActive.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_freeze", WiredConditionFreezeGameActive.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_freeze", WiredConditionNotFreezeGameActive.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_rank", WiredConditionHabboHasRank.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_not_rank", WiredConditionHabboNotRank.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_diamonds", WiredConditionHabboHasDiamonds.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_credits", WiredConditionHabboHasCredits.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_has_duckets", WiredConditionHabboHasDuckets.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_diamonds", WiredConditionNotHabboHasDiamonds.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_credits", WiredConditionNotHabboHasCredits.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_has_duckets", WiredConditionNotHabboHasDuckets.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_owns_badge", WiredConditionHabboOwnsBadge.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_owns_badge", WiredConditionNotHabboOwnsBadge.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_habbo_is_dancing", WiredConditionHabboIsDancing.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_habbo_is_dancing", WiredConditionNotHabboIsDancing.class));
this.interactionsList.add(new ItemInteraction("wf_xtra_random", WiredExtraRandom.class));
@@ -388,7 +359,7 @@ public class ItemManager {
return interaction;
}
- Emulator.getLogging().logDebugLine("Can't find interaction class:" + type.getName());
+ LOGGER.debug("Can't find interaction class: {}", type.getName());
return this.getItemInteraction(InteractionDefault.class);
}
@@ -418,12 +389,12 @@ public class ItemManager {
else
this.items.get(id).update(set);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to load Item (" + set.getInt("id") + ")");
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Failed to load Item ({})", set.getInt("id"));
+ LOGGER.error("Caught exception", e);
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -436,16 +407,16 @@ public class ItemManager {
try {
reward = new CrackableReward(set);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("item_id"));
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Failed to load items_crackable item_id = {}", set.getInt("item_id"));
+ LOGGER.error("Caught exception", e);
continue;
}
this.crackableRewards.put(set.getInt("item_id"), reward);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -479,7 +450,7 @@ public class ItemManager {
this.soundTracks.put(set.getString("code"), new SoundTrack(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -512,16 +483,16 @@ public class ItemManager {
try {
return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells);
}
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return null;
}
@@ -536,7 +507,7 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -561,7 +532,7 @@ public class ItemManager {
statement.setInt(1, item.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -588,7 +559,7 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return item;
@@ -628,9 +599,9 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return item;
@@ -642,7 +613,7 @@ public class ItemManager {
statement.setInt(2, itemTwoId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -652,7 +623,7 @@ public class ItemManager {
statement.setInt(2, hopper.getBaseItem().getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -667,7 +638,7 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return a;
@@ -683,9 +654,9 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return item;
@@ -706,7 +677,7 @@ public class ItemManager {
return (HabboItem) c.newInstance(set, baseItem);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -729,7 +700,7 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -737,7 +708,7 @@ public class ItemManager {
return null;
if (extraData.length() > 1000) {
- Emulator.getLogging().logErrorLine("Extradata exceeds maximum length of 1000 characters:" + extraData);
+ LOGGER.error("Extradata exceeds maximum length of 1000 characters: {}", extraData);
extraData = extraData.substring(0, 1000);
}
@@ -754,7 +725,7 @@ public class ItemManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
if (gift != null) {
@@ -808,7 +779,7 @@ public class ItemManager {
this.items.clear();
this.highscoreManager.dispose();
- Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!");
+ LOGGER.info("Item Manager -> Disposed!");
}
public List getInteractionList() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java
index 931be676..bc9662a3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/RandomStateParams.java
@@ -1,10 +1,13 @@
package com.eu.habbo.habbohotel.items;
-import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
public class RandomStateParams {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RandomStateParams.class);
+
private int states = -1;
private int delay = -1;
@@ -22,7 +25,7 @@ public class RandomStateParams {
this.delay = Integer.parseInt(keyValue[1]);
break;
default:
- Emulator.getLogging().logDebugLine("RandomStateParams: unknown key: " + keyValue[0]);
+ LOGGER.warn("RandomStateParams: unknown key: " + keyValue[0]);
break;
}
});
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
index 4e9ce06d..3be71726 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java
@@ -6,12 +6,13 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.MalformedURLException;
import java.net.URL;
import java.sql.*;
import java.util.ArrayList;
@@ -20,6 +21,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class YoutubeManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class);
+
public class YoutubeVideo {
private final String id;
private final int duration;
@@ -80,7 +83,7 @@ public class YoutubeManager {
Emulator.getThreading().run(() -> {
ExecutorService youtubeDataLoaderPool = Executors.newFixedThreadPool(10);
- Emulator.getLogging().logStart("YouTube Manager -> Loading...");
+ LOGGER.info("YouTube Manager -> Loading...");
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM youtube_playlists")) {
try (ResultSet set = statement.executeQuery()) {
@@ -95,7 +98,7 @@ public class YoutubeManager {
if (playlist != null) {
playlists.add(playlist);
} else {
- Emulator.getLogging().logErrorLine("Failed to load YouTube playlist: " + playlistId);
+ LOGGER.error("Failed to load YouTube playlist: " + playlistId);
}
this.playlists.put(itemId, playlists);
@@ -103,7 +106,7 @@ public class YoutubeManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
youtubeDataLoaderPool.shutdown();
@@ -113,7 +116,7 @@ public class YoutubeManager {
e.printStackTrace();
}
- Emulator.getLogging().logStart("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("YouTube Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
});
}
@@ -130,37 +133,35 @@ public class YoutubeManager {
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
-
- YoutubePlaylist playlist = null;
-
- String inputLine;
- while ((inputLine = br.readLine()) != null) {
- if (inputLine.contains("window[\"ytInitialData\"]")) {
- JsonObject obj = new JsonParser().parse(inputLine.substring(inputLine.indexOf("{")).replace(";", "")).getAsJsonObject();
-
- JsonObject meta = obj.get("microformat").getAsJsonObject().get("microformatDataRenderer").getAsJsonObject();
- String name = meta.get("title").getAsString();
- String description = meta.get("description").getAsString();
-
- ArrayList videos = new ArrayList<>();
-
- JsonArray rawVideos = obj.get("contents").getAsJsonObject().get("twoColumnBrowseResultsRenderer").getAsJsonObject().get("tabs").getAsJsonArray().get(0).getAsJsonObject().get("tabRenderer").getAsJsonObject().get("content").getAsJsonObject().get("sectionListRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("itemSectionRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("playlistVideoListRenderer").getAsJsonObject().get("contents").getAsJsonArray();
-
- for (JsonElement rawVideo : rawVideos) {
- JsonObject videoData = rawVideo.getAsJsonObject().get("playlistVideoRenderer").getAsJsonObject();
- if (!videoData.has("lengthSeconds")) continue; // removed videos
- videos.add(new YoutubeVideo(videoData.get("videoId").getAsString(), Integer.valueOf(videoData.get("lengthSeconds").getAsString())));
+ YoutubePlaylist playlist;
+ try (BufferedReader br = new BufferedReader(isr)) {
+ playlist = null;
+ String inputLine;
+ while ((inputLine = br.readLine()) != null) {
+ if (inputLine.contains("window[\"ytInitialData\"]")) {
+ JsonObject obj = new JsonParser().parse(inputLine.substring(inputLine.indexOf("{")).replace(";", "")).getAsJsonObject();
+
+ JsonObject meta = obj.get("microformat").getAsJsonObject().get("microformatDataRenderer").getAsJsonObject();
+ String name = meta.get("title").getAsString();
+ String description = meta.get("description").getAsString();
+
+ ArrayList videos = new ArrayList<>();
+
+ JsonArray rawVideos = obj.get("contents").getAsJsonObject().get("twoColumnBrowseResultsRenderer").getAsJsonObject().get("tabs").getAsJsonArray().get(0).getAsJsonObject().get("tabRenderer").getAsJsonObject().get("content").getAsJsonObject().get("sectionListRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("itemSectionRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("playlistVideoListRenderer").getAsJsonObject().get("contents").getAsJsonArray();
+
+ for (JsonElement rawVideo : rawVideos) {
+ JsonObject videoData = rawVideo.getAsJsonObject().get("playlistVideoRenderer").getAsJsonObject();
+ if (!videoData.has("lengthSeconds")) continue; // removed videos
+ videos.add(new YoutubeVideo(videoData.get("videoId").getAsString(), Integer.valueOf(videoData.get("lengthSeconds").getAsString())));
+ }
+
+ playlist = new YoutubePlaylist(playlistId, name, description, videos);
+
+ break;
}
-
- playlist = new YoutubePlaylist(playlistId, name, description, videos);
-
- break;
}
}
- br.close();
-
this.playlistCache.put(playlistId, playlist);
return playlist;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
index 840ede43..813ce782 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
@@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@@ -58,9 +59,22 @@ public class InteractionBackgroundToner extends HabboItem {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (client.getHabbo().getRoomUnit().cmdSit && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
- Emulator.getThreading().run(new BackgroundAnimation(this, room));
- return;
+ if(client != null)
+ {
+ if (!client.getHabbo().getRoomUnit().getRoom().hasRights(client.getHabbo())) {
+ ScripterManager.scripterDetected(
+ client,
+ Emulator.getTexts().getValue("scripter.warning.item.bgtoner.permission").replace("%username%", client.getHabbo().getHabboInfo().getUsername())
+ .replace("%room%", room.getName())
+ .replace("%owner%", room.getOwnerName())
+ );
+ return;
+ }
+
+ if (client.getHabbo().getRoomUnit().cmdSit && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
+ new BackgroundAnimation(this, room).run();
+ return;
+ }
}
if (this.getExtradata().split(":").length == 4) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
index a16115cb..133e83c9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
@@ -1,14 +1,17 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionColorPlate extends InteractionDefault {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionColorPlate.class);
+
public InteractionColorPlate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@@ -41,7 +44,7 @@ public class InteractionColorPlate extends InteractionDefault {
try {
state = Integer.valueOf(this.getExtradata());
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
state += amount;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
index 95308f40..1db3a1d2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
@@ -1,6 +1,5 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
@@ -10,11 +9,15 @@ import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionDefault extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionDefault.class);
+
public InteractionDefault(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@@ -74,7 +77,7 @@ public class InteractionDefault extends HabboItem {
try {
currentState = Integer.valueOf(this.getExtradata());
} catch (NumberFormatException e) {
- Emulator.getLogging().logErrorLine("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
+ LOGGER.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
}
this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
index 2d9106c9..99df17f1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
@@ -44,12 +44,9 @@ public class InteractionEffectGiver extends InteractionDefault {
this.setExtradata("1");
room.updateItem(this);
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- InteractionEffectGiver.this.setExtradata("0");
- room.updateItem(instance);
- }
+ Emulator.getThreading().run(() -> {
+ InteractionEffectGiver.this.setExtradata("0");
+ room.updateItem(instance);
}, 500);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
index eccba568..c0d42279 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
@@ -29,7 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionVendingMachine {
}
@Override
- public void giveVendingMachineItem(Habbo habbo, Room room) {
- room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30);
+ public void giveVendingMachineItem(Room room, RoomUnit unit) {
+ room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
index a645676e..ca92ccf4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
@@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
-import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
index 5c0b3422..f7ceb0e3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
@@ -3,6 +3,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.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@@ -38,17 +39,21 @@ public class InteractionGate extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
- if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
+ boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
+
+ if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired)
return;
- if (!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty())
- return;
+ // If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close
+ for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
+ if (room.hasHabbosAt(tile.x, tile.y))
+ return;
+ // Gate closed = 0, open = 1
if (this.getExtradata().length() == 0)
this.setExtradata("0");
- this.setExtradata((Integer.valueOf(this.getExtradata()) + 1) % 2 + "");
+ this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + "");
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
this.needsUpdate(true);
room.updateItemState(this);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
index 869b59a3..41fb4dc1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
@@ -8,11 +8,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionGift extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGift.class);
+
public boolean explode = false;
private int[] itemId;
private int colorId = 0;
@@ -28,7 +32,7 @@ public class InteractionGift extends HabboItem {
try {
this.loadData();
} catch (Exception e) {
- Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId());
+ LOGGER.warn("Incorrect extradata for gift with ID " + this.getId());
}
}
@@ -38,7 +42,7 @@ public class InteractionGift extends HabboItem {
try {
this.loadData();
} catch (Exception e) {
- Emulator.getLogging().logDebugLine("Incorrect extradata for gift with ID " + this.getId());
+ LOGGER.warn("Incorrect extradata for gift with ID " + this.getId());
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
index d552d5a9..176ae78d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
@@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@@ -35,7 +36,7 @@ public class InteractionGuildGate extends InteractionGuildFurni {
Habbo habbo = room.getHabbo(roomUnit);
- return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasPermission("acc_guildgate"));
+ return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasPermission(Permission.ACC_GUILDGATE));
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
index b6923128..7782736b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
@@ -42,12 +42,9 @@ public class InteractionHanditem extends InteractionDefault {
this.setExtradata("1");
room.updateItem(this);
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- InteractionHanditem.this.setExtradata("0");
- room.updateItem(instance);
- }
+ Emulator.getThreading().run(() -> {
+ InteractionHanditem.this.setExtradata("0");
+ room.updateItem(instance);
}, 500);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
index 83e1bd24..786e369f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
@@ -20,12 +20,9 @@ public class InteractionHanditemTile extends InteractionHanditem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
InteractionHanditemTile instance = this;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY()) {
- instance.handle(room, roomUnit);
- }
+ Emulator.getThreading().run(() -> {
+ if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY()) {
+ instance.handle(room, roomUnit);
}
}, 3000);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
index 95eddcd3..bc5744cd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
@@ -61,15 +61,13 @@ public class InteractionJukeBox extends HabboItem {
public void onPickUp(Room room) {
super.onPickUp(room);
this.setExtradata("0");
-
- if (room.getTraxManager().isPlaying() && room.getRoomSpecialTypes().getItemsOfType(InteractionJukeBox.class).isEmpty()) {
- room.getTraxManager().clearPlayList();
- }
+ room.getTraxManager().removeTraxOnRoom(this);
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
+ room.getTraxManager().addTraxOnRoom(this);
if (room.getTraxManager().isPlaying()) {
this.setExtradata("1");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
index 2901a7b9..cc291a67 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
@@ -60,26 +60,30 @@ public class InteractionMannequin extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- String[] lookCode = this.getExtradata().split(":")[1].split("\\.");
+ String lookCode = this.getExtradata().split(":")[1];
+ String newFigure = "";
- StringBuilder look = new StringBuilder();
- for (String part : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
- String type = part.split("-")[0];
-
- boolean found = false;
- for (String s : lookCode) {
- if (s.contains(type)) {
- found = true;
- look.append(s).append(".");
- }
- }
-
- if (!found) {
- look.append(part).append(".");
- }
+ for (String playerFigurePart : client.getHabbo().getHabboInfo().getLook().split("\\.")) {
+ if (!playerFigurePart.startsWith("ch") && !playerFigurePart.startsWith("lg"))
+ newFigure += playerFigurePart + ".";
}
- client.getHabbo().getHabboInfo().setLook(look.substring(0, look.length() - 1));
+ if (lookCode.isEmpty()) return;
+ String newFigureParts = lookCode;
+
+ for (String newFigurePart : newFigureParts.split("\\.")) {
+ if (newFigurePart.startsWith("hd"))
+ newFigureParts = newFigureParts.replace(newFigurePart, "");
+ }
+
+ if (newFigureParts.equals("")) return;
+
+ final String figure = newFigure + newFigureParts;
+
+ if (figure.length() > 512)
+ return;
+
+ client.getHabbo().getHabboInfo().setLook(figure);
room.sendComposer(new RoomUserDataComposer(client.getHabbo()).compose());
client.sendResponse(new UserDataComposer(client.getHabbo()));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
index efce0c5a..765b6e3b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
@@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import gnu.trove.set.hash.THashSet;
-import org.apache.commons.math3.util.Pair;
import java.sql.ResultSet;
import java.sql.SQLException;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
index 9a163257..f001fc20 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
@@ -1,17 +1,19 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeBoxMySongsComposer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionMusicDisc extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionMusicDisc.class);
+
private int songId;
public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException {
@@ -23,7 +25,7 @@ public class InteractionMusicDisc extends HabboItem {
try {
this.songId = Integer.valueOf(stuff[6]);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
+ LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
}
}
@@ -37,7 +39,7 @@ public class InteractionMusicDisc extends HabboItem {
try {
this.songId = Integer.valueOf(stuff[6]);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
+ LOGGER.error("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
index 367d500e..f2463700 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
@@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
+import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -18,7 +19,18 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine
}
@Override
- public RoomTile getRequiredTile(Habbo habbo, Room room) {
- return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true);
+ public THashSet getActivatorTiles(Room room) {
+
+ THashSet tiles = new THashSet();
+ for(int x = -1; x <= 1; x++) {
+ for(int y = -1; y <= 1; y++) {
+ RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y));
+ if(tile != null) {
+ tiles.add(tile);
+ }
+ }
+ }
+
+ return tiles;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
index 844b042e..01257bea 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
@@ -7,9 +7,14 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.wired.WiredHandler;
+import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.incoming.rooms.users.RoomUserWalkEvent;
import com.eu.habbo.messages.outgoing.rooms.items.ItemIntStateComposer;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -17,6 +22,8 @@ import java.util.ArrayList;
import java.util.List;
public class InteractionOneWayGate extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionOneWayGate.class);
+
private boolean walkable = false;
public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException {
@@ -86,6 +93,8 @@ public class InteractionOneWayGate extends HabboItem {
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4);
unit.setGoalLocation(tile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
+
+ Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
});
onFail.add(() -> {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
index 17b77a39..0eee202b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
@@ -56,24 +56,14 @@ public class InteractionPressurePlate extends HabboItem {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- updateState(room);
- }
- }, 100);
+ Emulator.getThreading().run(() -> updateState(room), 100);
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- updateState(room);
- }
- }, 100);
+ Emulator.getThreading().run(() -> updateState(room), 100);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
index 3cd88425..a8d0db0e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
@@ -50,7 +50,7 @@ public abstract class InteractionPushable extends InteractionDefault {
if (this.currentThread != null)
this.currentThread.dead = true;
- this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity);
+ this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, false);
Emulator.getThreading().run(this.currentThread, 0);
}
}
@@ -69,7 +69,7 @@ public abstract class InteractionPushable extends InteractionDefault {
if (this.currentThread != null)
this.currentThread.dead = true;
- this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity);
+ this.currentThread = new KickBallAction(this, room, client.getHabbo().getRoomUnit(), direction, velocity, false);
Emulator.getThreading().run(this.currentThread, 0);
}
}
@@ -80,6 +80,7 @@ public abstract class InteractionPushable extends InteractionDefault {
super.onWalkOn(roomUnit, room, objects);
int velocity;
+ boolean isDrag = false;
RoomUserRotation direction;
if (this.getX() == roomUnit.getGoal().x && this.getY() == roomUnit.getGoal().y) //User clicked on the tile the ball is on, they want to kick it
@@ -92,13 +93,14 @@ public abstract class InteractionPushable extends InteractionDefault {
velocity = this.getDragVelocity(roomUnit, room);
direction = this.getDragDirection(roomUnit, room);
this.onDrag(room, roomUnit, velocity, direction);
+ isDrag = true;
}
if (velocity > 0) {
if (this.currentThread != null)
this.currentThread.dead = true;
- this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity);
+ this.currentThread = new KickBallAction(this, room, roomUnit, direction, velocity, isDrag);
Emulator.getThreading().run(this.currentThread, 0);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
index daff0b5d..a23586ba 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
@@ -9,9 +9,6 @@ import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Optional;
public class InteractionPuzzleBox extends HabboItem {
public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
index 4635c63f..48a4d35a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
@@ -12,6 +12,8 @@ import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceInfoComposer;
import com.eu.habbo.threading.runnables.ClearRentedSpace;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.awt.*;
import java.sql.Connection;
@@ -20,6 +22,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionRentableSpace extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionRentableSpace.class);
+
private int renterId;
private String renterName;
private int endTimestamp;
@@ -50,7 +54,7 @@ public class InteractionRentableSpace extends HabboItem {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
} else {
@@ -180,7 +184,7 @@ public class InteractionRentableSpace extends HabboItem {
statement.setInt(1, zero);
statement.setInt(2, zero);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
index 733d6c45..c58f6193 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
@@ -48,12 +48,9 @@ public class InteractionTileEffectProvider extends InteractionCustomValues {
room.updateItem(this);
final InteractionTileEffectProvider proxy = this;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- proxy.values.put("state", "0");
- room.updateItem(proxy);
- }
+ Emulator.getThreading().run(() -> {
+ proxy.values.put("state", "0");
+ room.updateItem(proxy);
}, 500);
room.giveEffect(roomUnit, effectId, -1);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
index adf949e0..54b9baaa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
@@ -52,12 +52,9 @@ public class InteractionTrap extends InteractionDefault {
roomUnit.setCanWalk(false);
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- room.giveEffect(roomUnit, 0, -1);
- roomUnit.setCanWalk(true);
- }
+ Emulator.getThreading().run(() -> {
+ room.giveEffect(roomUnit, 0, -1);
+ roomUnit.setCanWalk(true);
}, delay);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
index 55b96e98..ca0175a2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
@@ -13,12 +13,14 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import com.eu.habbo.util.pathfinding.Rotation;
+import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ScheduledFuture;
public class InteractionVendingMachine extends HabboItem {
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
@@ -30,97 +32,115 @@ public class InteractionVendingMachine extends HabboItem {
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
}
+
+ public THashSet getActivatorTiles(Room room) {
+ THashSet tiles = new THashSet<>();
+ RoomTile tileInFront = getSquareInFront(room.getLayout(), this);
- @Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return true;
+ if (tileInFront != null)
+ tiles.add(tileInFront);
+
+ tiles.add(room.getLayout().getTile(this.getX(), this.getY()));
+ return tiles;
}
@Override
- public boolean isWalkable() {
- return false;
+ public void serializeExtradata(ServerMessage serverMessage) {
+ serverMessage.appendInt((this.isLimited() ? 256 : 0));
+ serverMessage.appendString(this.getExtradata());
+
+ super.serializeExtradata(serverMessage);
+ }
+
+ private void tryInteract(GameClient client, Room room, RoomUnit unit) {
+ THashSet activatorTiles = getActivatorTiles(room);
+
+ if(activatorTiles.size() == 0)
+ return;
+
+ boolean inActivatorSpace = false;
+
+ for(RoomTile tile : activatorTiles) {
+ if(unit.getCurrentLocation().is(unit.getX(), unit.getY())) {
+ inActivatorSpace = true;
+ }
+ }
+
+ if(inActivatorSpace) {
+ useVendingMachine(client, room, unit);
+ }
+ }
+
+ private void useVendingMachine(GameClient client, Room room, RoomUnit unit) {
+ this.setExtradata("1");
+ room.updateItem(this);
+
+ if(!unit.isWalking() && !unit.hasStatus(RoomUnitStatus.SIT) && !unit.hasStatus(RoomUnitStatus.LAY)) {
+ this.rotateToMachine(room, unit);
+ }
+
+ Emulator.getThreading().run(() -> {
+
+ giveVendingMachineItem(room, unit);
+
+ if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
+ if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
+ room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+
+ Emulator.getThreading().run(this, 500);
+ }, 1500);
+ }
+
+ public void giveVendingMachineItem(Room room, RoomUnit unit) {
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(unit, room, this.getBaseItem().getRandomVendingItem()));
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
+
+ if (client == null) {
+ return;
+ }
- if (client != null) {
- RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
+ RoomUnit unit = client.getHabbo().getRoomUnit();
- if (tile != null) {
- if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
- if (this.getExtradata().equals("0") || this.getExtradata().length() == 0) {
- if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
- room.updateHabbo(client.getHabbo());
- this.rotateToMachine(client.getHabbo().getRoomUnit());
- client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
- room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
- }
+ THashSet activatorTiles = getActivatorTiles(room);
- super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
+ if(activatorTiles.size() == 0)
+ return;
- this.setExtradata("1");
- room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
+ boolean inActivatorSpace = false;
- Emulator.getThreading().run(() -> {
- Emulator.getThreading().run(this, 1000);
- this.giveVendingMachineItem(client.getHabbo(), room);
+ for(RoomTile tile : activatorTiles) {
+ if(unit.getCurrentLocation().is(tile.x, tile.y)) {
+ inActivatorSpace = true;
+ }
+ }
- if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
- if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
- }, 500);
- }
- } else {
- if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
- for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
- if (t != null && t.isWalkable()) {
- tile = t;
- break;
- }
- }
- }
-
- RoomTile finalTile = tile;
- client.getHabbo().getRoomUnit().setGoalLocation(tile);
-
- Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> {
- this.setExtradata("1");
- room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
-
- try {
- super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Emulator.getThreading().run(() -> {
- client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
- if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
- this.rotateToMachine(client.getHabbo().getRoomUnit());
- room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
- }
-
- try {
- Emulator.getThreading().run(() -> {
- Emulator.getThreading().run(this, 1000);
- this.giveVendingMachineItem(client.getHabbo(), room);
-
- if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
- if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
- }, 500).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- }, 300));
- }, 250);
- }, null));
+ if(!inActivatorSpace) {
+ RoomTile tileToWalkTo = null;
+ for(RoomTile tile : activatorTiles) {
+ if(room.getLayout().tileWalkable(tile.x, tile.y) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) {
+ tileToWalkTo = tile;
}
}
+
+ if(tileToWalkTo != null) {
+ List onSuccess = new ArrayList();
+ List onFail = new ArrayList();
+
+ onSuccess.add(() -> {
+ tryInteract(client, room, unit);
+ });
+
+ unit.setGoalLocation(tileToWalkTo);
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail));
+ }
+ }
+ else {
+ useVendingMachine(client, room, unit);
}
}
@@ -129,16 +149,6 @@ public class InteractionVendingMachine extends HabboItem {
}
- @Override
- public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
-
- }
-
- @Override
- public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
-
- }
-
@Override
public void run() {
super.run();
@@ -151,13 +161,14 @@ public class InteractionVendingMachine extends HabboItem {
}
}
+ @Override
+ public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
+ return true;
+ }
@Override
- public void serializeExtradata(ServerMessage serverMessage) {
- serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
-
- super.serializeExtradata(serverMessage);
+ public boolean isWalkable() {
+ return this.getBaseItem().allowWalk();
}
@Override
@@ -165,44 +176,12 @@ public class InteractionVendingMachine extends HabboItem {
return true;
}
- private void rotateToMachine(RoomUnit unit) {
+ private void rotateToMachine(Room room, RoomUnit unit) {
RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
- boolean onlyHead = false;
- switch (unit.getBodyRotation()) {
- case NORTH_EAST:
- if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST))
- onlyHead = true;
- break;
-
- case NORTH_WEST:
- if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST))
- onlyHead = true;
- break;
-
- case SOUTH_EAST:
- if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST))
- onlyHead = true;
- break;
-
- case SOUTH_WEST:
- if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST))
- onlyHead = true;
- break;
- }
-
- if (onlyHead) {
- unit.setHeadRotation(rotation);
- } else {
+ if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) {
unit.setRotation(rotation);
+ unit.statusUpdate(true);
}
}
-
- public void giveVendingMachineItem(Habbo habbo, Room room) {
- Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
- }
-
- public RoomTile getRequiredTile(Habbo habbo, Room room) {
- return getSquareInFront(room.getLayout(), this);
- }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
index 9af96347..d697ee4a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
@@ -1,43 +1,48 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.pets.Pet;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
-import gnu.trove.list.array.TIntArrayList;
-import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
+import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class InteractionWater extends InteractionDefault {
+
+ private static final String DEEP_WATER_NAME = "bw_water_2";
+
+ private final boolean isDeepWater;
+ private boolean isInRoom;
+
public InteractionWater(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
+ this.isDeepWater = baseItem.getName().equalsIgnoreCase(DEEP_WATER_NAME);
+ this.isInRoom = this.getRoomId() != 0;
}
public InteractionWater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
+ this.isDeepWater = false;
+ this.isInRoom = this.getRoomId() != 0;
}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
super.onMove(room, oldLocation, newLocation);
-
- this.recalculate(room);
+ this.updateWaters(room, oldLocation);
}
@Override
public void onPickUp(Room room) {
- this.recalculate(room);
+ this.isInRoom = false;
+ this.updateWaters(room, null);
Object[] empty = new Object[]{};
for (Habbo habbo : room.getHabbosOnItem(this)) {
@@ -58,91 +63,11 @@ public class InteractionWater extends InteractionDefault {
@Override
public void onPlace(Room room) {
- this.recalculate(room);
+ this.isInRoom = true;
+ this.updateWaters(room, null);
super.onPlace(room);
}
- public void refreshWaters(Room room) {
- if (room == null) {
- room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- }
-
- int _1 = 0;
- int _2 = 0;
- int _3 = 0;
- int _4 = 0;
- int _5 = 0;
- int _6 = 0;
- int _7 = 0;
- int _8 = 0;
- int _9 = 0;
- int _10 = 0;
- int _11 = 0;
- int _12 = 0;
-
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
- ((InteractionWaterItem) item).update();
- }
-
- if (!this.getBaseItem().getName().equalsIgnoreCase("bw_water_2")) {
- if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() - 1))
- _1 = 1;
- if (room.waterTiles.containsKey(this.getX()) && room.waterTiles.get(this.getX()).contains(this.getY() - 1))
- _2 = 1;
- if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() - 1))
- _3 = 1;
- if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() - 1))
- _4 = 1;
- if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY()))
- _5 = 1;
- if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY()))
- _6 = 1;
- if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 1))
- _7 = 1;
- if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 1))
- _8 = 1;
- if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 2))
- _9 = 1;
- if (room.waterTiles.containsKey(this.getX()) && room.waterTiles.get(this.getX()).contains(this.getY() + 2))
- _10 = 1;
- if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() + 2))
- _11 = 1;
- if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 2))
- _12 = 1;
- }
-
- //if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1;
- if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1;
- if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1;
- //if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1;
- if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1;
- if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1;
- if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1;
- if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1;
- //if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1;
- if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1;
- if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1;
- //if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1;
-
- int result = 0;
- result |= _1 << 11;
- result |= _2 << 10;
- result |= _3 << 9;
- result |= _4 << 8;
- result |= _5 << 7;
- result |= _6 << 6;
- result |= _7 << 5;
- result |= _8 << 4;
- result |= _9 << 3;
- result |= _10 << 2;
- result |= _11 << 1;
- result |= _12;
-
- this.setExtradata(result + "");
- this.needsUpdate(true);
- room.updateItem(this);
- }
-
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
@@ -169,28 +94,6 @@ public class InteractionWater extends InteractionDefault {
pet.getRoomUnit().removeStatus(RoomUnitStatus.SWIM);
}
- private void recalculate(Room room) {
- THashMap tiles = new THashMap<>();
-
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) {
- for (short i = 0; i < item.getBaseItem().getLength(); i++) {
- for (short j = 0; j < item.getBaseItem().getWidth(); j++) {
- if (!tiles.containsKey((short) (item.getX() + i))) {
- tiles.put((short) (item.getX() + i), new TIntArrayList());
- }
-
- tiles.get((short) (item.getX() + i)).add(item.getY() + j);
- }
- }
- }
-
- room.waterTiles = tiles;
-
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) {
- ((InteractionWater) item).refreshWaters(room);
- }
- }
-
@Override
public boolean allowWiredResetState() {
return false;
@@ -222,4 +125,174 @@ public class InteractionWater extends InteractionDefault {
return pet == null || pet.getPetData().canSwim;
}
+
+ private void updateWaters(Room room, RoomTile oldLocation) {
+ // Update ourself.
+ this.updateWater(room);
+
+ // Find targets containing furni to update.
+ Rectangle target = this.getRectangle(1, 1);
+ Rectangle targetOld = null;
+
+ if (oldLocation != null) {
+ targetOld = RoomLayout.getRectangle(
+ oldLocation.x - 1,
+ oldLocation.y - 1,
+ this.getBaseItem().getWidth() + 2,
+ this.getBaseItem().getLength() + 2,
+ this.getRotation());
+ }
+
+ // Update neighbouring water.
+ for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) {
+ // We already updated ourself.
+ if (item == this) {
+ continue;
+ }
+
+ // Check if found water furni is touching or intersecting our water furni.
+ // Check the same for the old location
+ Rectangle itemRectangle = item.getRectangle();
+
+ if (target.intersects(itemRectangle) || (targetOld != null && targetOld.intersects(itemRectangle))) {
+ ((InteractionWater) item).updateWater(room);
+ }
+ }
+
+ // Update water items we might have missed in the old location.
+ if (targetOld != null) {
+ for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
+ if (targetOld.intersects(item.getRectangle())) {
+ ((InteractionWaterItem) item).update();
+ }
+ }
+ }
+ }
+
+ private void updateWater(Room room) {
+ Rectangle target = this.getRectangle();
+
+ // Only update water item furnis that are intersecting with us.
+ for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
+ if (target.intersects(item.getRectangle())) {
+ ((InteractionWaterItem) item).update();
+ }
+ }
+
+ // Prepare bits for cutting off water.
+ byte _1 = 0;
+ byte _2 = 0;
+ byte _3 = 0;
+ byte _4 = 0;
+ byte _5 = 0;
+ byte _6 = 0;
+ byte _7 = 0;
+ byte _8 = 0;
+ byte _9 = 0;
+ byte _10 = 0;
+ byte _11 = 0;
+ byte _12 = 0;
+
+ // Check if we are touching a water tile.
+ if (this.isValidForMask(room, this.getX() - 1, this.getY() - 1, this.getZ(), true)) {
+ _1 = 1;
+ }
+ if (this.isValidForMask(room, this.getX(), this.getY() - 1, this.getZ())) {
+ _2 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 1, this.getY() - 1, this.getZ())) {
+ _3 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 2, this.getY() - 1, this.getZ(), true)) {
+ _4 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() - 1, this.getY(), this.getZ())) {
+ _5 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 2, this.getY(), this.getZ())) {
+ _6 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() - 1, this.getY() + 1, this.getZ())) {
+ _7 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 2, this.getY() + 1, this.getZ())) {
+ _8 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() - 1, this.getY() + 2, this.getZ(), true)) {
+ _9 = 1;
+ }
+ if (this.isValidForMask(room, this.getX(), this.getY() + 2, this.getZ())) {
+ _10 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 1, this.getY() + 2, this.getZ())) {
+ _11 = 1;
+ }
+ if (this.isValidForMask(room, this.getX() + 2, this.getY() + 2, this.getZ(), true)) {
+ _12 = 1;
+ }
+
+ // Check if we are touching invalid tiles.
+ // if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1;
+ if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1;
+ if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1;
+ // if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1;
+ if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1;
+ if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1;
+ if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1;
+ if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1;
+ // if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1;
+ if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1;
+ if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1;
+ // if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1;
+
+ // Update water.
+ int result = (_1 << 11)
+ | (_2 << 10)
+ | (_3 << 9)
+ | (_4 << 8)
+ | (_5 << 7)
+ | (_6 << 6)
+ | (_7 << 5)
+ | (_8 << 4)
+ | (_9 << 3)
+ | (_10 << 2)
+ | (_11 << 1)
+ | _12;
+
+ String updatedData = String.valueOf(result);
+
+ if (!this.getExtradata().equals(updatedData)) {
+ this.setExtradata(updatedData);
+ this.needsUpdate(true);
+ room.updateItem(this);
+ }
+ }
+
+ private boolean isValidForMask(Room room, int x, int y, double z) {
+ return this.isValidForMask(room, x, y, z, false);
+ }
+
+ private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) {
+ for (HabboItem item : room.getItemsAt(x, y, z)) {
+ if (item instanceof InteractionWater) {
+ InteractionWater water = (InteractionWater) item;
+
+ // Take out picked up water from the recalculation.
+ if (!water.isInRoom) {
+ continue;
+ }
+
+ // Allow:
+ // - masking if both are deepwater or both not.
+ // - corners too because otherwise causes ugly clipping issues.
+ // This allows deepwater and normal water to look nice.
+ if (corner && !this.isDeepWater || water.isDeepWater == this.isDeepWater) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
index a9840636..0332c717 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
@@ -42,12 +42,15 @@ public class InteractionWaterItem extends InteractionDefault {
public void update() {
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null)
+ if (room == null) {
return;
+ }
- Rectangle rectangle = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
+ Rectangle rectangle = this.getRectangle();
+ // Check if every tile of the furni is in water.
boolean foundWater = true;
+
for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) {
for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) {
boolean tile = false;
@@ -66,16 +69,14 @@ public class InteractionWaterItem extends InteractionDefault {
}
}
- if (foundWater) {
- this.setExtradata("1");
+ // Update data if changed.
+ String updatedData = foundWater ? "1" : "0";
+
+ if (!this.getExtradata().equals(updatedData)) {
+ this.setExtradata(updatedData);
this.needsUpdate(true);
room.updateItem(this);
- return;
}
-
- this.setExtradata("0");
- this.needsUpdate(true);
- room.updateItem(this);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
index cede4c8d..a465367c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
@@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -14,6 +16,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public abstract class InteractionWired extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
private long cooldown;
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
@@ -71,7 +74,7 @@ public abstract class InteractionWired extends HabboItem {
statement.setInt(2, this.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
super.run();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
index 054ce7d8..9708c565 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
@@ -3,19 +3,23 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow;
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType;
import com.eu.habbo.messages.ServerMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class InteractionWiredHighscore extends HabboItem {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWiredHighscore.class);
+
public WiredHighscoreScoreType scoreType;
public WiredHighscoreClearType clearType;
@@ -33,7 +37,7 @@ public class InteractionWiredHighscore extends HabboItem {
this.scoreType = WiredHighscoreScoreType.valueOf(name);
this.clearType = WiredHighscoreClearType.values()[ctype];
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
this.reloadData();
@@ -51,7 +55,7 @@ public class InteractionWiredHighscore extends HabboItem {
this.scoreType = WiredHighscoreScoreType.valueOf(name);
this.clearType = WiredHighscoreClearType.values()[ctype];
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
this.reloadData();
@@ -83,7 +87,7 @@ public class InteractionWiredHighscore extends HabboItem {
this.setExtradata(Math.abs(state - 1) + "");
room.updateItem(this);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
index 6c0ff65e..6197b017 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
@@ -13,12 +13,16 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
public class InteractionGameTimer extends HabboItem implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InteractionGameTimer.class);
+
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 };
private int baseTime = 0;
@@ -89,7 +93,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
}
}).toArray();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -117,7 +121,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
room.addGame(game);
game.initialise();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
index 5c28cda7..67436d2a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
@@ -124,7 +124,10 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
@Override
public boolean validMove(Room room, RoomTile from, RoomTile to) {
- return room != null && from != null && to != null;
+ if (to == null) return false;
+ HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
+ return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
+
//return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
index 482a3d96..9c81282d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
@@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions.games.football;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.games.football.FootballGame;
import com.eu.habbo.habbohotel.items.Item;
@@ -34,12 +35,18 @@ public class InteractionFootball extends InteractionPushable {
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2)
return 0;
- return 6;
+ if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 1)
+ return 6;
+
+ return 1;
}
@Override
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
- return 6;
+ if (roomUnit.getPath().size() == 0)
+ return 6;
+
+ return 1;
}
@Override
@@ -79,8 +86,17 @@ public class InteractionFootball extends InteractionPushable {
@Override
public int getNextRollDelay(int currentStep, int totalSteps) {
- int t = 2500;
- return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);
+
+ if(totalSteps > 4) {
+ if(currentStep <= 4) {
+ return 125;
+ }
+ }
+
+ return 500;
+
+ /*int t = 2500;
+ return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);*/
}
@Override
@@ -176,8 +192,11 @@ public class InteractionFootball extends InteractionPushable {
game.onScore(kicker, color);
}
- this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
+ this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + "");
room.sendComposer(new ItemStateComposer(this).compose());
+
+ /*this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
+ room.sendComposer(new ItemStateComposer(this).compose());*/
}
@Override
@@ -194,7 +213,7 @@ public class InteractionFootball extends InteractionPushable {
@Override
public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
HabboItem topItem = room.getTopItemAt(from.x, from.y, this);
- return !(room.hasHabbosAt(to.x, to.y) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
+ return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.x, to.y)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
index 8bbe249c..cbd2ea22 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
@@ -30,6 +30,18 @@ public class InteractionMonsterPlantSeed extends HabboItem {
}
}
+ public static int randomGoldenRarityLevel() {
+ int number = Emulator.getRandom().nextInt(66);
+ int count = 0;
+ for (int i = 8; i < 11; i++) {
+ count += 11 - i;
+ if (number <= count) {
+ return i;
+ }
+ }
+ return 10;
+ }
+
public static int randomRarityLevel() {
int number = Emulator.getRandom().nextInt(66);
int count = 0;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
index 16d219a9..9ec50ff9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
@@ -150,24 +150,21 @@ public class InteractionPetBreedingNest extends HabboItem {
HabboItem box = this;
Pet petOne = this.petOne;
Pet petTwo = this.petTwo;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient());
+ Emulator.getThreading().run(() -> {
+ Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient());
- //habbo.getClient().sendResponse(new PetPackageNameValidationComposer(box.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
- habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ(), box.getRotation());
- offspring.needsUpdate = true;
- offspring.run();
- InteractionPetBreedingNest.this.freePets();
- habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box);
- habbo.getClient().sendResponse(new PetBreedingCompleted(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring)));
+ //habbo.getClient().sendResponse(new PetPackageNameValidationComposer(box.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
+ habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ(), box.getRotation());
+ offspring.needsUpdate = true;
+ offspring.run();
+ InteractionPetBreedingNest.this.freePets();
+ habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box);
+ habbo.getClient().sendResponse(new PetBreedingCompleted(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring)));
- if (box.getBaseItem().getName().startsWith("pet_breeding_")) {
- String boxType = box.getBaseItem().getName().replace("pet_breeding_", "");
- String achievement = boxType.substring(0, 1).toUpperCase() + boxType.substring(1) + "Breeder";
- AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement));
- }
+ if (box.getBaseItem().getName().startsWith("pet_breeding_")) {
+ String boxType = box.getBaseItem().getName().replace("pet_breeding_", "");
+ String achievement = boxType.substring(0, 1).toUpperCase() + boxType.substring(1) + "Breeder";
+ AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement));
}
}, 2000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
index 680bae5a..caeaf54f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
@@ -45,14 +45,11 @@ public class InteractionPetToy extends InteractionDefault {
pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, "0");
pet.packetUpdate = true;
HabboItem item = this;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- pet.addHappyness(25);
- item.setExtradata("0");
- room.updateItem(item);
- new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
- }
+ Emulator.getThreading().run(() -> {
+ pet.addHappyness(25);
+ item.setExtradata("0");
+ room.updateItem(item);
+ new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
}, 2500 + (Emulator.getRandom().nextInt(20) * 500));
this.setExtradata("1");
room.updateItemState(this);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java
deleted file mode 100644
index f65b7dfc..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionBattleBanzaiGameActive.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.games.Game;
-import com.eu.habbo.habbohotel.games.GameState;
-import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionBattleBanzaiGameActive extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP;
-
- public WiredConditionBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Game game = room.getGame(BattleBanzaiGame.class);
-
- return game != null && game.state.equals(GameState.RUNNING);
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java
deleted file mode 100644
index 62009610..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFreezeGameActive.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.games.Game;
-import com.eu.habbo.habbohotel.games.GameState;
-import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionFreezeGameActive extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP;
-
- public WiredConditionFreezeGameActive(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Game game = room.getGame(FreezeGame.class);
-
- return game != null && game.state.equals(GameState.RUNNING);
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
index ba2b2bf7..4aa50beb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
@@ -137,8 +137,6 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
int count;
packet.readInt();
@@ -147,6 +145,9 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
packet.readString();
count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java
index 304eded6..4895462e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java
@@ -154,14 +154,15 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
int count;
packet.readInt();
packet.readString();
count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
index 06e3cbaa..d2a2f573 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
@@ -104,12 +104,13 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
packet.readInt();
packet.readString();
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java
deleted file mode 100644
index 78e52e31..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasCredits.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboHasCredits extends WiredConditionHabboHasEffect {
- public WiredConditionHabboHasCredits(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getCredits() >= this.effectId;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java
deleted file mode 100644
index 41103b76..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDiamonds.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboHasDiamonds extends WiredConditionHabboHasEffect {
- public WiredConditionHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getCurrencyAmount(5) >= this.effectId;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java
deleted file mode 100644
index f6f7b66f..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasDuckets.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboHasDuckets extends WiredConditionHabboHasEffect {
- public WiredConditionHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getPixels() >= this.effectId;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java
index ecaf88c1..e47107c3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java
@@ -1,6 +1,5 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room;
@@ -8,11 +7,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredConditionHabboHasHandItem.class);
+
public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM;
private int handItem;
@@ -71,7 +74,7 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
try {
this.handItem = Integer.valueOf(set.getString("wired_data"));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java
deleted file mode 100644
index ecf2bc01..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasRank.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge {
- public WiredConditionHabboHasRank(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- try {
- return habbo.getHabboInfo().getRank().getId() == Integer.valueOf(this.badge);
- } catch (Exception e) {
- return false;
- }
- }
-
- return false;
- }
-
- @Override
- public WiredConditionOperator operator() {
- return WiredConditionOperator.OR;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java
deleted file mode 100644
index 0c706e6e..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboIsDancing.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.DanceType;
-import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboIsDancing extends WiredConditionGroupMember {
- public WiredConditionHabboIsDancing(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return roomUnit != null && roomUnit.getDanceType() != DanceType.NONE;
- }
-
- @Override
- public WiredConditionOperator operator() {
- return WiredConditionOperator.OR;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java
deleted file mode 100644
index 8364e356..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboNotRank.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge {
- public WiredConditionHabboNotRank(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboNotRank(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- try {
- return habbo.getHabboInfo().getRank().getId() != Integer.valueOf(this.badge);
- } catch (Exception e) {
- return false;
- }
- }
-
- return false;
- }
-
- @Override
- public WiredConditionOperator operator() {
- return WiredConditionOperator.OR;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java
deleted file mode 100644
index bd7e192a..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboOwnsBadge.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboOwnsBadge extends WiredConditionHabboWearsBadge {
- public WiredConditionHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getInventory().getBadgesComponent().hasBadge(this.badge);
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
index 73371bab..27f1ed0e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
@@ -67,8 +67,6 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
@Override
public boolean saveData(ClientMessage packet) {
- this.settings.clear();
-
int count;
packet.readInt();
@@ -84,6 +82,9 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
return true;
count = packet.readInt();
+ 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();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java
deleted file mode 100644
index 26bd7e9e..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMottoContains.java
+++ /dev/null
@@ -1,84 +0,0 @@
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-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.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionMottoContains extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_BADGE;
-
- private String motto = "";
-
- public WiredConditionMottoContains(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionMottoContains(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- return habbo != null && habbo.getHabboInfo().getMotto().contains(this.motto);
- }
-
- @Override
- public String getWiredData() {
- return this.motto;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.motto = set.getString("wired_data");
- }
-
- @Override
- public void onPickUp() {
- this.motto = "";
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.motto);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- packet.readInt();
-
- this.motto = packet.readString();
-
- return true;
- }
-
- @Override
- public WiredConditionOperator operator() {
- return WiredConditionOperator.OR;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java
deleted file mode 100644
index 06e1c102..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotBattleBanzaiGameActive.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.games.Game;
-import com.eu.habbo.habbohotel.games.GameState;
-import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotBattleBanzaiGameActive extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP;
-
- public WiredConditionNotBattleBanzaiGameActive(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotBattleBanzaiGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Game game = room.getGame(BattleBanzaiGame.class);
-
- return game == null || !game.state.equals(GameState.RUNNING);
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java
deleted file mode 100644
index 043a5dbd..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFreezeGameActive.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.games.Game;
-import com.eu.habbo.habbohotel.games.GameState;
-import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotFreezeGameActive extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP;
-
- public WiredConditionNotFreezeGameActive(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotFreezeGameActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Game game = room.getGame(FreezeGame.class);
-
- return game == null || !game.state.equals(GameState.RUNNING);
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
index c64fb8b5..7e666b33 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
@@ -123,16 +123,16 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
- int count;
packet.readInt();
this.all = packet.readInt() == 1;
packet.readString();
- count = packet.readInt();
+ int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java
index ef61c69c..abc5c559 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java
@@ -154,14 +154,14 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
- int count;
packet.readInt();
packet.readString();
- count = packet.readInt();
+ int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
index 95b5d8e3..754aed77 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
@@ -103,12 +103,13 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
packet.readInt();
packet.readString();
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java
deleted file mode 100644
index 6c322788..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasCredits.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboHasCredits extends WiredConditionNotHabboHasEffect {
- public WiredConditionNotHabboHasCredits(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboHasCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getCredits() < this.effectId;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java
deleted file mode 100644
index ea96650f..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDiamonds.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboHasDiamonds extends WiredConditionNotHabboHasEffect {
- public WiredConditionNotHabboHasDiamonds(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboHasDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getCurrencyAmount(5) < this.effectId;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java
deleted file mode 100644
index 98e55738..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasDuckets.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboHasDuckets extends WiredConditionNotHabboHasEffect {
- public WiredConditionNotHabboHasDuckets(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboHasDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboInfo().getPixels() < this.effectId;
- }
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java
deleted file mode 100644
index 81f1d7f2..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboIsDancing.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.DanceType;
-import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboIsDancing extends WiredConditionGroupMember {
- public WiredConditionNotHabboIsDancing(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboIsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return roomUnit != null && roomUnit.getDanceType() == DanceType.NONE;
- }
-
- @Override
- public WiredConditionOperator operator() {
- return WiredConditionOperator.OR;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java
deleted file mode 100644
index 91cb8d81..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboOwnsBadge.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboOwnsBadge extends WiredConditionNotHabboWearsBadge {
- public WiredConditionNotHabboOwnsBadge(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboOwnsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return !habbo.getInventory().getBadgesComponent().hasBadge(this.badge);
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
index 2f0dc9d4..698cd2c3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
@@ -142,9 +142,6 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
@Override
public boolean saveData(ClientMessage packet) {
- this.settings.clear();
-
- int count;
packet.readInt();
this.state = packet.readInt() == 1;
@@ -158,7 +155,10 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
if (room == null)
return true;
- count = packet.readInt();
+ int count = packet.readInt();
+ 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();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
index eb853f9c..65dc97f1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
@@ -105,12 +105,13 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
packet.readInt();
packet.readString();
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
index 5cb27d1c..9d373e56 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
@@ -108,12 +108,13 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
@Override
public boolean saveData(ClientMessage packet) {
- this.items.clear();
-
packet.readInt();
packet.readString();
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
index c49ff4a5..ec22bf63 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
@@ -68,10 +68,14 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
List bots = room.getBots(this.botName);
- for (Bot bot : bots) {
- bot.setFigure(this.botLook);
+
+ if (bots.size() != 1) {
+ return false;
}
+ Bot bot = bots.get(0);
+ bot.setFigure(this.botLook);
+
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java
index e7aab43c..928068af 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java
@@ -86,13 +86,15 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
- if (habbo != null) {
- List bots = room.getBots(this.botName);
- for (Bot bot : bots) {
- if (this.mode == 1)
- bot.startFollowingHabbo(habbo);
- else
- bot.stopFollowingHabbo();
+ List bots = room.getBots(this.botName);
+
+ if (habbo != null && bots.size() == 1) {
+ Bot bot = bots.get(0);
+
+ if (this.mode == 1) {
+ bot.startFollowingHabbo(habbo);
+ } else {
+ bot.stopFollowingHabbo();
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
index 918f12fb..94173cdd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
@@ -88,22 +88,21 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
Habbo habbo = room.getHabbo(roomUnit);
+ List bots = room.getBots(this.botName);
- if (habbo != null) {
- List bots = room.getBots(this.botName);
+ if (habbo != null && bots.size() == 1) {
+ Bot bot = bots.get(0);
- for (Bot bot : bots) {
- List tasks = new ArrayList<>();
- tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
- tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
+ List tasks = new ArrayList<>();
+ tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
+ tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
- Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
- List failedReach = new ArrayList<>();
- failedReach.add(() -> tasks.forEach(Runnable::run));
+ List failedReach = new ArrayList<>();
+ failedReach.add(() -> tasks.forEach(Runnable::run));
- Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
- }
+ Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
index 96815685..8297cde1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
@@ -57,6 +57,8 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
if (data.length == 2) {
this.botName = data[0];
+
+ if (data[1].length() > 64) return false;
this.message = data[1];
}
@@ -83,14 +85,21 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
.replace(Emulator.getTexts().getValue("wired.variable.pixels"), habbo.getHabboInfo().getPixels() + "")
.replace(Emulator.getTexts().getValue("wired.variable.points"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "");
}
+
List bots = room.getBots(this.botName);
- for (Bot bot : bots) {
- if (this.mode == 1)
- bot.shout(message);
- else
- bot.talk(message);
+ if (bots.size() != 1) {
+ return false;
}
+
+ Bot bot = bots.get(0);
+
+ if (this.mode == 1) {
+ bot.shout(message);
+ } else {
+ bot.talk(message);
+ }
+
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java
index 82f8ad59..97badb10 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java
@@ -77,6 +77,8 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
if (data.length == 2) {
this.botName = data[0];
+
+ if (data[1].length() > 64) return false;
this.message = data[1];
}
@@ -104,16 +106,21 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
List bots = room.getBots(this.botName);
- for (Bot bot : bots) {
- if (this.mode == 1) {
- bot.whisper(m, habbo);
- } else {
- bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
- }
+ if (bots.size() != 1) {
+ return false;
+ }
+
+ Bot bot = bots.get(0);
+
+ if (this.mode == 1) {
+ bot.whisper(m, habbo);
+ } else {
+ bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
}
return true;
}
+
return false;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
index 487b88f6..9fe3e8ef 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
@@ -6,18 +6,22 @@ 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.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
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.outgoing.rooms.users.RoomUserEffectComposer;
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collections;
import java.util.List;
public class WiredEffectBotTeleport extends InteractionWiredEffect {
@@ -36,6 +40,46 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
this.items = new THashSet<>();
}
+ public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
+ if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
+ return;
+
+ Room room = roomUnit.getRoom();
+
+ if (room == null) {
+ return;
+ }
+
+ // makes a temporary effect
+
+ roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
+ room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
+ Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);
+
+ if (tile == roomUnit.getCurrentLocation()) {
+ return;
+ }
+
+ if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) {
+ RoomTile alternativeTile = null;
+ List optionalTiles = room.getLayout().getTilesAround(tile);
+
+ Collections.reverse(optionalTiles);
+ for (RoomTile optionalTile : optionalTiles) {
+ if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) {
+ alternativeTile = optionalTile;
+ break;
+ }
+ }
+
+ if (alternativeTile != null) {
+ tile = alternativeTile;
+ }
+ }
+
+ Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
+ }
+
@Override
public void serializeWiredData(ServerMessage message, Room room) {
THashSet items = new THashSet<>();
@@ -70,9 +114,10 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
packet.readInt();
this.botName = packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
@@ -95,24 +140,22 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
List bots = room.getBots(this.botName);
- if (bots.isEmpty())
+ if (bots.size() != 1) {
return false;
+ }
- for (Bot bot : bots) {
- int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
- int j = 1;
- for (HabboItem item : this.items) {
- if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
- if (i == j) {
- int currentEffect = bot.getRoomUnit().getEffectId();
+ Bot bot = bots.get(0);
- room.giveEffect(bot.getRoomUnit(), 4, -1);
- Emulator.getThreading().run(() -> room.giveEffect(bot.getRoomUnit(), 0, -1), WiredHandler.TELEPORT_DELAY + 1000);
- Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? -0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
- break;
- } else {
- j++;
- }
+ int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
+ int j = 1;
+
+ for (HabboItem item : this.items) {
+ if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
+ if (i == j) {
+ teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY()));
+ return true;
+ } else {
+ j++;
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
index a5f5a0c0..3b5543b7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
@@ -68,9 +68,10 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
packet.readInt();
this.botName = packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
@@ -88,14 +89,13 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (this.items.isEmpty())
- return false;
-
List bots = room.getBots(this.botName);
- if (bots.isEmpty())
+ if (this.items.isEmpty() || bots.size() != 1) {
return false;
+ }
+ Bot bot = bots.get(0);
THashSet items = new THashSet<>();
for (HabboItem item : this.items) {
@@ -108,17 +108,15 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
}
if (this.items.size() > 0) {
- for (Bot bot : bots) {
- int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
- int j = 1;
- for (HabboItem item : this.items) {
- if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
- if (i == j) {
- bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
- break;
- } else {
- j++;
- }
+ int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
+ int j = 1;
+ for (HabboItem item : this.items) {
+ if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
+ if (i == j) {
+ bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
+ break;
+ } else {
+ j++;
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
index c41094e9..7ac99dae 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
@@ -72,12 +72,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
boolean hasHabbos = false;
for (Habbo habbo : room.getHabbosAt(targetTile)) {
hasHabbos = true;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{entry.getKey()});
- }
- });
+ Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{entry.getKey()}));
}
if (!hasHabbos) {
@@ -167,14 +162,17 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
- this.items.clear();
packet.readInt();
this.startRotation = RoomUserRotation.fromValue(packet.readInt());
this.rotateAction = packet.readInt();
packet.readString();
- int furniCount = packet.readInt();
- for (int i = 0; i < furniCount; i++) {
+ int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
+
+ for (int i = 0; i < count; i++) {
HabboItem item = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(packet.readInt());
if (item != null) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java
deleted file mode 100644
index a1c216e3..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectForwardToRoom.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredEffectForwardToRoom extends WiredEffectWhisper {
- public WiredEffectForwardToRoom(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectForwardToRoom(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null)
- return false;
-
- int roomId;
-
- try {
- roomId = Integer.valueOf(this.message);
- } catch (Exception e) {
- return false;
- }
-
- if (roomId > 0)
- habbo.getClient().sendResponse(new ForwardToRoomComposer(roomId));
-
- return true;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java
deleted file mode 100644
index 1a45f426..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveAchievement.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.achievements.Achievement;
-import com.eu.habbo.habbohotel.achievements.AchievementManager;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectGiveAchievement extends WiredEffectGiveBadge {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- public static final String DEFAULT_CONTENT = "ach_achievement:points <- Points are optional";
- private String achievement = DEFAULT_CONTENT;
-
- public WiredEffectGiveAchievement(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectGiveAchievement(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(true);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.achievement + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- try {
- this.achievement = packet.readString();
-
- int points = 1;
- String a = achievement;
- if (a.contains(":")) {
- a = achievement.split(":")[0];
- try {
- points = Integer.valueOf(achievement.split(":")[1]);
- } catch (Exception e) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.points"), RoomChatMessageBubbles.WIRED);
- }
- }
-
- Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a);
-
- if (ach == null) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.achievement").replace("%achievement%", a), RoomChatMessageBubbles.WIRED);
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
-
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (!this.achievement.equals(DEFAULT_CONTENT)) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- int points = 1;
- String a = achievement;
- if (a.contains(":")) {
- a = achievement.split(":")[0];
- try {
- points = Integer.valueOf(achievement.split(":")[1]);
- } catch (Exception e) {
- return false;
- }
- }
-
- Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a);
-
- if (ach != null) {
- AchievementManager.progressAchievement(habbo, ach, points);
- }
- }
- }
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.achievement;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
- this.achievement = DEFAULT_CONTENT;
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
-
- this.achievement = data[1];
- }
- }
-
- @Override
- public void onPickUp() {
- this.achievement = DEFAULT_CONTENT;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java
deleted file mode 100644
index 1f071383..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveBadge.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
-import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectGiveBadge extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- private String badge = "";
-
- public WiredEffectGiveBadge(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectGiveBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.badge);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- this.badge = packet.readString();
-
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null)
- return false;
-
- if (this.badge.isEmpty())
- return false;
-
- if (habbo.getInventory().getBadgesComponent().hasBadge(this.badge)) {
- habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALREADY_RECEIVED));
- } else {
- BadgesComponent.createBadge(this.badge, habbo);
- habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_RECEIVED_BADGE));
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.badge;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
- this.badge = data[1];
- }
- }
-
- @Override
- public void onPickUp() {
- this.badge = "";
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-}
-
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java
deleted file mode 100644
index d072d671..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveCredits.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectGiveCredits extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- private int credits = 0;
-
- public WiredEffectGiveCredits(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectGiveCredits(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(true);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.credits + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- try {
- this.credits = Integer.valueOf(packet.readString());
- } catch (Exception e) {
- return false;
- }
-
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return false;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null)
- return false;
-
- habbo.giveCredits(this.credits);
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.credits;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
- this.credits = 0;
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
-
- try {
- this.credits = Integer.valueOf(data[1]);
- } catch (Exception e) {
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.credits = 0;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-}
-
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java
deleted file mode 100644
index dc15d8ac..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDiamonds.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.InteractionWiredTrigger;
-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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.users.UserPointsComposer;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectGiveDiamonds extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- private int points = 0;
- private int pointsType = -1;
-
- public WiredEffectGiveDiamonds(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectGiveDiamonds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.points + (this.pointsType == -1 ? "" : ":" + this.pointsType));
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- try {
- this.loadFromString(packet.readString());
- } catch (Exception e) {
- return false;
- }
-
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null)
- return false;
-
- habbo.getHabboInfo().addCurrencyAmount(this.pointsType == -1 ? Emulator.getConfig().getInt("seasonal.primary.type") : this.pointsType, this.points);
- habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(this.pointsType == -1 ? Emulator.getConfig().getInt("seasonal.primary.type") : this.pointsType), this.points, Emulator.getConfig().getInt("seasonal.primary.type")));
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.points + (this.pointsType == -1 ? "" : ":" + this.pointsType);
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
- this.points = 0;
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
-
- try {
- this.loadFromString(data[1]);
- } catch (Exception e) {
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.points = 0;
- this.setDelay(0);
- }
-
- private void loadFromString(String data) {
- String[] pointsData = data.split(":");
-
- this.pointsType = -1;
- if (pointsData.length >= 1) {
- this.points = Integer.valueOf(pointsData[0]);
- }
-
- if (pointsData.length == 2) {
- this.pointsType = Integer.valueOf(pointsData[1]);
- }
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java
deleted file mode 100644
index 21d82d19..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveDuckets.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.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.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.users.UserPointsComposer;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectGiveDuckets extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- private int pixels = 0;
-
- public WiredEffectGiveDuckets(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectGiveDuckets(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.pixels + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- try {
- this.pixels = Integer.valueOf(packet.readString());
- } catch (Exception e) {
- return false;
- }
-
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null)
- return false;
-
- habbo.getHabboInfo().addCurrencyAmount(0, this.pixels);
- habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(0), this.pixels, 0));
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.pixels;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
- this.pixels = 0;
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
-
- try {
- this.pixels = Integer.valueOf(data[1]);
- } catch (Exception e) {
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.pixels = 0;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-}
-
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java
index a5a8c947..e61973e9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveReward.java
+++ b/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.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@@ -116,7 +117,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (client.getHabbo().hasPermission("acc_superwired")) {
+ if (client.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
client.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.superwired.info"), RoomChatMessageBubbles.BOT);
}
}
@@ -165,7 +166,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
- if (gameClient.getHabbo().hasPermission("acc_superwired")) {
+ if (gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
packet.readInt();
this.rewardTime = packet.readInt();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java
deleted file mode 100644
index d2b53911..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectLowerFurni.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-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.outgoing.rooms.items.FloorItemOnRollerComposer;
-import gnu.trove.set.hash.THashSet;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredEffectLowerFurni extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.TELEPORT;
-
- private THashSet items = new THashSet<>();
-
- private int offset = 0;
-
- public WiredEffectLowerFurni(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectLowerFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(0);
- message.appendInt(this.offset);
- message.appendInt(0);
- message.appendString("");
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
- packet.readString();
-
- this.items.clear();
-
- int count = packet.readInt();
-
- for (int i = 0; i < count; i++) {
- this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
- }
-
- this.offset = packet.readInt();
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- for (HabboItem item : this.items) {
- if (item.getRoomId() == 0)
- continue;
-
- if (item.getZ() > 0) {
- double z = (0.1) * (double) this.offset;
- double minZ = room.getLayout().getHeightAtSquare(item.getX(), item.getY());
- if (z < minZ) {
- z = minZ;
- }
-
- room.sendComposer(new FloorItemOnRollerComposer(item, null, room.getLayout().getTile(item.getX(), item.getY()), -z, room).compose());
-
- room.updateHabbosAt(item.getX(), item.getY());
- }
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- StringBuilder wiredData = new StringBuilder(this.offset + "\t");
-
- if (this.items != null && !this.items.isEmpty()) {
- for (HabboItem item : this.items) {
- wiredData.append(item.getId()).append(";");
- }
- }
-
- return wiredData.toString();
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items = new THashSet<>();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.contains("\t")) {
- String[] data = wiredData.split("\t");
-
- try {
- this.offset = Integer.valueOf(data[0]);
- } catch (Exception e) {
- }
-
- if (data.length >= 2) {
- if (data[1].contains(";")) {
- for (String s : data[1].split(";")) {
- HabboItem item = room.getHabboItem(Integer.valueOf(s));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.offset = 0;
- this.items.clear();
- this.setDelay(0);
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
index b318a033..251bc2a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
@@ -17,11 +17,15 @@ import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredEffectMatchFurni extends InteractionWiredEffect {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMatchFurni.class);
+
private static final WiredEffectType type = WiredEffectType.MATCH_SSHOT;
public boolean checkForWiredResetPermission = true;
private THashSet settings;
@@ -85,11 +89,12 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
if (t != null && t.state != RoomTileState.INVALID) {
boolean canMove = true;
- if (t.x == item.getX() && t.y == item.getY()) {
+ if (t.x == item.getX() && t.y == item.getY() || room.hasHabbosAt(t.x, t.y)) {
canMove = !(room.getTopItemAt(t.x, t.y) == item);
slideAnimation = false;
}
+
if (canMove && !room.hasHabbosAt(t.x, t.y)) {
THashSet tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation);
double highestZ = -1d;
@@ -189,7 +194,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -239,11 +244,6 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
- this.settings.clear();
-
- //packet.readInt();
-
- int count;
packet.readInt();
this.state = packet.readInt() == 1;
@@ -257,7 +257,10 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
if (room == null)
return true;
- count = packet.readInt();
+ int count = packet.readInt();
+ 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();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java
deleted file mode 100644
index 495c15fe..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurniStaff.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.habbohotel.items.Item;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredEffectMatchFurniStaff extends WiredEffectMatchFurni {
- public WiredEffectMatchFurniStaff(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- this.checkForWiredResetPermission = false;
- }
-
- public WiredEffectMatchFurniStaff(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.checkForWiredResetPermission = false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java
index 83d32cda..23414d94 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniAway.java
@@ -58,12 +58,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
if (target != null) {
if (RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY())) {
final Habbo finalTarget = target;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- WiredHandler.handle(WiredTriggerType.COLLISION, finalTarget.getRoomUnit(), room, new Object[]{item});
- }
- }, 500);
+ Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, finalTarget.getRoomUnit(), room, new Object[]{item}), 500);
continue;
}
@@ -191,9 +186,10 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
packet.readInt();
packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java
index f1c4166d..95125c68 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTowards.java
@@ -107,6 +107,10 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
RoomLayout layout = room.getLayout();
boolean collided = false;
+ if (layout == null) {
+ break;
+ }
+
for (int i = 0; i < 3; i++) {
if (target != null)
break;
@@ -300,9 +304,10 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
packet.readInt();
packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
index ae37a0f3..06192a4e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveRotateFurni.java
@@ -17,6 +17,8 @@ import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.awt.*;
import java.sql.ResultSet;
@@ -24,6 +26,10 @@ import java.sql.SQLException;
import java.util.ArrayList;
public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
+
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectMoveRotateFurni.class);
+
public static final WiredEffectType type = WiredEffectType.MOVE_ROTATE;
private final THashSet items = new THashSet<>(WiredHandler.MAXIMUM_FURNI_SELECTION / 2);
private int direction;
@@ -40,7 +46,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
// remove items that are no longer in the room
- this.items.removeIf( item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
+ this.items.removeIf(item -> Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
THashSet tilesToUpdate = new THashSet<>(Math.min(this.items.size(), 10));
@@ -53,10 +59,9 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
//Verify if rotation result in a valid position
FurnitureMovementError rotateError = room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation);
if (item.getRotation() != newRotation && (rotateError.equals(FurnitureMovementError.TILE_HAS_HABBOS) || rotateError.equals(FurnitureMovementError.TILE_HAS_PETS) ||
- rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE)))
- {
+ rotateError.equals(FurnitureMovementError.TILE_HAS_BOTS) || rotateError.equals(FurnitureMovementError.NONE))) {
item.setRotation(newRotation);
- if(this.direction == 0) {
+ if (this.direction == 0) {
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
room.sendComposer(new FloorItemUpdateComposer(item).compose());
for (RoomTile t : tilesToUpdate) {
@@ -135,7 +140,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
}
if (validMove) {
- if(this.rotation > 0) {
+ if (this.rotation > 0) {
item.setX(newTile.x);
item.setY(newTile.y);
item.setZ(item.getZ() + offset);
@@ -144,8 +149,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
room.updateHabbosAt(t.x, t.y);
room.updateBotsAt(t.x, t.y);
}
- }
- else {
+ } else {
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose());
}
}
@@ -268,6 +272,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
packet.readString();
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false;
this.items.clear();
for (int i = 0; i < count; i++) {
@@ -282,6 +287,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
/**
* Returns a new rotation for an item based on the wired options
+ *
* @param item
* @return new rotation
*/
@@ -306,6 +312,7 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect {
/**
* Returns the direction of movement based on the wired settings
+ *
* @return direction
*/
private RoomUserRotation getMovementDirection() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java
deleted file mode 100644
index fe399daa..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectOpenHabboPages.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredEffectOpenHabboPages extends WiredEffectWhisper {
- public WiredEffectOpenHabboPages(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectOpenHabboPages(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- habbo.getClient().sendResponse(new NuxAlertComposer(this.message));
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java
deleted file mode 100644
index 76baea9d..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRaiseFurni.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-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.outgoing.rooms.items.FloorItemOnRollerComposer;
-import gnu.trove.set.hash.THashSet;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredEffectRaiseFurni extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.TELEPORT;
-
- private THashSet items = new THashSet<>();
-
- private int offset = 0;
-
- public WiredEffectRaiseFurni(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectRaiseFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(0);
- message.appendInt(this.offset);
- message.appendInt(0);
- message.appendString("");
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
- packet.readString();
-
- this.items.clear();
-
- int count = packet.readInt();
-
- for (int i = 0; i < count; i++) {
- this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
- }
-
- this.offset = packet.readInt();
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- for (HabboItem item : this.items) {
- if (item.getRoomId() == 0)
- continue;
-
- double offsetZ = (((0.1) * this.offset)) % 127;
- room.sendComposer(new FloorItemOnRollerComposer(item, null, room.getLayout().getTile(item.getX(), item.getY()), offsetZ, room).compose());
- room.updateHabbosAt(item.getX(), item.getY());
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- StringBuilder wiredData = new StringBuilder(this.offset + "\t");
-
- if (this.items != null && !this.items.isEmpty()) {
- for (HabboItem item : this.items) {
- wiredData.append(item.getId()).append(";");
- }
- }
-
- return wiredData.toString();
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items = new THashSet<>();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.contains("\t")) {
- String[] data = wiredData.split("\t");
-
- try {
- this.offset = Integer.valueOf(data[0]);
- } catch (Exception e) {
- }
-
- if (data.length >= 2) {
- if (data[1].contains(";")) {
- for (String s : data[1].split(";")) {
- HabboItem item = room.getHabboItem(Integer.valueOf(s));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.offset = 0;
- this.items.clear();
- this.setDelay(0);
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java
deleted file mode 100644
index fd089c22..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectRollerSpeed.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-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.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.ServerMessage;
-import gnu.trove.procedure.TObjectProcedure;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectRollerSpeed extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
-
- private int speed = 4;
-
- public WiredEffectRollerSpeed(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectRollerSpeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.speed + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- }
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(ClientMessage packet, GameClient gameClient) {
- packet.readInt();
-
- try {
- this.speed = Integer.valueOf(packet.readString());
- } catch (Exception e) {
- return false;
- }
- packet.readInt();
- this.setDelay(packet.readInt());
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- room.setRollerSpeed(this.speed);
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return this.getDelay() + "\t" + this.speed;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wireData = set.getString("wired_data");
- String[] data = wireData.split("\t");
- this.speed = 0;
-
- if (data.length >= 2) {
- super.setDelay(Integer.valueOf(data[0]));
-
- try {
- this.speed = Integer.valueOf(data[1]);
- } catch (Exception e) {
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.speed = 4;
- this.setDelay(0);
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
index 965ed802..652f3780 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
@@ -47,14 +47,20 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
Room room = roomUnit.getRoom();
- if (room == null)
+ if (room == null) {
return;
+ }
// makes a temporary effect
+
roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);
+ if (tile == roomUnit.getCurrentLocation()) {
+ return;
+ }
+
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) {
RoomTile alternativeTile = null;
List optionalTiles = room.getLayout().getTilesAround(tile);
@@ -125,9 +131,10 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
packet.readInt();
packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
@@ -146,6 +153,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
if (!this.items.isEmpty()) {
int i = Emulator.getRandom().nextInt(this.items.size());
HabboItem item = this.items.get(i);
+
teleportUnitToTile(roomUnit, room.getLayout().getTile(item.getX(), item.getY()));
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java
index 0e3232ed..d3025363 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleFurni.java
@@ -19,6 +19,8 @@ import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -26,6 +28,8 @@ import java.util.ArrayList;
import java.util.List;
public class WiredEffectToggleFurni extends InteractionWiredEffect {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleFurni.class);
+
public static final WiredEffectType type = WiredEffectType.TOGGLE_STATE;
private final THashSet items;
@@ -92,9 +96,10 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
packet.readInt();
packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
@@ -136,7 +141,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
item.onClick(habbo != null && !(item instanceof InteractionGameTimer) ? habbo.getClient() : null, room, new Object[]{state, this.getType()});
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java
index c570f378..98b41137 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectToggleRandom.java
@@ -17,6 +17,8 @@ import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -24,6 +26,8 @@ import java.util.ArrayList;
import java.util.List;
public class WiredEffectToggleRandom extends InteractionWiredEffect {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredEffectToggleRandom.class);
+
public static final WiredEffectType type = WiredEffectType.TOGGLE_RANDOM;
private final THashSet items = new THashSet<>();
@@ -120,7 +124,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
item.setExtradata(Emulator.getRandom().nextInt(item.getBaseItem().getStateCount() + 1) + "");
room.updateItem(item);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java
index 6016e7ab..d58b6a84 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTriggerStacks.java
@@ -87,9 +87,10 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
packet.readInt();
packet.readString();
- this.items.clear();
-
int count = packet.readInt();
+ if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
+
+ this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
@@ -102,7 +103,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (stuff != null && stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks) {
+
+ if (stuff == null || (stuff.length >= 1 && stuff[stuff.length - 1] instanceof WiredEffectTriggerStacks)) {
return false;
}
@@ -126,14 +128,14 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
}
}
}
+ Object[] newStuff = new Object[stuff.length + 1];
+ System.arraycopy(stuff, 0, newStuff, 0, stuff.length);
+ newStuff[newStuff.length - 1] = this;
+ WiredHandler.executeEffectsAtTiles(usedTiles, roomUnit, room, stuff);
- Object[] newStuff = new Object[stuff.length + 1];
- System.arraycopy(stuff, 0, newStuff, 0, stuff.length);
- newStuff[newStuff.length - 1] = this;
- WiredHandler.executeEffectsAtTiles(usedTiles, roomUnit, room, stuff);
+ return true;
+ }
- return true;
- }
@Override
public String getWiredData() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
index b46c81c9..0017efe8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/extra/WiredBlob.java
@@ -1,22 +1,24 @@
package com.eu.habbo.habbohotel.items.interactions.wired.extra;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameState;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
-import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredBlob extends InteractionDefault {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredBlob.class);
+
enum WiredBlobState {
ACTIVE("0"),
USED("1");
@@ -104,14 +106,14 @@ public class WiredBlob extends InteractionDefault {
String[] params = this.getBaseItem().getCustomParams().split(",");
if (params.length != 2) {
- Emulator.getLogging().logErrorLine("Wired blobs should have customparams with two parameters (points,resetsWithGame)");
+ LOGGER.error("Wired blobs should have customparams with two parameters (points,resetsWithGame)");
return;
}
try {
this.POINTS_REWARD = Integer.parseInt(params[0]);
} catch (NumberFormatException e) {
- Emulator.getLogging().logErrorLine("Wired blobs should have customparams with the first parameter being the amount of points (number)");
+ LOGGER.error("Wired blobs should have customparams with the first parameter being the amount of points (number)");
return;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java
index a40dd95a..73c543c3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerBotReachedFurni.java
@@ -14,6 +14,8 @@ import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -21,6 +23,8 @@ import java.util.ArrayList;
import java.util.List;
public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WiredTriggerBotReachedFurni.class);
+
public final static WiredTriggerType type = WiredTriggerType.BOT_REACHED_STF;
private THashSet items;
@@ -157,7 +161,7 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
if (item != null)
this.items.add(item);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java
deleted file mode 100644
index e1e96145..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboIdle.java
+++ /dev/null
@@ -1,76 +0,0 @@
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-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 java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredTriggerHabboIdle extends InteractionWiredTrigger {
- private static final WiredTriggerType type = WiredTriggerType.IDLES;
-
- public WiredTriggerHabboIdle(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredTriggerHabboIdle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return stuff.length > 0 && stuff[0] instanceof Habbo;
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-
- @Override
- public WiredTriggerType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean isTriggeredByRoomUnit() {
- return true;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java
deleted file mode 100644
index c0cc60d8..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboSaysCommand.java
+++ /dev/null
@@ -1,116 +0,0 @@
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger {
- private static final WiredTriggerType type = WiredTriggerType.SAY_COMMAND;
-
- private boolean ownerOnly = false;
- private String key = "";
-
- public WiredTriggerHabboSaysCommand(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredTriggerHabboSaysCommand(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- if (this.key.length() > 0) {
- if (stuff[0] instanceof String) {
- if (((String) stuff[0]).replace(":", "").startsWith(this.key + " ")) {
- if (this.ownerOnly && room.getOwnerId() != habbo.getHabboInfo().getId())
- return false;
-
- habbo.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(this.key, habbo, habbo, RoomChatMessageBubbles.ALERT)));
-
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public String getWiredData() {
- return (this.ownerOnly ? "1" : "0") + "\t" + this.key;
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String[] data = set.getString("wired_data").split("\t");
-
- if (data.length == 2) {
- this.ownerOnly = data[0].equalsIgnoreCase("1");
- this.setKey(data[1]);
- }
- }
-
- @Override
- public void onPickUp() {
- this.ownerOnly = false;
- this.key = "";
- }
-
- @Override
- public WiredTriggerType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.key);
- message.appendInt(0);
- message.appendInt(1);
- message.appendInt(this.getType().code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- packet.readInt();
- this.ownerOnly = packet.readInt() == 1;
- setKey(packet.readString());
-
-
- return true;
- }
-
- private void setKey(String key) {
- if (key.contains(":")) {
- key = key.replaceAll(":", "");
- }
-
- this.key = key;
- }
-
- @Override
- public boolean isTriggeredByRoomUnit() {
- return true;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java
deleted file mode 100644
index f3622f82..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStartsDancing.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredTriggerHabboStartsDancing extends WiredTriggerCollision {
- public WiredTriggerHabboStartsDancing(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredTriggerHabboStartsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredTriggerType getType() {
- return WiredTriggerType.STARTS_DANCING;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java
deleted file mode 100644
index cea8333c..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboStopsDancing.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredTriggerHabboStopsDancing extends WiredTriggerCollision {
- public WiredTriggerHabboStopsDancing(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredTriggerHabboStopsDancing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredTriggerType getType() {
- return WiredTriggerType.STOPS_DANCING;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java
deleted file mode 100644
index e058b1e3..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboUnidle.java
+++ /dev/null
@@ -1,76 +0,0 @@
-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.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-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 java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredTriggerHabboUnidle extends InteractionWiredTrigger {
- private static final WiredTriggerType type = WiredTriggerType.UNIDLES;
-
- public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredTriggerHabboUnidle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return stuff.length > 0 && stuff[0] instanceof Habbo;
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
-
- }
-
- @Override
- public void onPickUp() {
-
- }
-
- @Override
- public WiredTriggerType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(type.code);
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(ClientMessage packet) {
- return true;
- }
-
- @Override
- public boolean isTriggeredByRoomUnit() {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
index 8953c439..a081bfc5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
+++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
@@ -1,12 +1,16 @@
package com.eu.habbo.habbohotel.messenger;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Message implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Message.class);
+
private final int fromId;
private final int toId;
private final int timestamp;
@@ -31,7 +35,7 @@ public class Message implements Runnable {
statement.setInt(4, this.timestamp);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java
index 06d4e37d..59c6083a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java
+++ b/src/main/java/com/eu/habbo/habbohotel/messenger/Messenger.java
@@ -11,6 +11,8 @@ import com.eu.habbo.plugin.events.users.friends.UserAcceptFriendRequestEvent;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -20,6 +22,9 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Messenger {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Messenger.class);
+
//Configuration. Loaded from database & updated accordingly.
public static boolean SAVE_PRIVATE_CHATS = false;
public static int MAXIMUM_FRIENDS = 200;
@@ -41,7 +46,7 @@ public class Messenger {
statement.setInt(4, userOne);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -55,7 +60,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return users;
}
@@ -85,7 +90,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -102,7 +107,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -114,7 +119,7 @@ public class Messenger {
statement.setInt(2, userFrom);
statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -133,7 +138,7 @@ public class Messenger {
count = set.getInt("count");
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return count;
@@ -157,7 +162,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return map;
}
@@ -209,11 +214,17 @@ public class Messenger {
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
- this.friends.putIfAbsent(set.getInt("id"), new MessengerBuddy(set));
+ MessengerBuddy buddy = new MessengerBuddy(set);
+
+ if (buddy.getId() == habbo.getHabboInfo().getId()) {
+ continue;
+ }
+
+ this.friends.putIfAbsent(set.getInt("id"), buddy);
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -237,7 +248,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return buddy;
@@ -252,7 +263,7 @@ public class Messenger {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -311,7 +322,7 @@ public class Messenger {
statement.setInt(1, userTo);
statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -323,7 +334,7 @@ public class Messenger {
statement.setInt(3, userFrom);
return statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return 0;
@@ -345,7 +356,7 @@ public class Messenger {
statement.setInt(3, Emulator.getIntUnixTimestamp());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
Habbo habboTo = Emulator.getGameServer().getGameClientManager().getHabbo(userTo);
diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
index 62d7a862..4a292b87 100644
--- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
@@ -7,6 +7,8 @@ import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.friends.FriendChatMessageComposer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -14,6 +16,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class MessengerBuddy implements Runnable, ISerialize {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MessengerBuddy.class);
private int id;
private String username;
@@ -44,7 +47,7 @@ public class MessengerBuddy implements Runnable, ISerialize {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -56,7 +59,7 @@ public class MessengerBuddy implements Runnable, ISerialize {
this.relation = 0;
this.userOne = 0;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -149,7 +152,7 @@ public class MessengerBuddy implements Runnable, ISerialize {
statement.setInt(3, this.id);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java
index 1fc72341..3c8517da 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolBan.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.modtool;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -9,6 +11,8 @@ import java.sql.SQLException;
import java.text.SimpleDateFormat;
public class ModToolBan implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModToolBan.class);
+
public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public int userId;
public String ip;
@@ -63,7 +67,7 @@ public class ModToolBan implements Runnable {
statement.setInt(9, this.cfhTopic);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
index 8a10edbb..c891286e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java
@@ -21,6 +21,8 @@ import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.sql.*;
@@ -29,6 +31,8 @@ import java.util.List;
import java.util.Map;
public class ModToolManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModToolManager.class);
+
private final TIntObjectMap category;
private final THashMap> presets;
private final THashMap tickets;
@@ -41,7 +45,7 @@ public class ModToolManager {
this.tickets = new THashMap<>();
this.cfhCategories = new TIntObjectHashMap<>();
this.loadModTool();
- Emulator.getLogging().logStart("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("ModTool Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public static void requestUserInfo(GameClient client, ClientMessage packet) {
@@ -58,9 +62,9 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -78,7 +82,7 @@ public class ModToolManager {
this.loadTickets(connection);
this.loadCfhCategories(connection);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -97,7 +101,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -108,7 +112,7 @@ public class ModToolManager {
this.presets.get(set.getString("type")).add(set.getString("preset"));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -120,7 +124,7 @@ public class ModToolManager {
this.tickets.put(set.getInt("id"), new ModToolIssue(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -146,7 +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) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -198,7 +202,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return chatlogs;
@@ -207,7 +211,7 @@ public class ModToolManager {
public ArrayList getUserChatlog(int userId) {
ArrayList chatlogs = new ArrayList<>();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY timestamp DESC LIMIT 150")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, chatlogs_room.* FROM chatlogs_room INNER JOIN users ON users.id = chatlogs_room.user_from_id WHERE user_from_id = ? ORDER BY chatlogs_room.timestamp DESC LIMIT 150")) {
statement.setInt(1, userId);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
@@ -215,7 +219,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return chatlogs;
@@ -224,7 +228,7 @@ public class ModToolManager {
public ArrayList getMessengerChatlog(int userOneId, int userTwoId) {
ArrayList chatLogs = new ArrayList<>();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY timestamp DESC LIMIT 50")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username, chatlogs_private.* FROM chatlogs_private INNER JOIN users ON users.id = user_from_id WHERE (user_from_id = ? AND user_to_id = ?) OR (user_from_id = ? AND user_to_id = ?) ORDER BY chatlogs_private.timestamp DESC LIMIT 50")) {
statement.setInt(1, userOneId);
statement.setInt(2, userTwoId);
statement.setInt(3, userTwoId);
@@ -235,7 +239,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return chatLogs;
@@ -272,7 +276,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return chatlogs;
@@ -290,7 +294,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return roomVisits;
@@ -348,7 +352,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return roomVisits;
@@ -378,7 +382,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return null;
@@ -495,7 +499,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return ban;
@@ -519,7 +523,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return banned;
@@ -543,7 +547,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -557,7 +561,7 @@ public class ModToolManager {
statement.execute();
return statement.getUpdateCount() > 0;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
@@ -662,7 +666,7 @@ public class ModToolManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return total;
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java
index ea72d8bb..3960d07e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolSanctions.java
@@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.plugin.events.sanctions.SanctionEvent;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -13,6 +15,7 @@ import java.util.ArrayList;
import java.util.Date;
public class ModToolSanctions {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModToolSanctions.class);
private final THashMap> sanctionHashmap;
private final THashMap sanctionLevelsHashmap;
@@ -22,8 +25,8 @@ public class ModToolSanctions {
this.sanctionHashmap = new THashMap<>();
this.sanctionLevelsHashmap = new THashMap<>();
this.loadModSanctions();
- Emulator.getLogging().logStart("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) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -68,7 +71,7 @@ public class ModToolSanctions {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return this.sanctionHashmap;
@@ -87,7 +90,7 @@ public class ModToolSanctions {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -98,7 +101,7 @@ public class ModToolSanctions {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -109,7 +112,7 @@ public class ModToolSanctions {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -120,7 +123,7 @@ public class ModToolSanctions {
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
index 123a47c4..07cbadab 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
@@ -9,6 +9,8 @@ import com.eu.habbo.plugin.events.users.UserTriggerWordFilterEvent;
import gnu.trove.iterator.hash.TObjectHashIterator;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -18,6 +20,8 @@ import java.text.Normalizer;
import java.util.regex.Pattern;
public class WordFilter {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WordFilter.class);
+
private static final Pattern DIACRITICS_AND_FRIENDS = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+");
//Configuration. Loaded from database & updated accordingly.
public static boolean ENABLED_FRIENDCHAT = true;
@@ -29,7 +33,7 @@ public class WordFilter {
public WordFilter() {
long start = System.currentTimeMillis();
this.reload();
- Emulator.getLogging().logStart("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)");
+ LOGGER.info("WordFilter -> Loaded! (" + (System.currentTimeMillis() - start) + " MS)");
}
private static String stripDiacritics(String str) {
@@ -54,7 +58,7 @@ public class WordFilter {
try {
word = new WordFilterWord(set);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
continue;
}
@@ -67,7 +71,7 @@ public class WordFilter {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -134,29 +138,14 @@ public class WordFilter {
filteredMessage = this.normalise(filteredMessage);
}
- TObjectHashIterator iterator = this.words.iterator();
-
- boolean foundShit = false;
-
- while (iterator.hasNext()) {
- WordFilterWord word = (WordFilterWord) iterator.next();
-
- if (StringUtils.containsIgnoreCase(filteredMessage, word.key)) {
- if (habbo != null) {
- if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
- continue;
- }
- filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement);
- foundShit = true;
-
- if (habbo != null && word.muteTime > 0) {
- habbo.mute(word.muteTime, false);
- }
+ for (WordFilterWord word : this.words) {
+ if (!StringUtils.containsIgnoreCase(filteredMessage, word.key)) continue;
+ if (habbo != null) {
+ if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
+ continue;
}
- }
- if (!foundShit) {
- return message;
+ filteredMessage = filteredMessage.replaceAll("(?i)" + Pattern.quote(word.key), word.replacement);
}
return filteredMessage;
diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java
index ff1b74b1..0a7825a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorHotelFilter.java
@@ -19,7 +19,7 @@ public class NavigatorHotelFilter extends NavigatorFilter {
@Override
public List getResult(Habbo habbo) {
- boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
+ boolean showInvisible = habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
List resultLists = new ArrayList<>();
int i = 0;
@@ -41,7 +41,7 @@ public class NavigatorHotelFilter extends NavigatorFilter {
@Override
public List getResult(Habbo habbo, NavigatorFilterField filterField, String value, int roomCategory) {
- boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
+ boolean showInvisible = habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
if (!filterField.databaseQuery.isEmpty()) {
List resultLists = new ArrayList<>();
int i = 0;
diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java
index e4fea5b7..929456b9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorManager.java
@@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.sql.Connection;
@@ -18,9 +20,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class NavigatorManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NavigatorManager.class);
+
public static int MAXIMUM_RESULTS_PER_PAGE = 10;
-
-
public static boolean CATEGORY_SORT_USING_ORDER_NUM = false;
public final THashMap publicCategories = new THashMap<>();
@@ -36,7 +38,7 @@ public class NavigatorManager {
this.filters.put(NavigatorUserFilter.name, new NavigatorUserFilter());
this.filters.put(NavigatorFavoriteFilter.name, new NavigatorFavoriteFilter());
- Emulator.getLogging().logStart("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Navigator Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public void loadNavigator() {
@@ -49,7 +51,7 @@ public class NavigatorManager {
this.publicCategories.put(set.getInt("id"), new NavigatorPublicCategory(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM navigator_publics WHERE visible = '1'")) {
@@ -62,12 +64,12 @@ public class NavigatorManager {
if (room != null) {
category.addRoom(room);
} else {
- Emulator.getLogging().logErrorLine("Public room (ID: " + set.getInt("room_id") + " defined in navigator_publics does not exist!");
+ LOGGER.error("Public room (ID: {} defined in navigator_publics does not exist!", set.getInt("room_id"));
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -83,7 +85,7 @@ public class NavigatorManager {
field = clazz.getDeclaredMethod(s);
clazz = field.getReturnType();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
}
@@ -91,7 +93,7 @@ public class NavigatorManager {
try {
field = clazz.getDeclaredMethod(set.getString("field"));
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
continue;
}
}
@@ -101,11 +103,11 @@ public class NavigatorManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
List staffPromotedRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsStaffPromoted();
diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java
index 49be285d..4ab8c3bd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorPublicFilter.java
@@ -16,7 +16,7 @@ public class NavigatorPublicFilter extends NavigatorFilter {
@Override
public List getResult(Habbo habbo) {
- boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
+ boolean showInvisible = habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
List resultLists = new ArrayList<>();
int i = 0;
diff --git a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java
index 2e98a9c3..a27d3c69 100644
--- a/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/navigation/NavigatorRoomAdsFilter.java
@@ -16,7 +16,7 @@ public class NavigatorRoomAdsFilter extends NavigatorFilter {
@Override
public List getResult(Habbo habbo) {
- boolean showInvisible = habbo.hasPermission("acc_enter_anyroom") || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
+ boolean showInvisible = habbo.hasPermission(Permission.ACC_ENTERANYROOM) || habbo.hasPermission(Permission.ACC_ANYROOMOWNER);
List resultList = new ArrayList<>();
resultList.add(new SearchResultList(0, "categories", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("categories", ListMode.LIST), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("official-root", DisplayMode.VISIBLE), Emulator.getGameEnvironment().getNavigatorManager().getRoomsForCategory("categories", habbo), false, showInvisible, DisplayOrder.ACTIVITY, 0));
return resultList;
diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java b/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java
index a41fd11a..5dfdd12f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java
+++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Permission.java
@@ -1,7 +1,7 @@
package com.eu.habbo.habbohotel.permissions;
public class Permission {
- public static String ACC_ANYCHATCOLOR = "acc_anychatcolor";
+ public static String ACC_ANYCHATCOLOR = "acc_anychatcolor"; // allows them to pick and choose any color from the chat bubbles.
public static String ACC_ANYROOMOWNER = "acc_anyroomowner";
public static String ACC_EMPTY_OTHERS = "acc_empty_others";
public static String ACC_ENABLE_OTHERS = "acc_enable_others";
@@ -15,17 +15,16 @@ public class Permission {
public static String ACC_UNLIMITED_BOTS = "acc_unlimited_bots";
public static String ACC_UNLIMITED_PETS = "acc_unlimited_pets";
public static String ACC_HIDE_IP = "acc_hide_ip";
+ public static String ACC_HIDE_MAIL = "acc_hide_mail";
public static String ACC_NOT_MIMICED = "acc_not_mimiced";
public static String ACC_CHAT_NO_FLOOD = "acc_chat_no_flood";
- public static String ACC_STAFF_CHAT = "acc_staff_chat";
public static String ACC_STAFF_PICK = "acc_staff_pick";
- public static String ACC_ENTERANYROOM = "acc_enteranyroom";
+ public static String ACC_ENTERANYROOM = "acc_enteranyroom"; //
public static String ACC_FULLROOMS = "acc_fullrooms";
public static String ACC_INFINITE_CREDITS = "acc_infinite_credits";
public static String ACC_INFINITE_PIXELS = "acc_infinite_pixels";
public static String ACC_INFINITE_POINTS = "acc_infinite_points";
public static String ACC_AMBASSADOR = "acc_ambassador";
- public static String ACC_DEBUG = "acc_debug";
public static String ACC_CHAT_NO_LIMIT = "acc_chat_no_limit";
public static String ACC_CHAT_NO_FILTER = "acc_chat_no_filter";
public static String ACC_NOMUTE = "acc_nomute";
@@ -39,12 +38,10 @@ public class Permission {
public static String ACC_MODTOOL_ROOM_INFO = "acc_modtool_room_info";
public static String ACC_MODTOOL_ROOM_LOGS = "acc_modtool_room_logs";
public static String ACC_TRADE_ANYWHERE = "acc_trade_anywhere";
- public static String ACC_UPDATE_NOTIFICATIONS = "acc_update_notifications";
public static String ACC_HELPER_USE_GUIDE_TOOL = "acc_helper_use_guide_tool";
public static String ACC_HELPER_GIVE_GUIDE_TOURS = "acc_helper_give_guide_tours";
public static String ACC_HELPER_JUDGE_CHAT_REVIEWS = "acc_helper_judge_chat_reviews";
public static String ACC_FLOORPLAN_EDITOR = "acc_floorplan_editor";
- public static String ACC_CAMERA = "acc_camera";
public final String key;
public final PermissionSetting setting;
public Permission(String key, PermissionSetting setting) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java
index cfd1620e..e815b4b1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/permissions/PermissionsManager.java
@@ -6,6 +6,8 @@ import com.eu.habbo.plugin.HabboPlugin;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
@@ -13,6 +15,8 @@ import java.util.List;
import java.util.Set;
public class PermissionsManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManager.class);
+
private final TIntObjectHashMap ranks;
private final TIntIntHashMap enables;
private final THashMap> badges;
@@ -25,7 +29,7 @@ public class PermissionsManager {
this.reload();
- Emulator.getLogging().logStart("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Permissions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public void reload() {
@@ -58,7 +62,7 @@ public class PermissionsManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -71,7 +75,7 @@ public class PermissionsManager {
this.enables.put(set.getInt("effect_id"), set.getInt("min_rank"));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java
index be2a9e63..b488f968 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/GnomePet.java
@@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -11,6 +13,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class GnomePet extends Pet implements IPetLook {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GnomePet.class);
+
private final String gnomeData;
public GnomePet(ResultSet set) throws SQLException {
@@ -47,7 +51,7 @@ public class GnomePet extends Pet implements IPetLook {
statement.setInt(2, this.id);
statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
index 46704168..666fa8d1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/HorsePet.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.pets;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -8,6 +10,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class HorsePet extends RideablePet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(HorsePet.class);
+
private int hairColor;
private int hairStyle;
@@ -40,7 +44,7 @@ public class HorsePet extends RideablePet {
statement.setInt(6, super.getId());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
super.run();
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
index 19bb4181..c362cf58 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
@@ -13,6 +13,8 @@ import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import org.apache.commons.math3.util.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -23,35 +25,37 @@ import java.util.LinkedHashMap;
import java.util.Map;
public class MonsterplantPet extends Pet implements IPetLook {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MonsterplantPet.class);
+
public static final Map> bodyRarity = new LinkedHashMap>() {
{
this.put(1, new Pair<>("Blungon", 0));
- this.put(5, new Pair<>("Squarg", 0));
this.put(2, new Pair<>("Wailzor", 1));
this.put(3, new Pair<>("Stumpy", 1));
this.put(4, new Pair<>("Sunspike", 2));
- this.put(9, new Pair<>("Weggylum", 2));
+ this.put(5, new Pair<>("Squarg", 0));
this.put(6, new Pair<>("Shroomer", 3));
this.put(7, new Pair<>("Zuchinu", 3));
+ this.put(8, new Pair<>("Abysswirl", 5));
+ this.put(9, new Pair<>("Weggylum", 2));
this.put(10, new Pair<>("Wystique", 4));
this.put(11, new Pair<>("Hairbullis", 4));
- this.put(8, new Pair<>("Abysswirl", 5));
this.put(12, new Pair<>("Snozzle", 5)); //Rarity???
}
};
public static final Map> colorRarity = new LinkedHashMap>() {
{
this.put(0, new Pair<>("Aenueus", 0));
- this.put(9, new Pair<>("Fulvus", 0));
this.put(1, new Pair<>("Griseus", 1));
- this.put(3, new Pair<>("Viridulus", 1));
this.put(2, new Pair<>("Phoenicus", 2));
+ this.put(3, new Pair<>("Viridulus", 1));
+ this.put(4, new Pair<>("Cyaneus", 5));
this.put(5, new Pair<>("Incarnatus", 2));
- this.put(8, new Pair<>("Amethyst", 3));
- this.put(10, new Pair<>("Cinereus", 3));
this.put(6, new Pair<>("Azureus", 4));
this.put(7, new Pair<>("Atamasc", 4));
- this.put(4, new Pair<>("Cyaneus", 5));
+ this.put(8, new Pair<>("Amethyst", 3));
+ this.put(9, new Pair<>("Fulvus", 0));
+ this.put(10, new Pair<>("Cinereus", 3));
}
};
public static final ArrayList> indexedBody = new ArrayList<>(MonsterplantPet.bodyRarity.values());
@@ -138,7 +142,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
statement.setInt(13, this.id);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -349,6 +353,19 @@ public class MonsterplantPet extends Pet implements IPetLook {
}
}
+ private boolean mayScratch() {
+ // Monsterplant petting is available when:
+ // ((energy / max_energy) < 0.98) = true
+ // You can find the minimum deathTimestamp by solving (insert a timestamp for timestamp, solve for death_timestamp):
+ // (((death_timestamp - timestamp) / 259200)) < 0.98
+ // This information was found in the Habbo swf, com.sulake.habbo.ui.widget.infostand.InfoStandPetView.as
+ // this._Str_2304("pettreat", ((_local_3 / _local_4) < 0.98));
+ final float energy = this.getEnergy();
+ final float energyMax = this.getMaxEnergy();
+
+ return ((energy / energyMax) < 0.98);
+ }
+
@Override
public int getMaxEnergy() {
return MonsterplantPet.timeToLive;
@@ -364,13 +381,15 @@ public class MonsterplantPet extends Pet implements IPetLook {
}
@Override
- public void scratched(Habbo habbo) {
- AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
- this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
- this.addHappyness(10);
- this.addExperience(10);
- this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
- this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
+ public synchronized void scratched(Habbo habbo) {
+ if (this.mayScratch()) {
+ AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
+ this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
+ this.addHappyness(10);
+ this.addExperience(10);
+ this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
+ this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
+ }
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
index 965584c4..d5e13742 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
@@ -14,6 +14,8 @@ import com.eu.habbo.messages.outgoing.rooms.users.RoomUserRemoveComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
import com.eu.habbo.plugin.events.pets.PetTalkEvent;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.Calendar;
@@ -21,6 +23,7 @@ import java.util.Map;
import java.util.TimeZone;
public class Pet implements ISerialize, Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Pet.class);
public int levelThirst;
public int levelHunger;
@@ -62,7 +65,7 @@ public class Pet implements ISerialize, Runnable {
this.name = set.getString("name");
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(set.getInt("type"));
if (this.petData == null) {
- Emulator.getLogging().logErrorLine("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!");
+ LOGGER.error("WARNING! Missing pet data for type: " + set.getInt("type") + "! Insert a new entry into the pet_actions table for this type!");
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(0);
}
this.race = set.getInt("race");
@@ -85,7 +88,7 @@ public class Pet implements ISerialize, Runnable {
this.petData = Emulator.getGameEnvironment().getPetManager().getPetData(type);
if (this.petData == null) {
- Emulator.getLogging().logErrorLine(new Exception("WARNING! Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!"));
+ LOGGER.warn("Missing pet data for type: " + type + "! Insert a new entry into the pet_actions table for this type!");
}
this.race = race;
@@ -205,7 +208,7 @@ public class Pet implements ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.needsUpdate = false;
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
index 7335963d..8294707d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetManager.java
@@ -19,6 +19,8 @@ import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TIntObjectProcedure;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.distribution.NormalDistribution;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
@@ -26,6 +28,8 @@ import java.util.Collection;
import java.util.Map;
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() {
@@ -79,7 +83,7 @@ public class PetManager {
reloadPetData();
- Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
+ LOGGER.info("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public static int getLevel(int experience) {
@@ -101,13 +105,15 @@ public class PetManager {
return 100 * level;
}
- public static int randomBody(int minimumRarity) {
- int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0);
+ public static int randomBody(int minimumRarity, boolean isRare) {
+ int randomRarity = isRare ? random(Math.max(minimumRarity - 1, 0), (MonsterplantPet.bodyRarity.size() - minimumRarity) + (minimumRarity - 1), 2.0) : random(Math.max(minimumRarity - 1, 0), MonsterplantPet.bodyRarity.size(), 2.0);
+
return MonsterplantPet.bodyRarity.get(MonsterplantPet.bodyRarity.keySet().toArray()[randomRarity]).getValue();
}
- public static int randomColor(int minimumRarity) {
- int randomRarity = random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0);
+ public static int randomColor(int minimumRarity, boolean isRare) {
+ int randomRarity = isRare ? random(Math.max(minimumRarity - 1, 0), (MonsterplantPet.colorRarity.size() - minimumRarity) + (minimumRarity - 1), 2.0) : random(Math.max(minimumRarity - 1, 0), MonsterplantPet.colorRarity.size(), 2.0);
+
return MonsterplantPet.colorRarity.get(MonsterplantPet.colorRarity.keySet().toArray()[randomRarity]).getValue();
}
@@ -148,8 +154,8 @@ public class PetManager {
this.loadPetCommands(connection);
this.loadPetBreeding(connection);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- Emulator.getLogging().logErrorLine("Pet Manager -> Failed to load!");
+ LOGGER.error("Caught SQL exception", e);
+ LOGGER.error("Pet Manager -> Failed to load!");
}
}
@@ -164,7 +170,7 @@ public class PetManager {
this.petRaces.get(set.getInt("race")).add(new PetRace(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -174,7 +180,7 @@ public class PetManager {
this.petData.put(set.getInt("pet_type"), new PetData(set));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.loadPetItems(connection);
@@ -214,7 +220,7 @@ public class PetManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -228,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 {
- Emulator.getLogging().logErrorLine("Unknown pet vocal type " + set.getString("type"));
+ LOGGER.error("Unknown pet vocal type " + set.getString("type"));
}
} else {
- Emulator.getLogging().logErrorLine("Missing pet_actions table entry for pet id " + set.getInt("pet_id"));
+ LOGGER.error("Missing pet_actions table entry for pet id " + set.getInt("pet_id"));
}
} else {
if (!PetData.generalPetVocals.containsKey(PetVocalsType.valueOf(set.getString("type").toUpperCase())))
@@ -241,7 +247,7 @@ public class PetManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -252,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) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_commands ORDER BY pet_id ASC")) {
@@ -264,7 +270,7 @@ public class PetManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -274,7 +280,7 @@ public class PetManager {
this.breedingPetType.put(set.getInt("pet_id"), set.getInt("offspring_id"));
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
try (Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM pet_breeding_races")) {
@@ -291,13 +297,13 @@ public class PetManager {
this.breedingReward.get(reward.petType).get(reward.rarityLevel).add(reward);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
public THashSet getBreeds(String petName) {
if (!petName.startsWith("a0 pet")) {
- Emulator.getLogging().logErrorLine("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!");
+ LOGGER.error("Pet " + petName + " not found. Make sure it matches the pattern \"a0 pet\"!");
return null;
}
@@ -305,7 +311,7 @@ public class PetManager {
int petId = Integer.valueOf(petName.split("t")[1]);
return this.petRaces.get(petId);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return null;
@@ -343,7 +349,7 @@ public class PetManager {
return this.petData.get(type);
} else {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
- Emulator.getLogging().logErrorLine("Missing petdata for type " + type + ". Adding this to the database...");
+ LOGGER.error("Missing petdata for type " + type + ". Adding this to the database...");
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO pet_actions (pet_type) VALUES (?)")) {
statement.setInt(1, type);
statement.execute();
@@ -355,13 +361,13 @@ public class PetManager {
if (set.next()) {
PetData petData = new PetData(set);
this.petData.put(type, petData);
- Emulator.getLogging().logErrorLine("Missing petdata for type " + type + " added to the database!");
+ LOGGER.error("Missing petdata for type " + type + " added to the database!");
return petData;
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -426,8 +432,8 @@ public class PetManager {
public MonsterplantPet createMonsterplant(Room room, Habbo habbo, boolean rare, RoomTile t, int minimumRarity) {
MonsterplantPet pet = new MonsterplantPet(
habbo.getHabboInfo().getId(), //Owner ID
- randomBody(rare ? 4 : minimumRarity),
- randomColor(rare ? 4 : minimumRarity),
+ randomBody(minimumRarity, rare),
+ randomColor(minimumRarity, rare),
Emulator.getRandom().nextInt(12) + 1,
Emulator.getRandom().nextInt(11),
Emulator.getRandom().nextInt(12) + 1,
@@ -508,7 +514,7 @@ public class PetManager {
statement.setInt(1, pet.getId());
return statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java
index e7edc7ae..8e2d78a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/polls/PollManager.java
@@ -3,10 +3,14 @@ package com.eu.habbo.habbohotel.polls;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import gnu.trove.map.hash.THashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.*;
public class PollManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PollManager.class);
+
private final THashMap activePolls = new THashMap<>();
public PollManager() {
@@ -23,7 +27,7 @@ public class PollManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
return false;
}
@@ -63,7 +67,7 @@ public class PollManager {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
index 23db2026..3ca0650f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
@@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -8,6 +10,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class CustomRoomLayout extends RoomLayout implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CustomRoomLayout.class);
+
private final int roomId;
private boolean needsUpdate;
@@ -30,7 +34,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable {
statement.setInt(5, this.roomId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
index be20b9e9..9c1ddb76 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
@@ -13,7 +13,9 @@ public enum FurnitureMovementError {
TILE_HAS_BOTS("${room.error.cant_set_item}"),
MAX_DIMMERS("${room.error.max_dimmers}"),
MAX_SOUNDFURNI("${room.errors.max_soundfurni}"),
- MAX_ITEMS("${room.error.max_furniture}");
+ MAX_ITEMS("${room.error.max_furniture}"),
+ MAX_STICKIES("${room.error.max_stickies}");
+
public final String errorCode;
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
index 6e36318b..517b38b8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
@@ -54,10 +54,7 @@ import com.eu.habbo.plugin.events.furniture.*;
import com.eu.habbo.plugin.events.rooms.RoomLoadedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUnloadedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUnloadingEvent;
-import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
-import com.eu.habbo.plugin.events.users.UserIdleEvent;
-import com.eu.habbo.plugin.events.users.UserRightsTakenEvent;
-import com.eu.habbo.plugin.events.users.UserRolledEvent;
+import com.eu.habbo.plugin.events.users.*;
import com.eu.habbo.threading.runnables.YouAreAPirate;
import gnu.trove.TCollections;
import gnu.trove.iterator.TIntObjectIterator;
@@ -72,6 +69,8 @@ import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
import io.netty.util.internal.ConcurrentSet;
import org.apache.commons.math3.util.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.awt.*;
import java.sql.Connection;
@@ -83,28 +82,26 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class Room implements Comparable, ISerialize, Runnable {
- public static final Comparator SORT_SCORE = new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- if (!(o1 instanceof Room && o2 instanceof Room))
- return 0;
+ private static final Logger LOGGER = LoggerFactory.getLogger(Room.class);
- return ((Room) o2).getScore() - ((Room) o1).getScore();
- }
+ 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 = new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
+ public static final Comparator SORT_ID = (o1, o2) -> {
- if (!(o1 instanceof Room && o2 instanceof Room))
- return 0;
+ if (!(o1 instanceof Room && o2 instanceof Room))
+ return 0;
- return ((Room) o2).getId() - ((Room) o1).getId();
- }
+ return ((Room) o2).getId() - ((Room) o1).getId();
};
private static final TIntObjectHashMap defaultMoodData = new TIntObjectHashMap<>();
//Configuration. Loaded from database & updated accordingly.
@@ -112,10 +109,12 @@ public class Room implements Comparable, ISerialize, Runnable {
public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10;
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;
public static int IDLE_CYCLES_KICK = 480;
public static String PREFIX_FORMAT = "[%prefix%] ";
+ public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
static {
for (int i = 1; i <= 3; i++) {
@@ -146,7 +145,6 @@ 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 THashMap waterTiles;
public ConcurrentSet scheduledComposers = new ConcurrentSet<>();
public ConcurrentSet scheduledTasks = new ConcurrentSet<>();
public String wordQuiz = "";
@@ -204,11 +202,13 @@ public class Room implements Comparable, ISerialize, Runnable {
private int idleCycles;
private volatile int unitCounter;
private volatile int rollerSpeed;
+ private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30);
private long rollerCycle = System.currentTimeMillis();
private volatile int lastTimerReset = Emulator.getIntUnixTimestamp();
private volatile boolean muted;
private RoomSpecialTypes roomSpecialTypes;
private TraxManager traxManager;
+ private boolean cycleOdd;
private long cycleTimestamp;
public Room(ResultSet set) throws SQLException {
@@ -270,7 +270,7 @@ public class Room implements Comparable, ISerialize, Runnable {
this.loadBans(connection);
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.tradeMode = set.getInt("trade_mode");
@@ -318,49 +318,49 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
this.loadLayout();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadRights(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadItems(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadHeightmap();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadBots(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadPets(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadWordFilter(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
try {
this.loadWiredData(connection);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
this.idleCycles = 0;
@@ -368,7 +368,7 @@ public class Room implements Comparable, ISerialize, Runnable {
this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
this.traxManager = new TraxManager(this);
@@ -406,7 +406,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} else {
- Emulator.getLogging().logErrorLine("Unknown Room Layout for Room (ID: " + this.id + ")");
+ LOGGER.error("Unknown Room Layout for Room (ID: {})", this.id);
}
}
@@ -421,11 +421,11 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
if (this.itemCount() > Room.MAXIMUM_FURNI) {
- Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ").");
+ LOGGER.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI);
}
}
@@ -442,14 +442,14 @@ public class Room implements Comparable, ISerialize, Runnable {
((InteractionWired) item).loadWiredData(set, this);
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -485,7 +485,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -515,12 +515,12 @@ public class Room implements Comparable, ISerialize, Runnable {
this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name"));
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -535,14 +535,13 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
public void updateTile(RoomTile tile) {
if (tile != null) {
tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false));
-
tile.setState(this.calculateTileState(tile));
}
}
@@ -566,17 +565,28 @@ public class Room implements Comparable, ISerialize, Runnable {
return RoomTileState.INVALID;
RoomTileState result = RoomTileState.OPEN;
- HabboItem lowestItem = null;
+ HabboItem highestItem = null;
HabboItem lowestChair = this.getLowestChair(tile);
THashSet items = this.getItemsAt(tile);
- if (items == null) return RoomTileState.INVALID;
- if (items.stream().anyMatch(i -> i.getBaseItem().allowLay())) return RoomTileState.LAY;
+ if (items == null) return RoomTileState.INVALID;
for (HabboItem item : items) {
if (exclude != null && item == exclude) continue;
- if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
+ if(item.getBaseItem().allowLay()) {
+ return RoomTileState.LAY;
+ }
+
+ if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
+ continue;
+
+ highestItem = item;
+ if (result == RoomTileState.OPEN) {
+ result = this.checkStateForItem(item, tile);
+ }
+
+ /*if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
continue;
}
@@ -588,7 +598,7 @@ public class Room implements Comparable, ISerialize, Runnable {
if (result == RoomTileState.OPEN) {
result = this.checkStateForItem(item, tile);
}
- }
+ }*/
}
if (lowestChair != null) return RoomTileState.SIT;
@@ -717,14 +727,11 @@ public class Room implements Comparable, ISerialize, Runnable {
}
if (oldZ != roomUnit.getZ()) {
- this.scheduledTasks.add(new Runnable() {
- @Override
- public void run() {
- try {
- item.onWalkOn(roomUnit, Room.this, null);
- } catch (Exception e) {
+ this.scheduledTasks.add(() -> {
+ try {
+ item.onWalkOn(roomUnit, Room.this, null);
+ } catch (Exception e) {
- }
}
});
}
@@ -742,23 +749,22 @@ public class Room implements Comparable, ISerialize, Runnable {
THashSet roomUnits = new THashSet<>();
for (Habbo habbo : habbos) {
+
+ double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight();
+
if ((item == null && !habbo.getRoomUnit().cmdSit) || (item != null && !item.getBaseItem().allowSit()))
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
if ((item == null && !habbo.getRoomUnit().cmdLay) || (item != null && !item.getBaseItem().allowLay()))
habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
- if (item != null) {
- if (item.getBaseItem().allowSit() || item.getBaseItem().allowLay()) {
- habbo.getRoomUnit().setZ(item.getZ());
- habbo.getRoomUnit().setPreviousLocationZ(item.getZ());
- habbo.getRoomUnit().setRotation(RoomUserRotation.fromValue(item.getRotation()));
- } else {
- habbo.getRoomUnit().setZ(item.getZ() + Item.getCurrentHeight(item));
- }
+ if (item != null && (item.getBaseItem().allowSit() || item.getBaseItem().allowLay())) {
+ habbo.getRoomUnit().setZ(item.getZ());
+ habbo.getRoomUnit().setPreviousLocationZ(item.getZ());
+ habbo.getRoomUnit().setRotation(RoomUserRotation.fromValue(item.getRotation()));
} else {
- habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
- habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
+ habbo.getRoomUnit().setZ(z);
+ habbo.getRoomUnit().setPreviousLocationZ(z);
}
roomUnits.add(habbo.getRoomUnit());
}
@@ -929,7 +935,7 @@ public class Room implements Comparable, ISerialize, Runnable {
botIterator.value().needsUpdate(true);
Emulator.getThreading().run(botIterator.value());
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
}
@@ -937,7 +943,7 @@ public class Room implements Comparable, ISerialize, Runnable {
this.currentBots.clear();
this.currentPets.clear();
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -949,7 +955,7 @@ public class Room implements Comparable, ISerialize, Runnable {
this.preLoaded = true;
this.layout = null;
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
@@ -1039,14 +1045,9 @@ public class Room implements Comparable, ISerialize, Runnable {
if (this.loaded) {
try {
Emulator.getThreading().run(
- new Runnable() {
- @Override
- public void run() {
- Room.this.cycle();
- }
- });
+ Room.this::cycle);
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
@@ -1109,7 +1110,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.executeUpdate();
this.needsUpdate = false;
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -1120,11 +1121,12 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setInt(2, this.id);
statement.executeUpdate();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
private void cycle() {
+ this.cycleOdd = !this.cycleOdd;
this.cycleTimestamp = System.currentTimeMillis();
final boolean[] foundRightHolder = {false};
@@ -1175,12 +1177,7 @@ public class Room implements Comparable, ISerialize, Runnable {
habbo.getRoomUnit().kickCount++;
if (habbo.getRoomUnit().kickCount >= 5) {
- this.scheduledTasks.add(new Runnable() {
- @Override
- public void run() {
- Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room);
- }
- });
+ this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room));
continue;
}
}
@@ -1191,6 +1188,7 @@ public class Room implements Comparable, ISerialize, Runnable {
if (habbo.getRoomUnit().isIdle()) {
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
+ WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
} else {
habbo.getRoomUnit().increaseIdleTimer();
@@ -1210,23 +1208,10 @@ public class Room implements Comparable, ISerialize, Runnable {
habbo.getHabboStats().mutedBubbleTracker = false;
this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose());
}
- if (!habbo.hasPermission("acc_chat_no_flood") && habbo.getHabboStats().chatCounter > 0) {
- //if (habbo.getRoomUnit().talkTimeOut == 0 || currentTimestamp - habbo.getRoomUnit().talkTimeOut < 0)
- {
- habbo.getHabboStats().chatCounter--;
- if (habbo.getHabboStats().chatCounter > 3 && !this.hasRights(habbo)) {
- if (this.chatProtection == 0) {
- this.floodMuteHabbo(habbo, 30);
- } else if (this.chatProtection == 1 && habbo.getHabboStats().chatCounter > 4) {
- this.floodMuteHabbo(habbo, 30);
- } else if (this.chatProtection == 2 && habbo.getHabboStats().chatCounter > 5) {
- this.floodMuteHabbo(habbo, 30);
- }
- }
- }
- } else {
- habbo.getHabboStats().chatCounter = 0;
+ // Substract 1 from the chatCounter every odd cycle, which is every (500ms * 2).
+ if (this.cycleOdd && habbo.getHabboStats().chatCounter.get() > 0) {
+ habbo.getHabboStats().chatCounter.decrementAndGet();
}
if (this.cycleRoomUnit(habbo.getRoomUnit(), RoomUnitType.USER)) {
@@ -1267,7 +1252,7 @@ public class Room implements Comparable, ISerialize, Runnable {
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
}
@@ -1280,7 +1265,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
petIterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -1425,9 +1410,13 @@ public class Room implements Comparable, ISerialize, Runnable {
HabboItem nextTileChair = this.getLowestChair(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 (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
@@ -1462,6 +1451,7 @@ 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), tile, tile.getStackHeight() + (isRiding ? 1 : 0) + (nextTileChair != null ? -1 : 0), room));
@@ -1470,15 +1460,12 @@ public class Room implements Comparable, ISerialize, Runnable {
HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y);
if (item != null && itemsNewTile.contains(item)) {
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- if (unit.getGoal() == rollerTile) {
- try {
- item.onWalkOn(unit, room, null);
- } catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
- }
+ Emulator.getThreading().run(() -> {
+ if (unit.getGoal() == rollerTile) {
+ try {
+ item.onWalkOn(unit, room, null);
+ } catch (Exception e) {
+ LOGGER.error("Caught exception", e);
}
}
}, this.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY);
@@ -2012,30 +1999,37 @@ public class Room implements Comparable, ISerialize, Runnable {
* @param excludeUserId Habbo id to keep pets
*/
public void removeAllPets(int excludeUserId) {
+ ArrayList toRemovePets = new ArrayList<>();
ArrayList removedPets = new ArrayList<>();
synchronized (this.currentPets) {
for (Pet pet : this.currentPets.valueCollection()) {
try {
if (pet.getUserId() != excludeUserId) {
-
- pet.removeFromRoom();
-
- Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId());
- if (habbo != null) {
- habbo.getInventory().getPetsComponent().addPet(pet);
- habbo.getClient().sendResponse(new AddPetComposer(pet));
- }
+ toRemovePets.add(pet);
}
- pet.needsUpdate = true;
- pet.run();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
}
}
+ for (Pet pet : toRemovePets) {
+ removedPets.add(pet);
+
+ pet.removeFromRoom();
+
+ Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId());
+ if (habbo != null) {
+ habbo.getInventory().getPetsComponent().addPet(pet);
+ habbo.getClient().sendResponse(new AddPetComposer(pet));
+ }
+
+ pet.needsUpdate = true;
+ pet.run();
+ }
+
for (Pet pet : removedPets) {
this.currentPets.remove(pet.getId());
}
@@ -2143,7 +2137,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setInt(10, this.promotion.getCategory());
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.needsUpdate = true;
@@ -2235,7 +2229,7 @@ public class Room implements Comparable, ISerialize, Runnable {
return this.habboQueue.remove(habbo.getHabboInfo().getId()) != null;
}
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
return true;
@@ -2308,7 +2302,7 @@ public class Room implements Comparable, ISerialize, Runnable {
if (habbo != null) {
this.furniOwnerNames.put(item.getUserId(), habbo.getUsername());
} else {
- Emulator.getLogging().logDebugLine("Failed to find username for item (ID:" + item.getId() + ", UserID: " + item.getUserId() + ")");
+ LOGGER.error("Failed to find username for item (ID: {}, UserID: {})", item.getId(), item.getUserId());
}
}
}
@@ -2571,6 +2565,25 @@ public class Room implements Comparable, ISerialize, Runnable {
}
+ 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) {
synchronized (this.roomUnitLock) {
habbo.getRoomUnit().setId(this.unitCounter);
@@ -2603,7 +2616,7 @@ public class Room implements Comparable, ISerialize, Runnable {
habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit());
}
- if (sendRemovePacket && habbo.getRoomUnit() != null) {
+ if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting) {
this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
}
@@ -2614,7 +2627,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
item.onWalkOff(habbo.getRoomUnit(), this, new Object[]{});
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
@@ -2675,7 +2688,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
iterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -2695,7 +2708,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
iterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -2717,7 +2730,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
iterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -2760,7 +2773,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
petIterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -2839,7 +2852,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
petIterator.advance();
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
@@ -2994,7 +3007,7 @@ public class Room implements Comparable, ISerialize, Runnable {
try {
doorTileTopItem.onWalkOn(habbo.getRoomUnit(), this, new Object[]{});
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
@@ -3002,7 +3015,7 @@ public class Room implements Comparable, ISerialize, Runnable {
public void floodMuteHabbo(Habbo habbo, int timeOut) {
habbo.getHabboStats().mutedCount++;
timeOut += (timeOut * (int) Math.ceil(Math.pow(habbo.getHabboStats().mutedCount, 2)));
- habbo.getHabboStats().chatCounter = 0;
+ habbo.getHabboStats().chatCounter.set(0);
habbo.mute(timeOut, true);
}
@@ -3033,7 +3046,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
habbo.getHabboStats().lastChat = millis;
if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) {
- habbo.getHabboStats().chatCounter += 2;
+ habbo.getHabboStats().chatCounter.addAndGet(1);
Emulator.getThreading().run(new YouAreAPirate(habbo, this));
return;
}
@@ -3059,14 +3072,14 @@ public class Room implements Comparable, ISerialize, Runnable {
}
if (!this.wordFilterWords.isEmpty()) {
- if (!habbo.hasPermission("acc_chat_no_filter")) {
+ if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FILTER)) {
for (String string : this.wordFilterWords) {
- roomChatMessage.setMessage(roomChatMessage.getMessage().replace(string, "bobba"));
+ roomChatMessage.setMessage(roomChatMessage.getMessage().replaceAll("(?i)" + Pattern.quote(string), "bobba"));
}
}
}
- if (!habbo.hasPermission("acc_nomute")) {
+ if (!habbo.hasPermission(Permission.ACC_NOMUTE)) {
if (this.isMuted() && !this.hasRights(habbo)) {
return;
}
@@ -3092,9 +3105,40 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
- habbo.getHabboStats().chatCounter += 2;
+ if (!habbo.hasPermission(Permission.ACC_CHAT_NO_FLOOD)) {
+ final int chatCounter = habbo.getHabboStats().chatCounter.addAndGet(1);
- ServerMessage prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null;
+ 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)) {
+ UsernameTalkEvent usernameTalkEvent = (UsernameTalkEvent) Emulator.getPluginManager().fireEvent(new UsernameTalkEvent(habbo, roomChatMessage, chatType));
+ if (usernameTalkEvent.hasCustomComposer()) {
+ prefixMessage = usernameTalkEvent.getCustomComposer();
+ }
+ }
+
+ if(prefixMessage == null) {
+ prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null;
+ }
ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null;
Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation());
@@ -3110,9 +3154,10 @@ public class Room implements Comparable, ISerialize, Runnable {
return;
}
- final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose();
RoomChatMessage staffChatMessage = new RoomChatMessage(roomChatMessage);
staffChatMessage.setMessage("To " + staffChatMessage.getTargetHabbo().getHabboInfo().getUsername() + ": " + staffChatMessage.getMessage());
+
+ final ServerMessage message = new RoomUserWhisperComposer(roomChatMessage).compose();
final ServerMessage staffMessage = new RoomUserWhisperComposer(staffChatMessage).compose();
for (Habbo h : this.getHabbos()) {
@@ -3130,13 +3175,13 @@ public class Room implements Comparable, ISerialize, Runnable {
continue;
}
- if (h.hasPermission("acc_see_whispers")) {
+ if (h.hasPermission(Permission.ACC_SEE_WHISPERS)) {
h.getClient().sendResponse(staffMessage);
}
}
} else if (chatType == RoomChatType.TALK) {
ServerMessage message = new RoomUserTalkComposer(roomChatMessage).compose();
- boolean noChatLimit = habbo.hasPermission("acc_chat_no_limit");
+ boolean noChatLimit = habbo.hasPermission(Permission.ACC_CHAT_NO_LIMIT);
for (Habbo h : this.getHabbos()) {
if ((h.getRoomUnit().getCurrentLocation().distance(habbo.getRoomUnit().getCurrentLocation()) <= this.chatDistance ||
@@ -3181,7 +3226,7 @@ public class Room implements Comparable, ISerialize, Runnable {
bot.onUserSay(roomChatMessage);
} catch (NoSuchElementException e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
break;
}
}
@@ -3199,13 +3244,21 @@ public class Room implements Comparable, ISerialize, Runnable {
RoomChatMessage itemMessage = new RoomChatMessage(Emulator.getTexts().getValue(item.getBaseItem().getName() + ".message." + randomValue, item.getBaseItem().getName() + ".message." + randomValue + " not found!"), habbo, RoomChatMessageBubbles.getBubble(Emulator.getConfig().getInt(item.getBaseItem().getName() + ".message.bubble", RoomChatMessageBubbles.PARROT.getType())));
- this.sendComposer(new RoomUserShoutComposer(itemMessage).compose());
+ this.sendComposer(new RoomUserTalkComposer(itemMessage).compose());
try {
item.onClick(habbo.getClient(), this, new Object[0]);
+ item.setExtradata("1");
+ updateItemState(item);
+
+ Emulator.getThreading().run(() -> {
+ item.setExtradata("0");
+ updateItemState(item);
+ }, 2000);
+
break;
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ LOGGER.error("Caught exception", e);
}
}
}
@@ -3281,6 +3334,10 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public THashSet getItemsAt(RoomTile tile) {
+ return getItemsAt(tile, false);
+ }
+
+ public THashSet getItemsAt(RoomTile tile, boolean returnOnFirst) {
THashSet items = new THashSet<>(0);
if (tile == null)
@@ -3309,19 +3366,24 @@ public class Room implements Comparable, ISerialize, Runnable {
if (item.getBaseItem().getType() != FurnitureType.FLOOR)
continue;
- if (item.getX() == tile.x && item.getY() == tile.y) {
- items.add(item);
- } else {
- if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
- continue;
- }
+ int width, length;
- THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- for (RoomTile t : tiles) {
- if ((t.x == tile.x) && (t.y == tile.y) && (!items.contains(item))) {
- items.add(item);
- }
- }
+ if (item.getRotation() != 2 && item.getRotation() != 6) {
+ width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
+ length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
+ }
+ else {
+ width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
+ length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
+ }
+
+ if (!(tile.x >= item.getX() && tile.x <= item.getX() + width - 1 && tile.y >= item.getY() && tile.y <= item.getY() + length - 1))
+ continue;
+
+ items.add(item);
+
+ if(returnOnFirst) {
+ return items;
}
}
@@ -3339,20 +3401,7 @@ public class Room implements Comparable, ISerialize, Runnable {
if (item.getZ() < minZ)
continue;
- if (item.getX() == x && item.getY() == y && item.getZ() >= minZ) {
- items.add(item);
- } else {
- if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
- continue;
- }
-
- THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- for (RoomTile tile : tiles) {
- if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) {
- items.add(item);
- }
- }
- }
+ items.add(item);
}
return items;
}
@@ -3360,54 +3409,22 @@ public class Room implements Comparable, ISerialize, Runnable {
public THashSet getItemsAt(Class extends HabboItem> type, int x, int y) {
THashSet items = new THashSet<>();
- TIntObjectIterator iterator = this.roomItems.iterator();
+ for (HabboItem item : this.getItemsAt(x, y)) {
+ if (!item.getClass().equals(type))
+ continue;
- for (int i = this.roomItems.size(); i-- > 0; ) {
- HabboItem item;
- try {
- iterator.advance();
- item = iterator.value();
- } catch (Exception e) {
- break;
- }
-
- if (item.getClass().equals(type)) {
- if (item.getX() == x && item.getY() == y) {
- items.add(item);
- } else {
- if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
- continue;
- }
-
- THashSet tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- for (RoomTile tile : tiles) {
- if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) {
- items.add(item);
- }
- }
- }
- }
+ items.add(item);
}
-
return items;
}
public boolean hasItemsAt(int x, int y) {
- TIntObjectIterator iterator = this.roomItems.iterator();
+ RoomTile tile = this.getLayout().getTile((short) x, (short) y);
- for (int i = this.roomItems.size(); i-- > 0; ) {
- HabboItem habboItem;
- try {
- iterator.advance();
- habboItem = iterator.value();
- } catch (Exception e) {
- break;
- }
+ if(tile == null)
+ return false;
- if (habboItem.getX() == x && habboItem.getY() == y) return true;
- }
-
- return false;
+ return this.getItemsAt(tile, true).size() > 0;
}
public HabboItem getTopItemAt(int x, int y) {
@@ -3415,55 +3432,24 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public HabboItem getTopItemAt(int x, int y, HabboItem exclude) {
- HabboItem item = null;
+ RoomTile tile = this.getLayout().getTile((short) x, (short) y);
- TIntObjectIterator iterator = this.roomItems.iterator();
+ if(tile == null)
+ return null;
- for (int i = this.roomItems.size(); i-- > 0; ) {
- HabboItem habboItem;
- try {
- iterator.advance();
- habboItem = iterator.value();
- } catch (Exception e) {
- break;
- }
+ HabboItem highestItem = null;
- if (habboItem.getBaseItem().getType() != FurnitureType.FLOOR)
+ for (HabboItem item : this.getItemsAt(x, y)) {
+ if(exclude != null && exclude == item)
continue;
- if (exclude != null) {
- if (exclude == habboItem)
- continue;
- }
+ if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
+ continue;
- if (habboItem.getX() == x && habboItem.getY() == y) {
- if (item == null || (habboItem.getZ() + Item.getCurrentHeight(habboItem)) > (item.getZ() + Item.getCurrentHeight(item))) {
- item = habboItem;
- }
- } else {
- if (habboItem.getBaseItem().getWidth() <= 1 && habboItem.getBaseItem().getLength() <= 1) {
- continue;
- }
-
- if (this.layout == null) continue;
-
- THashSet tiles = this.layout.getTilesAt(
- this.layout.getTile(habboItem.getX(), habboItem.getY()),
- habboItem.getBaseItem().getWidth(),
- habboItem.getBaseItem().getLength(),
- habboItem.getRotation()
- );
-
- for (RoomTile tile : tiles) {
- if (((tile.x == x) && (tile.y == y))) {
- if (item == null || item.getZ() < habboItem.getZ())
- item = habboItem;
- }
- }
- }
+ highestItem = item;
}
- return item;
+ return highestItem;
}
public double getTopHeightAt(int x, int y) {
@@ -3494,17 +3480,14 @@ public class Room implements Comparable, ISerialize, Runnable {
THashSet items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (HabboItem item : items) {
- if (item.getBaseItem().allowSit()) {
- if (lowestChair == null || item.getZ() < lowestChair.getZ()) {
- lowestChair = item;
- }
- }
- if (lowestChair != null) {
- if (item.getZ() > lowestChair.getZ() && item.getZ() - lowestChair.getZ() < 1.5) {
- lowestChair = null;
- }
- }
+ if(!item.getBaseItem().allowSit())
+ continue;
+
+ if(lowestChair != null && lowestChair.getZ() < item.getZ())
+ continue;
+
+ lowestChair = item;
}
}
@@ -3512,37 +3495,39 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) {
+
if (x < 0 || y < 0 || this.layout == null)
return calculateHeightmap ? Short.MAX_VALUE : 0.0;
+
+ if (Emulator.getPluginManager().isRegistered(FurnitureStackHeightEvent.class, true)) {
+ FurnitureStackHeightEvent event = Emulator.getPluginManager().fireEvent(new FurnitureStackHeightEvent(x, y, this));
+ if(event.hasPluginHelper()) {
+ return calculateHeightmap ? event.getHeight() * 256.0D : event.getHeight();
+ }
+ }
double height = this.layout.getHeightAtSquare(x, y);
boolean canStack = true;
- boolean stackHelper = false;
- THashSet items = this.getItemsAt(x, y);
- if (items != null) {
- for (HabboItem item : items) {
+
+ THashSet stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y);
+
+ if(stackHelpers.size() > 0) {
+ for(HabboItem item : stackHelpers) {
if (item == exclude) continue;
-
- if (item instanceof InteractionStackHelper) {
- stackHelper = true;
- height = item.getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(item.getExtradata()) / 100);
- canStack = true;
- }
+ return calculateHeightmap ? item.getZ() * 256.0D : item.getZ();
}
+ }
- if (!stackHelper) {
- HabboItem item = this.getTopItemAt(x, y, exclude);
- if (item != null) {
- canStack = item.getBaseItem().allowStack();
- height = item.getZ() + Item.getCurrentHeight(item);
- }
+ HabboItem item = this.getTopItemAt(x, y, exclude);
+ if (item != null) {
+ canStack = item.getBaseItem().allowStack();
+ height = item.getZ() + Item.getCurrentHeight(item);
+ }
- HabboItem lowestChair = this.getLowestChair(x, y);
- if (lowestChair != null && lowestChair != exclude) {
- canStack = true;
- height = lowestChair.getZ() + Item.getCurrentHeight(lowestChair);
- }
- }
+ HabboItem lowestChair = this.getLowestChair(x, y);
+ if (lowestChair != null && lowestChair != exclude) {
+ canStack = true;
+ height = lowestChair.getZ();
}
if (calculateHeightmap) {
@@ -3742,6 +3727,10 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public void botChat(ServerMessage message) {
+ if (message == null) {
+ return;
+ }
+
for (Habbo habbo : this.getHabbos()) {
if (!habbo.getHabboStats().ignoreBots)
habbo.getClient().sendResponse(message);
@@ -3758,7 +3747,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -3777,7 +3766,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -3821,7 +3810,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setInt(2, userId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -3858,7 +3847,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setInt(2, userId);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -3876,7 +3865,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setInt(1, this.id);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
this.refreshRightsInRoom();
@@ -3943,7 +3932,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
@@ -4195,7 +4184,7 @@ public class Room implements Comparable, ISerialize, Runnable {
for (Habbo habbo : this.getHabbos()) {
if (habbo.getHabboInfo().getCurrentRoom() == this) {
if (habbo.getHabboInfo().getId() != this.ownerId) {
- if (!(habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission("acc_moverotate")))
+ if (!(habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_MOVEROTATE)))
this.refreshRightsForHabbo(habbo);
}
}
@@ -4247,7 +4236,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setString(2, word);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
return;
}
@@ -4264,7 +4253,7 @@ public class Room implements Comparable, ISerialize, Runnable {
statement.setString(2, word);
statement.execute();
} catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
+ LOGGER.error("Caught SQL exception", e);
}
}
}
@@ -4355,6 +4344,8 @@ public class Room implements Comparable, ISerialize, Runnable {
return FurnitureMovementError.MAX_ITEMS;
}
+
+
rotation %= 8;
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) {
return FurnitureMovementError.NONE;
@@ -4407,23 +4398,35 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) throws Exception {
+ boolean pluginHelper = false;
if (Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) {
- Event furniturePlacedEvent = new FurniturePlacedEvent(item, owner, tile);
- Emulator.getPluginManager().fireEvent(furniturePlacedEvent);
+ FurniturePlacedEvent event = Emulator.getPluginManager().fireEvent(new FurniturePlacedEvent(item, owner, tile));
- if (furniturePlacedEvent.isCancelled())
+ if (event.isCancelled()) {
return FurnitureMovementError.CANCEL_PLUGIN_PLACE;
+ }
+
+ pluginHelper = event.hasPluginHelper();
}
THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
FurnitureMovementError fits = furnitureFitsAt(tile, item, rotation);
- if (!fits.equals(FurnitureMovementError.NONE)) {
+ if (!fits.equals(FurnitureMovementError.NONE) && !pluginHelper) {
return fits;
}
- item.setZ(tile.getStackHeight());
+ double height = tile.getStackHeight();
+
+ if (Emulator.getPluginManager().isRegistered(FurnitureBuildheightEvent.class, true)) {
+ FurnitureBuildheightEvent event = (FurnitureBuildheightEvent) Emulator.getPluginManager().fireEvent(new FurnitureBuildheightEvent(item, owner, 0.00, height));
+ if (event.hasChangedHeight()) {
+ height = event.getUpdatedHeight();
+ }
+ }
+
+ item.setZ(height);
item.setX(tile.x);
item.setY(tile.y);
item.setRotation(rotation);
@@ -4475,9 +4478,14 @@ public class Room implements Comparable, ISerialize, Runnable {
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) {
RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY());
+
+ boolean pluginHelper = false;
if (Emulator.getPluginManager().isRegistered(FurnitureMovedEvent.class, true)) {
- if (Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile)).isCancelled())
+ FurnitureMovedEvent event = Emulator.getPluginManager().fireEvent(new FurnitureMovedEvent(item, actor, oldLocation, tile));
+ if(event.isCancelled()) {
return FurnitureMovementError.CANCEL_PLUGIN_MOVE;
+ }
+ pluginHelper = event.hasPluginHelper();
}
HabboItem topItem = this.getTopItemAt(tile.x, tile.y);
@@ -4489,15 +4497,15 @@ public class Room implements Comparable, ISerialize, Runnable {
//Check if can be placed at new position
THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
- if (!stackHelper.isPresent()) {
+ if (!stackHelper.isPresent() && !pluginHelper) {
if (topItem != item) {
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()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
return FurnitureMovementError.CANT_STACK;
- if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
- if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
- if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
+ if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
+ if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
+ if (!magicTile && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
}
}
@@ -4539,6 +4547,13 @@ public class Room implements Comparable